RenderMan Look File Scripting

RenderMan Look File Scripting

RenderMan ships with two Python modules that can be used for easy, programmatic access to RenderMan Look Files: rlf.py and rlf2maya.py. rlf.py can either be run from inside Maya to manipulate a scene's RLF data, or standalone to load and store RenderMan Look Files to disk for rendering. rlf2maya.py needs to run inside Maya's Python environment, and requires RenderMan for Maya to be loaded.

rlf.py

The various classes in rlf.py make it possible to query and update the Look File but don't provide access to the execution of rules (XPath) or interaction with RenderMan for Maya.

Example Usage:

import rfm.rlf as rlf

scope = rlf.RLFScope()
scope.LoadRlf("perspShape_Final.0001.orig.rlf")
dynRules = scope.GetRules()

newscope = rlf.RLFScope()
for rule in dynRules:
    print "processing rule " + rule.GetRuleString()
    if "Sphere" in rule.GetRuleString():
       newscope.AddRule(rule)

serial = newscope.Serialize()
f = open("perspShape_Final.0001.rlf", "w")
f.write(serial)
f.close()

Scope Commands

AddRule(self,rlfRule)

Add the RLFRule to the end of the internal dynamic rules list.

AddStaticBinding(self, attrIdPath, payloadId)

Add a static binding...

AddStaticEdit(self, attrIdPath, payloadId)

Add a static edit...

CreatePayload(self, Id, Type, Value)

Create a new payload.

DeleteRule(self,rlfRule)

Delete the specified rule from the dynamic rules list.

DeleteRuleAtIndex(self,index)

Delete the specified rule from the dynamic rules list.

DeleteStaticBinding(self, attrIdPath)

Delete a static binding...

DeleteStaticEdit(self, attrIdPath)

Delete a static edit...

Deserialize(self, serializedRlf)

Initialized from a serialized JSON string.

FindStaticBindingPayload(self, attrIdPath)

If there is a static binding for the attrIdPath then return the RLFPayload for it, otherwise return None.

FindStaticEditPayload(self, attrIdPath)

If there is a static edit for the attrIdPath then return the RLFPayload for it, otherwise return None.

GetEditPayloads(self)

Returns the dictionary of id's to edit payloads.

GetHeader(self)

Return the header dictionary.

GetHeaderValue(self,key)

Return a specified entry from the m_header dictionary.

GetInjectionPayloads(self)

Returns the dictionary of id's to injection payloads.

GetRule(self,index)

Return the RLFRule object from the specified index in the dynamic rules list.

GetRules(self)

Return the list of rules.

GetStaticBindings(self)

Return the static binding dictionary.

InsertRule(self,index,rlfRule)

Insert the passed rule into the index position of internal dynamic rules list.

LoadRlf(self, filename)

Reconstitute a rlfScope object from a RLF JSON representation on disk.

RemovePayload(self, payloadId)

Delete a payload associate with the specified payloadID.

ReplaceRule(self,index,rlfrule)

Replace the specified rule in the dynamic rules list.

Serialize(self, asString=True)

Return a string or dictionary representation of the scope.

SetEditPayloads(self, payloads)

Sets the dictionary of id's to edit payloads.

SetHeader(self,headerDict)

Override the header dictionary.

SetHeaderValue(self,key,value)

Set a specific header value.

SetInjectionPayloads(self, payloads)

Sets the dictionary of id's to injection payloads.

Rule Commands

GetDict(self)

Returns the dictionary of rule data.

GetMatchPhase(self)

Get the type of the rule, edit or inject.

GetMatchType(self)

Get the match type of the rule, glob xpath re etc...

GetPayload(self)

Get the RLF payload object for the rule.

GetPayloadId(self)

Returns the payload id.

GetRuleString(self)

Get the rule string.

GetUserData(self,key)

Get the user data for the given key.
Initialize(self, matchphase, matchtype, rulestring, flowcontrol, payload=None)
Initialize rule

SetFlowControl(self,value)

Set the continuation behavior of the rule.

SetMatchType(self,matchtype)

Set the match type of the rule, glob xpath re etc...

SetPayload(self,rlfPayload)

Set the RLF payload object for the rule.

SetRuleString(self,value)

Set the rule string.

SetUserData(self,key,value)

Add/set the user data for the given key.

SetUserDataDict(self,d)

Add/set the user data for the given key.

Payload Commands

GetData(self)

Return the payload data.

GetDict(self)

Returns a dictionary entry for the payload map.

GetID(self)

Return the payload ID.

GetType(self)

Return the type of the payload; it can be either an edit or inject payload.

SetData(self,value)

Set the payload data.

SetID(self,value)

Set the payload ID.

SetType(self,value)

Sets the type of the payload; it can be either an edit or inject payload.

rlf2maya.py

rlf2maya.py provides convenient Python routines to the RenderMan for Maya rman sub-commands for getting and setting the RenderMan Look File Scope object found in the rfm.rlf Python module (rlf.py).

Example Usage:

import rfm.rlf2maya as rlf2maya

s = rlf2maya.GetActiveScope()

# modify s in someway (see rlf.py)
s.AddRule(rule)

# replace the current scene's active scope
rlf2maya.SetActiveScope(s)

Commands

GetActiveScope()

Return a copy of the RLFScope object that is the scene's current scope.

GetScope(scopeName)

Return a copy of the RLFScope object of the given name.

GetScopeNames()

Return the list of scope names in the current scene.

SetActiveScope(scope)

Set the current scene's active RLF data to be the given RLFScope. This overrides the scene's current active scope.