Best event for auto stacking new sources

hey had some time and threw together a mode that should do it.
Just quick and dirty so don’t expect it to be robust but the basic functionality should be there

from rv import rvtypes, commands


class LoadPlates(rvtypes.MinorMode):

    def __init__(self):
        rvtypes.MinorMode.__init__(self)
        self.init(
            "load_plates",
            [("source-group-complete", self.load_plate, "")],
            None
        )

    def load_plate(self, event):
        event.reject()

        contents = event.contents()
        added_node = contents.split(";;")[0]

        src_path = commands.getStringProperty(f"{added_node}_source.media.movie")[0]
        plate_path_to_add = self.find_plate_path(src_path)
        added_plate_node = commands.addSourceVerbose([plate_path_to_add])

        stack_node = commands.newNode("RVStackGroup", "PlateStack")
        commands.setNodeInputs(stack_node, [added_plate_node, added_node])

        self.add_to_custom_sequence(stack_node=stack_node)

    def add_to_custom_sequence(self, stack_node: str):
        sequence_node = "MySequenceNode"
        if not commands.nodeExists(sequence_node):
            commands.newNode("RVSequenceGroup", sequence_node)

        input_nodes, _ = commands.nodeConnections(sequence_node)
        input_nodes.append(stack_node)
        commands.setNodeInputs(sequence_node, input_nodes)

        commands.setViewNode(sequence_node)

    def find_plate_path(self, source_path: str) -> str:
        # TODO: implement
        pass



def createMode():
    "Required to initialize the module. RV will call this function to create your mode."
    return LoadPlates()

1 Like