rr Module

The module rr is available for all python scripts in RR applications. It is already loaded/imported.

Each RR application has a different rr module, but the function names are the same. Some functions are not available in all RR applications.

Functions - Commands

rr.jobModify((list)jobIDs, (_SettingsOnly)settings, (_SettingsOnly) change) bool

Send a Change Settings command to the rrServer (like rrControl tab Job Settings).

Parameters:
  • jobIDs (list) – list of rrJob._JobMinInfo.ID of jobs that you want to change

  • settings (rrJob._SettingsOnly) – the new values you want to set

  • change (rrJob._SettingsOnly) – which parameters you want to change. E.g. if you want to change the user name for all jobs, but all jobs should keep their sequence start-end. To let RR know that you want to change this value, just set them to anything non-null. (bool values to true, integer to 1, strings to e.g. “1”.)

Returns:

Success

Return type:

bool

You need to call rrJob.getClass_SettingsOnly() to get a rrJob._SettingsOnly instance.

Note

The job table display does not update until the next refresh. But the job itself will be changed (you can verify it if you re-select the job and check the Job Settings page in rrControl)

Example: Setting frame range in a rrControl, per-job script

# Set job frames to the range 50 - 60

job = rr.getJob()

job_settings = rrJob.getClass_SettingsOnly()
job_settings.seqStart = 50
job_settings.seqEnd = 60

# Inform RR of which attributes have changed using another :class:`rrJob._SettingsOnly` instance

job_flags = rrJob.getClass_SettingsOnly()
job_flags.seqStart = 1
job_flags.seqEnd = 1

job_IDs = [job.ID]

success = rr.jobModify(job_IDs, job_settings, job_flags)

if not success:
    print("Unable to modify job")

Available in:

  • rrControl

rr.jobSendCommand((list)jobIDs, (rrJob._LogMessage)commandID, (int)commandParam) bool

Send a Job command to the rrServer. jobIDs is a list of rrJob._JobMinInfo.ID of jobs that you want to send a command to.

Note

The job in rrControl will not update until rrControl gets an update from the rrServer.

Available in:

  • rrControl

  • rrServer - Event plugin

rr.clientSendCommand((list)clients, (int)commandID, (str)param) bool

Sends a command to rrClients. clients is a list of client IDs as positional integers. If the list has only one element and it equals -1, then the command is applied to all clients.

param is an optional string parameter. It can be used to send commandlines to the client with the commandID rrGlobal._ClientCommand.cCommandLinecCommandLine”

Available in:

  • rrControl

  • rrServer - Event plugin

Example, executing a command line on a all selected clients

for c in range(0, rr.clientAll_count()):
    client = rr.clientAll_get(c)
    if client.isSelected():
        selected_clients.append(client)

cmd_line = 'echo "Hello"<NL>'
success = rr.clientSendCommand(selected_clients,
                               rrGlobal._ClientCommand.cCommandLine,
                               cmd_line)

Functions - Data access

Misc

rr.sceneFileToLoad()

Returns the name of the scene file to be parsed.

Available in:

  • rrSubmitter Scene Parser

rr.returnFromPlugin((pluginReturn)returncode)

This function has to be executed by each scene parser plugin. It tells the rrSubmitter if the scene load was successful, if it failed or if this plugin is not the right plugin to load this kind of file. The return codes are stored in rrGlobal.pluginReturn

Example, failing to access the properties of an .xml file:

import os
import xml.etree.ElementTree

scene_file= rr.sceneFileToLoad()
try:
    scene_xml = xml.etree.ElementTree.parse(sceneFile).getroot()
except Exception:
    rr.returnFromPlugin(rrGlobal.pluginReturn.fileFailedToOpen)

Available in:

  • rrSubmitter Scene Parser - Scripted Job

All Jobs

rr.getNewJob() rrJob._JobSubmitter

Returns an empty job.

Available in:

  • rrSubmitter Scene Parser - Scripted Job

rr.jobAll_count() int

Returns the number of all jobs available in this RR application. It can be paired with jobAll_get() in for loops.

Available in:

  • rrControl job - perJob

  • rrControl job - once

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

  • rrSubmitter Scripted Job

  • rrSubmitter Scene Parser

  • rrServer - Event plugin

rr.jobAll_get((int)index) rrJob._JobSend

Returns the COPY of a job by its global list index. This function can be used in pair with jobAll_count()

Available in:

  • rrControl job - perJob

  • rrControl job - once

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

  • rrSubmitter Scripted Job

  • rrSubmitter Scene Parser

  • rrServer - Event plugin

Example, use an rrSubmitter onSubmission script to assign all jobs of user ‘Mario’ to user ‘Luigi’:

for i in range(rr.jobAll_count()):
    job = rr.jobAll_get(i)

    if job.userName == "Mario":
        job.userName = "Luigi"

        # job is a copy,  use jobAll_set to make changes effective
        rr.jobAll_set(i, job)
rr.jobAll_append(rrJob._jobSubmitter(job))

Add job to the list. If the job is already present in the list, it will be duplicated

Example:

new_job = getNewJob()

# ... set attributes of new job

jobAll_append(new_job)

Added in version 9.0.

rr.jobAll_set((int)index, rrJob._jobSubmitter(job))

Overwrites the job in the rrSubmitter with your job. Scripted Jobs/Scene Parser only. If the index is higher than the number of jobs in your list, this function is equivalent to jobAll_append(): the new job is appended and assigned the first available index.

Available in:

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

  • rrSubmitter Scripted Job

  • rrSubmitter Scene Parser

Example, replace all jobs with an Execute job, without changing the user:

for i in range(rr.jobAll_count()):
    job = rr.jobAll_get(i)

    new_job = getNewJob()
    new_job.userName = job.userName

    new_job.renderApp.name = "Execute"
    new_job.renderApp.type = "Execute"
    new_job.renderApp.executeType = rrGlobal.executeJobType.onceEachClient

    # ... set other attributes of the new job

    rr.jobAll_set(i, new_job)
rr.jobVisible_count() int

Returns the number of all jobs that are currently visible in rrControl. Jobs that does not match your rrControl UI filter are not listed. It can be used with jobVisible_get() in for loops.

Available in:

  • rrControl job - perJob

  • rrControl job - once

rr.jobVisible_get((int)index) rrJob._JobSend

Returns the COPY of a job displayed in the joblist by its display index. It can be used with jobVisible_count() in for loops.

Available in:

  • rrControl job - perJob

  • rrControl job - once

rr.jobAll_setShotgunID((int)index, (string)shotgunID)

Set the shotgunID of the job at index.

Available in:

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

  • rrSubmitter Scripted Job

  • rrSubmitter Scene Parser

Example, assigning a shotgun ID inside an onSubmission plugin

import  rrSG
import  rr

for i in range(rr.jobSelected_count():
    job= rr.jobSelected_get(i)
    sh_ID= str(rRifle.getRenderEntityFromRRJobId(job.IDstrFull()))
    rr.jobAll_setShotgunID(i, sh_ID)
rr.populatePreIDs()

Sets increasing rrJob._JobBasics.preID numbers for all jobs currently in the rrSubmitter. PreIDs are not set by default, but they required if you want to set rrJob._JobBasics.waitForPreID for some job.

Available in:

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

  • rrSubmitter Scripted Job

  • rrSubmitter Scene Parser

Example, create a new job that waits for two existing jobs to finish

rr.populatePreIDs()

job_a = rr.jobAll_get(0)
job_b = rr.jobAll_get(1)

new_job = rr.getNewJob()
new_job.waitForPreID_set(0, job_a.preID)
new_job.waitForPreID_set(1, job_b.preID)
new_job.maxWaitForPreID = 2

Current Job

rr.getJob() rrJob._JobSend

Returns a COPY of the rrJob._JobSend, to which the perJob script belongs.

Note

Changing the values of the returned job doesn’t affect the attributes of the stored job.

setJob() must be invoked to store the changes.

Note

perJob plugins are called once for each selected/checked job.

Example: Setting a custom variable inside a rrSubmitter, onSubmission script

job = rr.getJob()
job.customDataSet_Str("MyCustomVar", "MyCustomValue")
rr.setJob(job)

Available in:

  • rrControl job - perJob

  • rrSubmitter onSubmission - perJob

  • rrServer - Event plugin

  • rrServer - Status change

  • rrServer - Notification plugin

rr.perJobCurrent() int

Returns the index of the current job in the execution list.

Note

perJob plugins are called once for each selected job.

Available in:

  • rrControl job - perJob

rr.perJobMax() int

Returns the number of all jobs in the execution list.

Note

perJob plugins are called once for each selected job.

Available in:

  • rrControl job - perJob

rr.setJob((rrjob._JobSubmitter)job)

Overwrites the job of the current perJob script with given job.

Available in:

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

Selected/Submitted Jobs

rr.jobSelected_count() int

in rrControl: Returns the number of all selected jobs. in rrSubmitter: Returns the number of all checked jobs.

Available in:

  • rrControl job - perJob

  • rrControl job - once

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

rr.jobSelected_get(int(index)) rrJob._JobSend

Returns a COPY of a selected job by its index.

Available in:

  • rrControl job - perJob

  • rrControl job - once

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

Example, gather all paths of selected objects inside an rrControl or rrSubmitter python script

selected_job_paths = []

for i in range(rr.jobSelected_count()):
    selected_job = rr.jobSelected_get(i)
    selected_path = "".join(selected_job.imageDir,
                            selected_job.imageFileName,
                            "#"*selected_job.imageFramePadding,
                            selected_job.imageExtension)

    selected_job_paths.append(selected_path)
rr.jobSelected_set((int)index, (rrJob._JobSubmitter) job)

Overwrites the job selected in the rrSubmitter at index with given job.

Available in:

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

rr.jobSelected_setShotgunID((int)index, (string)shotgunID)

Set the shotgunID of the job at selection index. See jobAll_setShotgunID()

Available in:

  • rrSubmitter onSubmission - perJob

  • rrSubmitter onSubmission - once

  • rrSubmitter Scripted Job

  • rrSubmitter Scene Parser

Clients

rr.clientAll_count() int

Gets the number of clients. To use in combination with clientAll_get() in for loops.

Available in:

  • rrControl client - perClient

  • rrControl client - once

  • rrServer - Event plugin

rr.clientAll_get()

getClient() -> _Client:

Gets a reference to the current client. To use in combination with clientAll_count() in for loops.

Note

perClient plugins are called once for each selected client.

Example: Getting a list of selected clients in a rrControl script

selected_clients = []
clients_count = rr.clientAll_count()

for c in range(clients_count):
    if (rr.clientAll_get(c).isSelected()):
        selected_clients.append(c)

Available in:

  • rrControl client - perClient

rr.perClientCurrent() int

Gets the number of the current client in the execution list.

Note

perClient plugins are called once for each selected Client.

Available in:

  • rrControl job - perClient

rr.perClientMax() int

Gets the number of all clients in the execution list.

Note

perClient plugins are called once for each selected client.

Available in:

  • rrControl job - perClient