RV Cookbook - How to get things done with RV in Python

I found it frequently time intensive to figure out how to do things with RV… And what I wish I had was a cookbook that I could just look up snippets in…

So let’s start one together as a community.

Add snippets that work and are helpful. Please

  1. If there is a post already use Copy Quote to link to original post (for further reference)
  2. Mention the version of RV that the snippet works with
  3. Preferably make it executable in the Python Console for RV (if possible)

Let’s make it fun and helpful :slight_smile:

And if you are looking for basic getting started guidance instead of snippets:

12 Likes

Adding multiple media representations.
Works in RV 2024.1.0, link to docs

Link media brought in via drag and drop to Shotgun

The Shotgun Mode has changed by the way

Building a stack
Works in RV 2024.1.0

Accessing Shotgun from RV (works in 2024.1.0

Adding a source to a sequence (and creating seq if its not already there)

Moving nodes to a Folder (works in RV 2024.10)

import rv

def move_to_folder(source_group: str,
                   folder_node="AutoStackFolder",
                   folder_name="AutoStack Temp Folder"):
    if not rv.commands.nodeExists(folder_node):
        rv.commands.newNode("RVFolderGroup", folder_node)
        rv.extra_commands.setUIName(folder_node, folder_name)

    input_nodes = rv.commands.nodeConnections(folder_node, False)[0]
    if not source_group in input_nodes:
        input_nodes.append(source_group)
        rv.commands.setNodeInputs(folder_node, input_nodes)

Influencing the ordering that events are processed between custom modules

Ever wondered how to create a custom property? The docs don’t go into detail on it so here an example.

Works in RV 2024.1.0

Very useful snippets

Setting up an Example Look Pipeline

More tips for using Mu via Python

Changing the Composite Type on all Stacks (types other then replace can be found here)

Accessing SG Tracking Info for a given source

It’s important to wait until the tracking info is populated though

Getting the file path of the current media source

Getting the file name (and path) of the frame currently being played

Display Feedback in the upper left corner

An binding to an event that is only run once

How do I install Python Libraries to be used by RV Mode’s I develop?

When it’s Py Libs without compiled c code you can use
python -m pip install tool --target rv-py-libs

and then just add it as a path in your mode
import sys
sys.append("path/to/lib")

But when there is complied c code that doesn’t work as the compiled libs throw an error on import. This here works though (sample from Win)
"C:\Program Files\Autodesk\RV-2024.1.0\bin\python" -m pip install timerit