Node Utilities¶
Module providing utility functions for the PackageSuperToolAPI related to node creation and manipulation.
-
PackageSuperToolAPI.NodeUtils.AddNodeRef(destNodeOrGroupParam, key, node)¶ Adds a reference to a node or a group parameter on a given node using a given string key. This is used in package nodes to store a reference to another node or parameter relevant to that package. Internally, this is done by adding a special user parameter in
destNodeOrGroupParamcontaining an expression pointing tonode.Parameters: - destNodeOrGroupParam (
NodegraphAPI.NodeorNodegraphAPI.GroupParameter) – A node or group parameter where the reference will be stored. - key (
str) – The key to be used as the name of the reference. - node (
NodegraphAPI.Node) – The node to be referenced.
Raises: TypeError – If the first argument supplied is neither a node nor a parameter.
- destNodeOrGroupParam (
-
PackageSuperToolAPI.NodeUtils.AddPackageTypeAndPath(node, packageType, locationPath)¶ Adds the package type and path parameters to the given node.
Parameters: - node (
NodegraphAPI.Node) – The node to which to add the parameters. - packageType (
str) – The type of the given node’s package, to store in the parameters created. - locationPath (
str) – The location path of the given node’s package, to store in the parameters created.
- node (
-
PackageSuperToolAPI.NodeUtils.AppendNode(nodeA, nodeB)¶ Given two nodes A and B, connects B below A in the node graph. The port connected to A’s output will be connected to the output of B, and the input port of B will be connect to the output port of A.
Parameters: - nodeA (
Node) – The node under whichnodeBshould be appended. - nodeB (
Node) – The node to be appended tonodeA.
Note: Only handles single input and output ports - only the first (0-index) ports will be reconnected. If
nodeA‘s output port has multiple sinks, only the first will be reconnected.- nodeA (
-
PackageSuperToolAPI.NodeUtils.AppendNodes(parentGroupNode, nodes)¶ Connects the given nodes in a chain, connecting the head of the chain to the last node in the given parent Group node.
Parameters: - parentGroupNode (
Node) – The parent node. - nodes (
tupleofNode) – The nodes to append.
- parentGroupNode (
-
PackageSuperToolAPI.NodeUtils.DeleteDeepParameter(parentGroupParam, paramPath)¶ Deletes the parameter at the given parameter path and any of its parent group parameters if they are empty afterwards.
Parameters: - parentGroupParam (
NodegraphAPI.GroupParameter) – The parent group parameter in which to delete the parameter with the given path. - paramPath (
str) – The path to the parameter to delete. This can be a nested parameter path containing ”.” separators.
- parentGroupParam (
-
PackageSuperToolAPI.NodeUtils.GetDownstreamNodes(node)¶ Given a node that belongs to a package, returns the set of all downstream nodes that belong to the same package.
Return type: setofNodeParameters: node ( Node) – The node from which to find downstream nodes.Returns: The set of all nodes downstream from node.
-
PackageSuperToolAPI.NodeUtils.GetEditPackageForLocationPath(mainNode, locationPath)¶ Return type: PackageorNoneParameters: - mainNode (
Node) – The SuperToolNodeinstance for which to return an edit package for the given location path. - locationPath (
str) – The location path for which to return the EditPackage.
Returns: An EditPackage instance for the given location path, or
Noneif no such EditPackage node is found.- mainNode (
-
PackageSuperToolAPI.NodeUtils.GetEditPackageLocationPaths(mainNode)¶ Return type: listofstrParameters: mainNode ( Node) – The SuperToolNodeinstance for which to return a list of the names of the edit packages.Returns: A list of the names of EditPackage instances for the SuperTool of the given Nodeinstance.
-
PackageSuperToolAPI.NodeUtils.GetEditPackages(mainNode)¶ Return type: listofPackageParameters: mainNode ( Node) – The SuperToolNodeinstance for which to return a list of the edit packages.Returns: A list of the EditPackage instances for the SuperTool of the given Nodeinstance.
-
PackageSuperToolAPI.NodeUtils.GetPackageLocationParameterPath()¶ Return type: strReturns: The path to the parameter which contains the package location.
-
PackageSuperToolAPI.NodeUtils.GetPackageTypeParameterPath()¶ Return type: strReturns: The path to the parameter which contains the package type.
-
PackageSuperToolAPI.NodeUtils.GetRefNode(nodeOrGroupParam, key)¶ Given a key and a node or group parameter that might contain references to nodes (via the special parameters added by
AddNodeRef) returns a node pointed by the reference.Return type: NodegraphAPI.NodeorNoneParameters: - nodeOrGroupParam (
NodegraphAPI.NodeorNodegraphAPI.GroupParameter) – A node or group parameter where the reference might be stored. - key (
str) – The key to be used as the name of the reference.
Returns: The referenced node or
Noneif no reference with the given key is found in the given node or group parameter.- nodeOrGroupParam (
-
PackageSuperToolAPI.NodeUtils.GetSceneGraphPathExpression(package, path, raiseOnMissing=True)¶ A utility for generating the
getParam()expression which will evaluate to the scene graph path for the package at the given path, for the SuperTool to which the given package belongs.Return type: strParameters: - package (
Package) – A package belonging to the SuperTool for which the scene graph path expression should be returned. - path (
str) – The path corresponding to the package for which a scene graph path expression should be returned.
Returns: The expression which will evaluate to the scene graph path for the package corresponding to the given path, in the SuperTool to which the give package belongs.
- package (
-
PackageSuperToolAPI.NodeUtils.GetSuperToolGroupName()¶ Return type: strReturns: The name of the group parameter which contains information about the SuperTool.
-
PackageSuperToolAPI.NodeUtils.IsNodeGuardedFromDeletion(node)¶ Return type: boolParameters: node ( NodegraphAPI.Node) – The node to check.Returns: Trueif the given node is guarded from deletion, otherwiseFalse.
-
PackageSuperToolAPI.NodeUtils.NodeDeletionGuard(*args, **kwds)¶ Marks the node as protected against deletion, which can be tested by calling
IsNodeGuardedFromDeletionand passing a node to check.Parameters: node ( NodegraphAPI.Node) – The node to guard from deletion.
-
PackageSuperToolAPI.NodeUtils.PositionMergeInputs(mergeNode)¶ Evenly positions the nodes connected to the inputs of the given merge node.
Parameters: mergeNode ( NodegraphAPI.Node) – The node whose inputs should be evenly positioned.
-
PackageSuperToolAPI.NodeUtils.PrependNode(nodeA, nodeB)¶ Given two nodes A and B, connects B above A in the node graph. The port connected to A’s input will be connected to the input of B, and the output port of B will be connect to the input port of A.
Parameters: - nodeA (
Node) – The node to which to prependnodeB. - nodeB (
Node) – The node to be prepended tonodeA.
Note: Only handles single input and output ports - only the first (0-index) ports will be reconnected.
- nodeA (
-
PackageSuperToolAPI.NodeUtils.RemoveNodeRef(nodeOrGroupParam, key)¶ Removes the reference to a node (added by
AddNodeRef) with the given key from the given node or group parameter.Parameters: - nodeOrGroupParam (
NodegraphAPI.NodeorNodegraphAPI.GroupParameter) – A node or group parameter where the reference may have been be stored. - key (
str) – The key to be used as the name of the reference.
- nodeOrGroupParam (
-
PackageSuperToolAPI.NodeUtils.SetOrCreateDeepArrayParameter(parentGroupParam, paramPath, paramValue)¶ Sets the value of an array parameter, creating it and any of its parent group parameters as required if they don’t exist.
Return type: NodegraphAPI.GroupParameterParameters: - parentGroupParam (
NodegraphAPI.GroupParameter) – The parent group parameter in which to set (and create if necessary) the parameter with the given path. - paramPath (
str) – The path to the parameter whose value should be set. This can be a nested parameter path containing ”.” separators. - paramValue (
strorintorfloat) – The value to which the given parameter should be set.
Returns: The parameter (newly-created if it didn’t already exist), set to the given value.
- parentGroupParam (
-
PackageSuperToolAPI.NodeUtils.SetOrCreateDeepScalarParameter(parentGroupParam, paramPath, paramValue, hintString=None)¶ Sets the value of a scalar parameter, creating it and any of its parent group parameters as required if they don’t exist.
Return type: NodegraphAPI.GroupParameterParameters: - parentGroupParam (
NodegraphAPI.GroupParameter) – The parent parameter in which to set (and create if necessary) the parameter with the given path. - paramPath (
str) – The path to the parameter whose value should be set. This can be a nested parameter path containing ”.” separators. - paramValue (
strorintorfloat) – The value to which the given parameter should be set. - hintString (
strorNone) – An optional hint string for the parameter.
Returns: The parameter (newly-created if it didn’t already exist), set to the given value.
- parentGroupParam (
-
PackageSuperToolAPI.NodeUtils.SetOrCreateDeepVectorParameter(parentGroupParam, paramPath, paramValue)¶ Deprecated: This function will be removed. Please use SetOrCreateDeepArrayParameter() instead.
-
PackageSuperToolAPI.NodeUtils.SetPackageNodeName(package)¶ Sets the name of the given package’s main node and post-merge stack node (if found).
Parameters: package ( Package) – The package for which to set the node names.
-
PackageSuperToolAPI.NodeUtils.UpdateChildPackagePaths(inputPackage)¶ Recursively walks the child packages of the given input package, updating the package location parameters with their location.
Parameters: inputPackage ( Package) – The package whose children’s package location parameters should be updated.
-
PackageSuperToolAPI.NodeUtils.WireInlineNodes(parentGroupNode, nodes, x=0, y=0)¶ Connects a list of nodes (using the first input and output ports) that exist inside a given parent group node.
Parameters: - parentGroupNode (
NodegraphAPI.GroupNode) – The parent group node which encloses the nodes in the given list of nodes. - nodes (
listofNodegraphAPI.Node) – The list of nodes inside the given parent group node which should be connected together. - x (
int) – The horizontal offset which should be applied to the given nodes’ positions within the enclosing node. - y (
int) – The vertical offset which should be applied to the given nodes’ positions within the enclosing node.
- parentGroupNode (