def get_order(scene_items=None):
order = list()
for i, s in enumerate(scene_items):
source = obs.obs_sceneitem_get_source(s)
name = obs.obs_source_get_name(source)
order.append({"index": i, "name": name, "scene_item": s})
return order
def reorder():
current_scene = obs.obs_frontend_get_current_scene()
with scene_ar(current_scene) as scene:
with scene_enum(scene) as scene_items:
order = get_order(scene_items)
# change second index with pre last
order[1]["index"], order[-2]["index"] = (
order[-2]["index"],
order[1]["index"],
)
for s in sorted(order, key=lambda i: i["index"]):
obs.obs_sceneitem_set_order_position(s["scene_item"], s["index"])
some late but thanks anyway :)Yes , using obs_sceneitem_set_order_position . Here is how to get & set order :
See full example here: https://github.com/upgradeQ/OBS-Stu...75318a5a6e248c55ae11c9406/src/change_order.pyPython:def get_order(scene_items=None): order = list() for i, s in enumerate(scene_items): source = obs.obs_sceneitem_get_source(s) name = obs.obs_source_get_name(source) order.append({"index": i, "name": name, "scene_item": s}) return order def reorder(): current_scene = obs.obs_frontend_get_current_scene() with scene_ar(current_scene) as scene: with scene_enum(scene) as scene_items: order = get_order(scene_items) # change second index with pre last order[1]["index"], order[-2]["index"] = ( order[-2]["index"], order[1]["index"], ) for s in sorted(order, key=lambda i: i["index"]): obs.obs_sceneitem_set_order_position(s["scene_item"], s["index"])