Package autodesk_toxik :: Module precomp
[frames] | no frames]

Module precomp

Module for precomp import related functionality.

Classes
  RenderPassInfo
Stores significant information about a single render pass:
  RenderPassLinkInfo
Stores significant information about a link to a set of passes (rendered from different cameras of a set):
  RenderLayerInfo
Stores significant information about a set of layers (rendered from different cameras of a set):
Functions
[Graph]
precompImport(filePathOrPrecompModule, destinationPath, passDestinationPath="", layerDestinationPath="", multiStream=True, singleCompImport=False, singleCompTemplateFilePath="", missingImageCb=None, missingTemplateCb=None, useDefaultTemplate=True, compUpdateCb=None)
Precomp import from either a PrecompModule instance or from a file path.
PrecompModule
getPrecompModule(filePathOrPrecompModule)
Builds a PrecompModule instance from either a PrecompModule or a file path which can be either be a '.precomp' file or a Maya file '.ma'/'.mb'.
[Graph]
importScene(scene, destinationPath, multiStream=True, singleCompImport=False, singleCompTemplateFilePath="", passDestinationPath="", layerDestinationPath="", missingImageCb=None, missingTemplateCb=None, useDefaultTemplate=True, compUpdateCb=None)
Creates or updates the compositions associated with each set of render cameras selected for import in the given scene.
tuple of Graph and bool
importRenderCameras(cameras, destinationPath, multiStream=True, singleCompImport=False, singleCompTemplateFilePath="", passDestinationPath="", layerDestinationPath="", missingImageCb=None, missingTemplateCb=None, useDefaultTemplate=True, compUpdateCb=None)
Creates or updates the composition associated with the given set of render camera views (RenderCamera instances).
tuple of Graph and bool
importRenderLayers(layers, destinationPath, multiStream=True, passDestinationPath="", missingImageCb=None, missingTemplateCb=None, useDefaultTemplate=True, compUpdateCb=None)
Creates or updates the composition associated with the given render layers (RenderLayer instances).
tuple of Graph and bool
importRenderPasses(passes, destinationPath, missingImageCb=None, compUpdateCb=None)
Creates or updates the composition associated with the given render passes.
str
getPrecompAnchorType(precompClass)
Returns: The anchor type (str) used for the specified PrecompObject class.
tuple
getPrecompAnchor(node, precompClass)
Returns: The precomp anchor on the given node for the specified PrecompObject class.
tuple
getPrecompAnchors(node, precompClasses)
Returns: A tuple of precomp anchors on the given node for the specified list of precomp object classes.
 
setPrecompAnchor(node, precompClass, anchor)
Sets the precomp anchor on the given node for the specified precomp class, overwriting the previous one if it existed.
 
setPrecompAnchorFromObject(node, precompObject)
Sets the precomp anchor on the given node for the specified precomp object, overwriting the previous one if it existed.
 
removePrecompAnchors(node, precompClass)
Removes all precomp anchors for the specified precomp object type from the given node.
 
removeAllPrecompAnchors(node, exclude=[])
Removes all precomp anchors of any type (pass, layer, camera, etc) from the given node.
bool
hasPrecompAnchor(node)
Returns: True if the given node has any precomp anchor set on it.
tuple
getLinkNodeOutputCameraAnchor(linkNodeOutput)
Returns: The RenderCamera anchor of the given Link Image node output or None if there's none.
 
setLinkNodeOutputPrecompAnchors(linkNode)
This function sets the same anchors on the link node's output boundary nodes as the ones found on their respective linked output.
dict
findPrecompLinkNodes(compOrVersion, precompClasses, onlyAtTopLevel=False)
Finds all precomp link nodes for the specified precomp object class in the given Graph or Composition.
 
refreshPrecompLinkNodes(anchorsToLinkNodes)
Forces a refresh of the given precomp link nodes.
 
findAndRefreshPrecompLinkNodes(compOrVersion, precompClasses)
Forces a refresh of all precomp link nodes for the specified precomp object class in the given Graph or Composition.
LinkNode
initPrecompLinkNode(linkNode, precompClassesAndAnchors, nodeName=None)
Takes a link node and makes it a precomp link node based on the given precomp anchors.
LinkNode
createPrecompLinkNode(compOrVersionOrGroup, precompClassesAndAnchors, nodeName=None)
Adds a link node to the given composition/version/group and sets its precomp information according to the initPrecompLinkNode() function.
 
resetPrecompLinkNode(linkNode, precompClassesAndAnchors, nodeName=None, preserveOutputAnchors=True, preserveCameraAnchor=True)
Takes an existing precomp link node and resets it based on the given given precomp anchors.
LinkNode
createPrecompLinkNodeFromObject(compOrVersionOrGroup, precompObject)
Adds a precomp link node to the given composition/version/group.
bool
isPrecompLinkNodeMultiView(linkNode)
Returns: True if the given precomp link node is multi-view, i.e.
tuple
analysePrecompGraph(comp, precompLinkClasses)
Splits the top level nodes of the given Graph or Composition, into three categories and returns a tuple.
Composition
instantiatePrecompTemplate(templatePath, compPath, multiStream, backupVersion, precompObjects, precompLinkClasses, cameras=[])
Creates a new precomp composition based on the specified precomp template composition templatePath.
 
createPrecompOutputNodes(compVersion, cameras)
For each of the given RenderCamera instances, this function creates an output node in the given composition with the camera anchor set on it.
tuple
processPrecompLinkNodes(compVersion, precompLinkClasses, anchorsToPrecompObjects, anchorsToLinkedCompVersion, anchorsToLinkNodes, rebuildLinkNodes=False)
Adds missing precomp link nodes and rebuilds the existing ones in the given composition version compVersion.
 
stackRenderLayers(cameraCompVersion, layerAnchorToLinkNodes, layerAnchorToLayers, cameraAnchorToCamera, multiStream=True, stackGroupNodeName=None)
Stacks the render layers in a chain of Blend&Comp nodes according to the render layers compositing order and blend mode.
tuple
cleanupPrecompTemplate(comp, precompLinkClasses)
Cleans up the given template composition 'comp' to prepare it for instantiation.
 
cleanupPrecompLinkNodes(anchorsToLinkNodes, precompLinkClasses, preserveCameraAnchors=True)
Cleans up the the given precomp link nodes to prepare the ground for their update.
 
removePrecompLinkNodeDuplicates(anchorsToLinkNodes)
Remove any precomp link node duplicates, i.e.
dict
getLayerStackInfo(compPath)
Gets the information about the stack of render layers from the precomp settings of the camera composition.
 
setLayerStackInfo(compPath, layerSets)
Sets the information about the stack of render layers in the camera composition precomp setting.
 
updateLayerStackInfo(compPath, layerSets)
Updates the information about the stack of render layers in the camera composition precomp setting.
bool
hasLayerStackInfo(compPath)
Returns: True if the composition has precomp settings that store information about a stack of render layers.
dict
getPassLinksInfo(compPath)
Gets the information about links to render passes in the composition precomp settings.
 
setPassLinksInfo(compPath, passSets)
Sets the information about the imported passes in the composition precomp settings.
 
updatePassLinksInfo(compPath, passSets)
Updates the information about the imported passes in the composition precomp settings.
bool
hasPassLinksInfo(compPath)
Returns: True if the composition has precomp settings that store information about links to render passes.
dict
getPassInfo(compPath)
Gets the information about the passes in the render pass composition precomp setting.
 
setPassInfo(compPath, passes)
Sets the information about the imported passes in the render pass composition precomp setting.
 
writePrecompInfo(compPath, settingKey, infos)
Writes the given (*)Info instances to the composition precomp setting.
set
getCameraAnchorsFromXmlElement(xmlElement)
Returns: A set of camera anchors fetched from the given xml etree.Element.
 
addCameraAnchorsToXmlElement(anchors, xmlElement)
Adds a set of camera anchors to the given xml etree.Element.
tuple
getPrecompCompositionAttributes(precompObjects)
Returns: The following information about the composition that would represent the given objects:
 
setRate(compOrVersion, scene)
Sets the rate of the given composition/version based on the rate of the 3D scene.
 
setStartEnd(compOrVersion, start, end, outputName=None)
Sets the start/end of the given composition/version output.
 
setFormat(compOrVersion, precompObject, outputName=None)
Sets the image format and pixel format of the given composition/version based on the format of the given PrecompObject derived instance (Scene, RenderLayer or RenderPass).
str
getPrecompTemplatePath(path, precompObject, missingTemplateCb=None, useDefaultTemplate=True)
Checks whether the given template file path exists.
str
getDefaultPrecompTemplatePath(precompObject)
Returns: The default precomp template existing file path for the given PrecompObject derived instance or None if none were found.
 
validateDestinationFolder(path)
Validate destination folder and create it if need be.
tuple
getPrecompCompositionPath(destinationPath, compName, compUpdateCb, precompClass)
Determines the precomp composition path, handling the update mode if needed or throwing a RuntimeError if the conflict cannot be resolved.
callable
wrapCompUpdateCb(compUpdateCb)
Wraps the compUpdateCb parameter to provide the default behavior when the parameter is not callable.
str
sanitizeName(name)
Replaces invalid characters from the given name with Composite's default replacement character ('_').
 
getPrecompClassPrettyName(precompClass)
Returns a pretty name for the given PrecompObject derived class.
str
getCompositionTypeName(precompClass)
Returns: The name for the type of composition that the given PrecompObject derived class instantiates.
 
setTraceCallback(traceCb)
Sets a callback invoked by the functions in this module to provide information about what it's doing.
 
setWarningCallback(warningCb)
Sets a callback invoked by the functions in this module to show a warning.
bool
loadStreamTools()
Tries to load the multi-stream plugin tools.
str
getProjectRelativePath(path)
Returns: A path (str) relative to the current project root folder or the path itself if it's not under the project root.
tuple
getRenderCameraAnchor(obj)
Functor to get the render camera anchor of a Composite node or of a precomp object.
tuple
getSchematicPosition(node)
Returns: The position of a node in the schematic as an (x, y) float tuple.
 
setSchematicPosition(node, x, y)
Sets the (x, y) position of a node in the schematic.
Variables
  defaultPrecompTemplates = {}
  trace = lambda msg:
  warning = lambda msg:
  getAnchor = lambda x:
  getName = lambda x:
  isSelectedForImport = lambda x:
  formatModuleLoaded = False
  precompSettingGroup = "Precomp"
  layerStackInfoSetting = "LayerStackInfo"
  passLinksInfoSetting = "PassLinksInfo"
  passInfoSetting = "PassInfo"
  schematicNodeWidth = 125
  schematicNodeHeight = 45
Function Details

precompImport(filePathOrPrecompModule, destinationPath, passDestinationPath="", layerDestinationPath="", multiStream=True, singleCompImport=False, singleCompTemplateFilePath="", missingImageCb=None, missingTemplateCb=None, useDefaultTemplate=True, compUpdateCb=None)

 

Precomp import from either a PrecompModule instance or from a file path.

Parameters:
  • filePathOrPrecompModule (str or PrecompModule) - Can be either a PrecompModule instance or a str indicating a file path. If this argument is a a file path, the function guesses its type through its extension, which can be:
    • A Maya file: .ma or .mb
    • A precomp file: .precomp
  • destinationPath (str) - An absolute path to a folder to create/update the composition(s) into. The folder is created if it doesn't exist.
  • passDestinationPath (str) - A path, which can be absolute or relative to the destination folder, where the render pass compositions will be created/updated. The folder is created if it doesn't exist.
  • layerDestinationPath (str) - A path, which can be absolute or relative to the destination folder, where the render layer compositions will be created/updated. The folder is created if it doesn't exist.
  • multiStream (bool) - A boolean indicating whether compositions that contain many cameras (multi-view comp) will be made of a multi-stream graph (one stream per camera view) versus multiple duplicated graphs.
  • singleCompImport (bool) - Indicates whether render camera compositions will contain all the compositing graphs that would be present in each of its render layer compositions. Render passes are still imported in separate footage compositions, but are referenced directly from the camera composition.
  • singleCompTemplateFilePath (str) - A file path to a .txcomposition file to use as the template for the single composition import mode.
  • missingImageCb (callable) - Is a callable invoked whenever render pass image files cannot be found on disk. It receives the following arguments:
    • The path of the sequence of files that are missing.
    • The path of the render directory that was expected (a root directory where all rendered image files are located).
    • The name of the first file in the sequence (to test for file existence).

    The callback returns the directory where the missing image files can be found.

  • missingTemplateCb (callable) - A callable invoked whenever composition template file cannot be found. It receives the following arguments:
    • The PrecompObject derived instance from which the template path was taken.
    • The expected template file path.

    Returns the path to an existing template file, None if no template should be used and True if the default template should be used.

  • useDefaultTemplate (bool) - Indicates whether the default composition template should be used when no template is specified or when it cannot be found. Set to True by default.
  • compUpdateCb (callable) - A callable invoked whenever an existing composition is encountered to decide how to update it. compUpdateCb is passed two composition path and composition type string parameters. compUpdateCb must return a tuple. The first item of the tuple is an integer code for the update mode to apply:
    • 0: update working version.
    • 1: recreate working version.
    • 2: overwrite all versions.
    • 3: skip.

    The second item of the returned tuple is a boolean indicating whether a composition version to update/recreate must be backed up into a new version first. If compUpdateCb is set to None (default parameter) the default behavior is to update the working version of existing compositions and back it up in a new version first.

Returns: [Graph]
The list of created/updated camera composition versions (Graph).
Raises:
  • ValueError - If the specified file does not have a recognized extension.

getPrecompModule(filePathOrPrecompModule)

 

Builds a PrecompModule instance from either a PrecompModule or a file path which can be either be a '.precomp' file or a Maya file '.ma'/'.mb'.

For this function to work on a Maya file, the file must be opened by Maya, so the python interpreter must have its environment properly set to gain access to the Maya python API and be able to open the specified Maya file in a running instance of Maya (MAYA_LOCATION, PYTHONPATH and LD_LIBRARY_PATH or PATH environment variables).

Parameters:
  • filePathOrPrecompModule (PrecompModule or str) - Can be either a PrecompModule instance or a str indicating a file path. If this argument is a a file path, the function guesses its type through its extension, which can be:
    • A Maya file: .ma or .mb
    • A precomp file: .precomp
Returns: PrecompModule
A PrecompModule instance.
Raises:
  • RuntimeError - If the specified file cannot be opened in Maya.
  • ValueError - If the specified file does not have a recognized extension.
  • TypeError - If filePathOrPrecompModule is from an unsupported type.

importScene(scene, destinationPath, multiStream=True, singleCompImport=False, singleCompTemplateFilePath="", passDestinationPath="", layerDestinationPath="", missingImageCb=None, missingTemplateCb=None, useDefaultTemplate=True, compUpdateCb=None)

 

Creates or updates the compositions associated with each set of render cameras selected for import in the given scene.

Parameters:
Returns: [Graph]
The list of created/updated camera composition versions (Graph).

See Also: precompImport() for other arguments documentation.

importRenderCameras(cameras, destinationPath, multiStream=True, singleCompImport=False, singleCompTemplateFilePath="", passDestinationPath="", layerDestinationPath="", missingImageCb=None, missingTemplateCb=None, useDefaultTemplate=True, compUpdateCb=None)

 

Creates or updates the composition associated with the given set of render camera views (RenderCamera instances). This function recursively imports the render layer compositions for that render camera view.

Parameters:
Returns: tuple of Graph and bool
On success, a tuple containing the composition version associated with the given render cameras (opened at least in read-only) and a boolean indicating whether the composition has changed (was created or updated). The (None, false) tuple is returned on failure.

See Also: precompImport() for other arguments documentation.

importRenderLayers(layers, destinationPath, multiStream=True, passDestinationPath="", missingImageCb=None, missingTemplateCb=None, useDefaultTemplate=True, compUpdateCb=None)

 

Creates or updates the composition associated with the given render layers (RenderLayer instances). The given render layers are assumed to represent the same layer rendered from various cameras. This recursively imports the render pass compositions for that render layer.

Parameters:
  • layers (RenderLayer or list of them) - Render layers.
Returns: tuple of Graph and bool
On success, a tuple containing the composition version associated with the given render layers (opened at least in read-only) and a boolean indicating whether the composition has changed (was created or updated). The (None, false) tuple is returned on failure.

See Also: precompImport() for other arguments documentation.

importRenderPasses(passes, destinationPath, missingImageCb=None, compUpdateCb=None)

 

Creates or updates the composition associated with the given render passes. The given RenderPass instances are assumed to represent the same layer pass rendered from various cameras.

Parameters:
  • passes (RenderPass or list of them) - Render passes.
Returns: tuple of Graph and bool
On success, a tuple containing the composition version associated with the given render passes (opened at least in read-only) and a boolean indicating whether the composition has changed (was created or updated). The (None, false) tuple is returned on failure.

See Also: precompImport() for other arguments documentation.

getPrecompAnchorType(precompClass)

 
Parameters:
Returns: str
The anchor type (str) used for the specified PrecompObject class.
Raises:
  • RuntimeError - If an unknown precomp object type was specified.

getPrecompAnchor(node, precompClass)

 
Parameters:
Returns: tuple
The precomp anchor on the given node for the specified PrecompObject class. Returns None if the node does not have the specified precomp anchor type.

getPrecompAnchors(node, precompClasses)

 
Parameters:
  • node (Node)
  • precompClasses (PrecompObject derived class or list of them)
Returns: tuple
A tuple of precomp anchors on the given node for the specified list of precomp object classes. Returns None if the node doesn't have all the specified types of precomp anchor.

setPrecompAnchor(node, precompClass, anchor)

 

Sets the precomp anchor on the given node for the specified precomp class, overwriting the previous one if it existed.

Parameters:
  • node (Node)
  • precompClass (PrecompObject derived class)
  • anchor (tuple)

setPrecompAnchorFromObject(node, precompObject)

 

Sets the precomp anchor on the given node for the specified precomp object, overwriting the previous one if it existed.

Parameters:

removePrecompAnchors(node, precompClass)

 

Removes all precomp anchors for the specified precomp object type from the given node.

Parameters:

removeAllPrecompAnchors(node, exclude=[])

 

Removes all precomp anchors of any type (pass, layer, camera, etc) from the given node.

Parameters:
  • node (Node) - Node to remove anchors from.
  • exclude (list of PrecompObject classes) - List of precomp object classes to exclude from the removal.

hasPrecompAnchor(node)

 
Parameters:
  • node (Node)
Returns: bool
True if the given node has any precomp anchor set on it.

getLinkNodeOutputCameraAnchor(linkNodeOutput)

 
Parameters:
  • linkNodeOutput (Output)
Returns: tuple
The RenderCamera anchor of the given Link Image node output or None if there's none.

setLinkNodeOutputPrecompAnchors(linkNode)

 

This function sets the same anchors on the link node's output boundary nodes as the ones found on their respective linked output.

Parameters:
  • linkNode (LinkNode)

findPrecompLinkNodes(compOrVersion, precompClasses, onlyAtTopLevel=False)

 

Finds all precomp link nodes for the specified precomp object class in the given Graph or Composition. Such link nodes are expected to have one or many anchors set on them according to the precomp object classes passed in (one PrecompObject derived class or a list of them).

Parameters:
  • compOrVersion (Graph or Composition)
  • precompClasses (list of PrecompObject derived classes)
  • onlyAtTopLevel (bool) - If set to True only precomp link nodes at the top level of the given graph are returned (those are the only ones recognized in a precomp template). If set to False (the default), all precomp link nodes are returned.
Returns: dict
A dict where the key is either a single anchor or a tuple of anchors for the specified precomp classes and the value is a list of graph.LinkNode instances.

findAndRefreshPrecompLinkNodes(compOrVersion, precompClasses)

 

Forces a refresh of all precomp link nodes for the specified precomp object class in the given Graph or Composition. Such link nodes are expected to have one or many anchors set on them according to the precomp object classes passed in (one PrecompObject derived class or a list of them).

Parameters:
  • compOrVersion (Graph or Composition)
  • precompClasses (list of PrecompObject derived classes)

initPrecompLinkNode(linkNode, precompClassesAndAnchors, nodeName=None)

 

Takes a link node and makes it a precomp link node based on the given precomp anchors. The link node will also look at the working version of its linked composition (the latest comp that was imported). The linked composition path of the link node is emptied.

Parameters:
  • linkNode (LinkNode) - Link node to initialize.
  • precompClassesAndAnchors (list of (precompClass, anchor) tuples) - A list of tuples defining the anchors to set on the link node.
  • nodeName (str or None) - The name given to the link node. If set to None, it is automatically generated based on the given anchors.
Returns: LinkNode
The updated graph.LinkNode instance.

createPrecompLinkNode(compOrVersionOrGroup, precompClassesAndAnchors, nodeName=None)

 

Adds a link node to the given composition/version/group and sets its precomp information according to the initPrecompLinkNode() function.

Parameters:
  • compOrVersionOrGroup (Graph, Composition or GroupNode) - Composition, graph or group node to create the link node in.
Returns: LinkNode
The created graph.LinkNode instance.

See Also: initPrecompLinkNode() for other arguments documentation.

resetPrecompLinkNode(linkNode, precompClassesAndAnchors, nodeName=None, preserveOutputAnchors=True, preserveCameraAnchor=True)

 

Takes an existing precomp link node and resets it based on the given given precomp anchors.

Parameters:
  • linkNode (LinkNode) - Link node to reset.
  • preserveOutputAnchors (bool) - If this parameter is set to False, anchors on the link node outputs are removed.
  • preserveCameraAnchor (bool) - If this parameter is set to False, the camera anchor on the link node is removed.

See Also: initPrecompLinkNode() for other arguments documentation.

createPrecompLinkNodeFromObject(compOrVersionOrGroup, precompObject)

 

Adds a precomp link node to the given composition/version/group. Such link nodes have one or many anchors set on them which are typed based on the given precomp object. By default, the created link node looks at the working version of its linked composition (the latest comp that was imported).

Parameters:
  • compOrVersionOrGroup (Graph, Composition or GroupNode)
  • precompObject (PrecompObject instance)
Returns: LinkNode
The created graph.LinkNode instance.

isPrecompLinkNodeMultiView(linkNode)

 
Parameters:
  • linkNode (LinkNode) - Link node to test.
Returns: bool
True if the given precomp link node is multi-view, i.e. handles multiple camera views. A link node is multi-view when it has many connected outputs with RenderCamera anchors set on them (on the output boundary node).

analysePrecompGraph(comp, precompLinkClasses)

 

Splits the top level nodes of the given Graph or Composition, into three categories and returns a tuple.

Parameters:
  • comp (Graph or Composition) - Composition to analyse.
  • precompLinkClasses (list of PrecompObject derived classes) - A PrecompObject derived class or a list of them indicating the type of composition referenced by the precomp link nodes in the template.
Returns: tuple
A 4-tuple.

The first item is a dict containing precomp object link nodes where the key is either a single anchor or a tuple of anchors for the specified precomp classes and the value is a list of graph.LinkNode instances.

The second item is a list of the top level composition output nodes; the first item in the output nodes list is the primary output node.

The third item is a list of the remaining top level nodes.

Finally, the fourth item is a bool indicating whether the precomp graph is multi-view, i.e. handles multiple camera views; it has precomp link nodes with different camera anchors on them or at least one of its precomp link node is multi-view (see the isPrecompLinkNodeMultiView() documentation).

instantiatePrecompTemplate(templatePath, compPath, multiStream, backupVersion, precompObjects, precompLinkClasses, cameras=[])

 

Creates a new precomp composition based on the specified precomp template composition templatePath.

Parameters:
  • templatePath (str) - Path of the precomp template composition.
  • compPath (str) - Path of the new precomp composition.
  • multiStream (bool) - Indicates whether the resulting comp will be multi-stream versus multiple duplicated graphs.
  • backupVersion (bool) - If True, a backup of the current working version will be created.
  • precompObjects (PrecompObject instance or list of them) - A PrecompObject instance or a list of them for which the template is being instantiated.
  • precompLinkClasses (PrecompObject derived class or a list of them) - A PrecompObject derived class or a list of them indicating which type(s) of precomp objects are assembled by the template, i.e. which type(s) of anchor are to be expected on the precomp link nodes in the template.
  • cameras (list of RenderCamera) - If the resulting composition is meant to be multi-view, cameras is the list of RenderCamera instances for which the template is instantiated.
Returns: Composition
A graph.Composition opened in read-write or None if the template composition could not be loaded.

Also returns a dict containing precomp object link nodes, as returned analysePrecompGraph(); None can returned instead, even if the composition template was successfully instantiated.

createPrecompOutputNodes(compVersion, cameras)

 

For each of the given RenderCamera instances, this function creates an output node in the given composition with the camera anchor set on it. The primary output node of the composition is used first.

Parameters:
  • compVersion (Graph) - Composition version.
  • cameras (list of RenderCamera)

processPrecompLinkNodes(compVersion, precompLinkClasses, anchorsToPrecompObjects, anchorsToLinkedCompVersion, anchorsToLinkNodes, rebuildLinkNodes=False)

 

Adds missing precomp link nodes and rebuilds the existing ones in the given composition version compVersion.

It actually rebuilds the link nodes only if rebuildLinkNodes is True.

The anchorsToPrecompObjects, anchorsToLinkedCompVersion and anchorsToLinkNodes parameters are all dictionaries indexed by either a single precomp anchor or a tuple of them.

Parameters:
  • compVersion (Graph) - Composition version.
  • precompLinkClasses (PrecompObject derived class or list of them) - A PrecompObject derived class or a list of them indicating the type of the precomp anchor(s).
  • anchorsToPrecompObjects (dict) - Contains the PrecompObject derived instances that are being assembled in the composition (they are assumed to be all of the same type).
  • anchorsToLinkedCompVersion (dict) - Contains the precomp composition versions to link to.
  • anchorsToLinkNodes (dict) - Contains the existing precomp link nodes in the comp.
  • rebuildLinkNodes (bool) - Whether or not to rebuild the link nodes.
Returns: tuple
The union of the linked precomp composition time ranges as a (minStart, maxEnd) tuple.

stackRenderLayers(cameraCompVersion, layerAnchorToLinkNodes, layerAnchorToLayers, cameraAnchorToCamera, multiStream=True, stackGroupNodeName=None)

 

Stacks the render layers in a chain of Blend&Comp nodes according to the render layers compositing order and blend mode.

Parameters:
  • cameraCompVersion (graph.Graph)
  • layerAnchorToLinkNodes
  • layerAnchorToLayers
  • cameraAnchorToCamera
  • multiStream (bool) - Indicates whether the resulting comp will be multi-stream versus multiple duplicated graphs.
  • stackGroupNodeName (str @return The list of nodes was were created to build the layers stack. @rtype list of graph.Node)

cleanupPrecompTemplate(comp, precompLinkClasses)

 

Cleans up the given template composition 'comp' to prepare it for instantiation.

Parameters:
  • comp (Graph or Composition) - Composition template to clean up.
  • precompLinkClasses (list of PrecompObject derived classes) - A PrecompObject derived class or a list of them indicating the type of composition referenced by the precomp link nodes in the template.
Returns: tuple
The same values as analysePrecompGraph().

cleanupPrecompLinkNodes(anchorsToLinkNodes, precompLinkClasses, preserveCameraAnchors=True)

 

Cleans up the the given precomp link nodes to prepare the ground for their update.

Parameters:
  • anchorsToLinkNodes (dict) - A dictionary where the key is either a single anchor or a tuple of anchors for the specified precomp classes and the value is a list of graph.LinkNode instances.
  • precompLinkClasses (list) - A PrecompObject derived class or a list of them indicating the type of composition referenced by the link nodes.
  • preserveCameraAnchors (bool) - If this parameter is set to False, camera anchors on the link node and its outputs are removed.

removePrecompLinkNodeDuplicates(anchorsToLinkNodes)

 

Remove any precomp link node duplicates, i.e. link nodes which are in fact the same entry point (same anchor(s)) in the graph connected to different places. The given map gets updated in-place.

Parameters:
  • anchorsToLinkNodes

getLayerStackInfo(compPath)

 

Gets the information about the stack of render layers from the precomp settings of the camera composition.

Returns: dict
A dict (possibly empty) of layer anchor indexing a RenderLayerInfo instance.

setLayerStackInfo(compPath, layerSets)

 

Sets the information about the stack of render layers in the camera composition precomp setting.

Parameters:
  • compPath (str) - Composition path.
  • layerSets - A sequence or iterator of lists of RenderLayer instances assumed to originate from the same camera set.

updateLayerStackInfo(compPath, layerSets)

 

Updates the information about the stack of render layers in the camera composition precomp setting.

Parameters:

See Also: setLayerStackInfo().

hasLayerStackInfo(compPath)

 
Parameters:
  • compPath (str) - Composition path.
Returns: bool
True if the composition has precomp settings that store information about a stack of render layers.

getPassLinksInfo(compPath)

 

Gets the information about links to render passes in the composition precomp settings.

Parameters:
  • compPath (str) - Composition path.
Returns: dict
A dict (possibly empty) of (pass, layer) anchors tuple indexing a RenderPassLinkInfo instance.

setPassLinksInfo(compPath, passSets)

 

Sets the information about the imported passes in the composition precomp settings.

Parameters:
  • compPath (str) - Composition path.
  • passSets - A sequence or iterator of lists of RenderPass instances from the same layer and camera set.

updatePassLinksInfo(compPath, passSets)

 

Updates the information about the imported passes in the composition precomp settings.

Parameters:
  • compPath (str) - Composition path.
  • passSets - A sequence or iterator of lists of RenderPass instances from the same layer and camera set.

See Also: setPassLinksInfo().

hasPassLinksInfo(compPath)

 
Parameters:
  • compPath (str) - Composition path.
Returns: bool
True if the composition has precomp settings that store information about links to render passes.

getPassInfo(compPath)

 

Gets the information about the passes in the render pass composition precomp setting.

Parameters:
  • compPath (str) - Composition path.
Returns: dict
A dict (possibly empty) of camera anchor indexing a RenderPassInfo instance.

setPassInfo(compPath, passes)

 

Sets the information about the imported passes in the render pass composition precomp setting.

Parameters:
  • compPath (str) - Composition path.
  • passes - A sequence or iterator of RenderPass instances assumed to come from the same layer and camera set.

writePrecompInfo(compPath, settingKey, infos)

 

Writes the given (*)Info instances to the composition precomp setting.

Parameters:
  • compPath (str) - Composition path.
  • settingKey (str) - The composition precomp setting key.
  • infos - Can be a sequence or an iterator.

getCameraAnchorsFromXmlElement(xmlElement)

 
Parameters:
  • xmlElement (etree.Element)
Returns: set
A set of camera anchors fetched from the given xml etree.Element.

addCameraAnchorsToXmlElement(anchors, xmlElement)

 

Adds a set of camera anchors to the given xml etree.Element.

Parameters:
  • anchors - A set of camera anchors.
  • xmlElement (etree.Element)

getPrecompCompositionAttributes(precompObjects)

 
Parameters:
Returns: tuple
The following information about the composition that would represent the given objects:
  1. Composition name.
  2. Composition description.
  3. Dictionary of composition UDAs.

It is assumed that the given precomp objects are of the same type and, if applicable, represent the same 3D object rendered from different cameras.

setRate(compOrVersion, scene)

 

Sets the rate of the given composition/version based on the rate of the 3D scene. It sets the rate on all composition outputs.

Parameters:
  • compOrVersion (Composition or Graph)
  • scene (Scene)

setStartEnd(compOrVersion, start, end, outputName=None)

 

Sets the start/end of the given composition/version output.

Parameters:
  • compOrVersion (Composition or Graph)
  • start (int)
  • end (int)
  • outputName (str) - The output name. If this parameter is set to None, all outputs are changed.

setFormat(compOrVersion, precompObject, outputName=None)

 

Sets the image format and pixel format of the given composition/version based on the format of the given PrecompObject derived instance (Scene, RenderLayer or RenderPass).

Parameters:
  • compOrVersion (Composition or Graph)
  • precompObject (PrecompObject derived instance)
  • outputName (str) - This parameter determines the name of the output node for which the format is changed; if set to None the primary output node is used.

getPrecompTemplatePath(path, precompObject, missingTemplateCb=None, useDefaultTemplate=True)

 

Checks whether the given template file path exists. Asks the user to locate it if possible. Otherwise, returns the default template if there's one and we're allowed to.

Parameters:
  • path (str) - Precomp template file path.
  • precompObject (PrecompObject derived instance) - The PrecompObject derived instance from which the template path was taken.
  • missingTemplateCb (callable) - Callback that is called if the given template file path does not exist.
  • useDefaultTemplate (bool) - Indicates whether the default template should be used when the specified template cannot be found. Defaults to True.
Returns: str
The validated template file path or None otherwise.

getDefaultPrecompTemplatePath(precompObject)

 
Parameters:
Returns: str
The default precomp template existing file path for the given PrecompObject derived instance or None if none were found.

validateDestinationFolder(path)

 

Validate destination folder and create it if need be.

Parameters:
  • path (str) - Destination folder path.
Raises:
  • RuntimeError - If the path exists and is not a folder.

getPrecompCompositionPath(destinationPath, compName, compUpdateCb, precompClass)

 

Determines the precomp composition path, handling the update mode if needed or throwing a RuntimeError if the conflict cannot be resolved.

Parameters:
  • destinationPath (str)
  • compName (str)
  • compUpdateCb (callable)
  • precompClass (PrecompObject derived class)
Returns: tuple
A tuple with:
  • Composition path.
  • bool indicating whether comp is new (doesn't exist).
  • bool indicating whether to skip the composition.
  • bool indicating whether to update the working version.
  • bool indicating whether to recreate the working version.
  • bool indicating whether to backup the version to modify.
Raises:
  • RuntimeError - If the composition path conflict cannot be resolved.

wrapCompUpdateCb(compUpdateCb)

 

Wraps the compUpdateCb parameter to provide the default behavior when the parameter is not callable.

Parameters:
  • compUpdateCb
Returns: callable
The wrapped compUpdateCb.

sanitizeName(name)

 

Replaces invalid characters from the given name with Composite's default replacement character ('_').

Parameters:
  • name (str)
Returns: str
The sanitized name.

getPrecompClassPrettyName(precompClass)

 

Returns a pretty name for the given PrecompObject derived class.

Parameters:

getCompositionTypeName(precompClass)

 
Parameters:
Returns: str
The name for the type of composition that the given PrecompObject derived class instantiates.

setTraceCallback(traceCb)

 

Sets a callback invoked by the functions in this module to provide information about what it's doing. It must take one string parameter in argument. Default trace callback doesn't do anything.

Parameters:
  • traceCb (callable)

setWarningCallback(warningCb)

 

Sets a callback invoked by the functions in this module to show a warning. It must take one string parameter in argument. Default warning callback doesn't do anything.

Parameters:
  • warningCb (callable)

loadStreamTools()

 

Tries to load the multi-stream plugin tools.

Returns: bool
True on success.

getProjectRelativePath(path)

 
Parameters:
  • path (str)
Returns: str
A path (str) relative to the current project root folder or the path itself if it's not under the project root.

getRenderCameraAnchor(obj)

 

Functor to get the render camera anchor of a Composite node or of a precomp object.

Parameters:
Returns: tuple
The render camera anchor.

getSchematicPosition(node)

 
Parameters:
  • node (Node)
Returns: tuple
The position of a node in the schematic as an (x, y) float tuple.

setSchematicPosition(node, x, y)

 

Sets the (x, y) position of a node in the schematic.

Parameters:
  • node (Node)
  • x (float)
  • y (float)