What are some useful python snippets for working in RV?

Most of the Python commands are actually bindings on top of Mu commands. Mu is a native RV scripting language.

You can find most of the API documentation by launching RV then going Help -> Mu Command API Browser.

The most useful modules are rv.commands and rv.extra_commands. These are the bulk of operations that you can perform in RV.

Quick initial example

initial import

from rv import commands
from rv import extra_commands

Get all of the sources that are available at a specific frame

sources = commands.sourcesAtFrame(frame)

Get metadata info

print commands.sourceMediaInfo(sources[0])
print commands.sourceAttributes(“RVFileSource”)

Get file names

fileNames = commands.getStringProperty("%s.media.movie" % sources[0], 0, 1000)
fileName = fileNames[0]

Get annotated frames

frames = extra_commands.findAnnotatedFrames()

Set Stack view to be default


Setting up an Example Look Pipeline

Initial Import

from rv import commands, extra_commands

Get the last source at current frame

source = commands.sourcesAtFrame(commands.frame()[0])

Find the source group

sourceGroup = commands.nodeGroup(source)

Find the look pipe group that is on the source group

lookPipe = extra_commands.nodesInGroupOfType(sourceGroup, “RVLookPipelineGroup”)[0]

Set the order of the look pipe operations

commands.setStringProperty("%s.pipeline.nodes" % lookPipe, [“LinearToAlexaLogC”, “RVLookLut”, “rec709ToLinear”], True)

Find nodes of type RVLookLUT

looklut = commands.nodesInGroupOfType("%s.pipeline.nodes", “RVLookLUT”)

Set the LUT file path on the node you found

commands.setStringProperty("%s.lut.file" % “/path/to/cube”)

More tips for using Mu via Python

Sometimes some Mu commands aren’t bound in Python. In this case you have 2 ways of calling Mu from Python:

  1. If symbol exists in Mu but isn’t bound to python:

from pymu import MuSymbol
mute = MuSymbol(“rvui.isMuted”)

  1. If the symbol is either private or isn’t bound anywhere, you can directly evaluate Mu from Python:

import rv
rv.runtime.eval(“rvui.isMuted(); 1;”, [“rvui”])