Is there a way to get and and set the source order in scene?

upgradeQ

Member
Yes , using obs_sceneitem_set_order_position . Here is how to get & set order :

Python:
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"])
See full example here: https://github.com/upgradeQ/OBS-Stu...75318a5a6e248c55ae11c9406/src/change_order.py
 

Alexik

New Member
Yes , using obs_sceneitem_set_order_position . Here is how to get & set order :

Python:
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"])
See full example here: https://github.com/upgradeQ/OBS-Stu...75318a5a6e248c55ae11c9406/src/change_order.py
some late but thanks anyway :)
 

CowbanC

New Member
The Move plugin includes a means to move a source in the Scene, Source list in relation to the other sources.
I use it to keep multiple cameras in a scene visible for Sammi (a Streamer.bot alternative)
but move the single camera I want in a particular Scene to the top of the list.
A simple Move Source Scene filter for each camera source.
 
Top