Order sources in sequence


Just getting started with RV api. Let me know if am missing something. Let’s say, user has 3 movs loaded and we want to load the raw plates for those movs. Currently it loads all the new plates after the 3 movs. Is there any api to place the plates next to the mov.


instead of




Hi @Kessler
Just wondering if I am clear with the question. We have couple of features pending because of this so just wanted to know if you guys need more info. To iterate, I am basically looking for a way to re order sources or insert new source at the desired index.

Thanks for your time! :slightly_smiling_face:

Hi and welcome to the community @cg-cnu,

I’m going to share a code snippet that will hopefully point you in the right direction. To understand the code it would help to know and understand a bit about the node graph in RV. If you’re not familiar with it, at the very least take a look at the first diagram here in the documentation.

Now on to the fun part.

When you talk about loading media before or after each other, you’re talking about a node graph that is viewing an RVSequenceGroup node. So our first step is to figure out which sequence node we are viewing. In most cases this will be the defaultSequence node but to be thorough we will programatically find the node:

from rv import commands as rvc

# Get the node being currently viewed
sequence_node = rvc.viewNode()
if rvc.nodeType(sequence_node) != "RVSequenceGroup":
    raise Exception("This is meant to work on sequences only")

Next, as you can see from the node graph diagram, an RVSequenceGroup node has a number of inputs. Each of these inputs is an RVSourceGroup node. You can see the structure of such a node here in the documentation. Here I’m going to assume that you need the file path to decide on the order you want to display them. So let’s get all the input nodes and extract their file paths:

# Get the input and output nodes from the sequence node
inputs, outputs = rvc.nodeConnections(sequence_node)

# Create a mapping of the sources and their file paths. You could use the file paths
# to decide what order they should go in
source_media_map = {}
for source_group in inputs:
    group_child_nodes = rvc.nodesInGroup(source_group)
    source_node = [x for x in group_child_nodes if rvc.nodeType(x) == "RVFileSource"][0]
    source_media_map[source_node] = rvc.sourceMedia(source_node)[0]

At this point you can insert your logic on how to re-order the nodes. I’m just going to shuffle them. Then, you set the inputs of the sequence node to be your newly ordered list:

# We're just going to shuffle the original inputs for this example
new_order = inputs

# Set the newly ordered inputs on the sequence node
rvc.setNodeInputs(sequence_node, new_order)

I hope there’s enough there to help you figure out how to use these calls in your workflow.



@Ehsan Thank you so much for the detailed response. I haven’t quite understood the way RV works and at the same time the API docs are terse. This absolutely cleared up all the questions I have. We just smashed two tickets and released them on to the floor for testing and I really appreciate your help in getting this sorted. Cheers!

1 Like