I would try to use the source-group-complete event. This is triggered no matter where the source gets added from.
This is the first event where it is safe to intercept after adding a source and it should work for your use case.
in the event.contents() you can then find the added node and add it to your stack.
Then set the stack as the view node
→ should be commands.setViewNode(your_stack) or something similar
Let’s say I have 3 new sources and for each create a stack with the corresponding plate.
Would one of you know if there is sample code/docs that outlines how to?
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()