Go to: Synopsis. Return value. Keywords. Related. Flags. Python examples.
nodeCast(stringstring, [copyDynamicAttrs=boolean], [disableAPICallbacks=boolean], [disableScriptJobCallbacks=boolean], [disconnectUnmatchedAttrs=boolean], [force=boolean], [swapNames=boolean], [swapValues=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
nodeCast is undoable, NOT queryable, and NOT editable.
Given two nodes, a source node of type A and a target node of type B,
where type A is either type B or a sub-type of B, this command will replace the
target node with the source node. That is, all node connections, DAG hierarchy
and attribute values on the target node will be removed from the target node
and placed on the source node. This operation will fail if either object is
referenced, locked or if the nodes do not share a common sub-type.
This operation is atomic. If the given parameters fail, then the source and
target nodes will remain in their initial state prior to execution of the
command.
IMPORTANT: the command will currently ignore instance connections and
instance objects. It will also ignore reference nodes.
int | 0 for success, 1 for failure. |
node, swap, cast
createNode, nodeType
copyDynamicAttrs, disableAPICallbacks, disableScriptJobCallbacks, disconnectUnmatchedAttrs, force, swapNames, swapValues
Long name (short name) |
Argument types |
Properties |
copyDynamicAttrs(cda)
|
boolean
|
|
|
If the target node contains any dynamic attributes that are not defined on the
source node, then create identical dynamic attricutes on the source node and copy
the values and connections from the target node into them.
|
|
disableAPICallbacks(dsa)
|
boolean
|
|
|
disableScriptJobCallbacks(dsj)
|
boolean
|
|
|
disconnectUnmatchedAttrs(dua)
|
boolean
|
|
|
If the node that is being swapped out has any connections that do not exist
on the target node, then indicate if the connection should be disconnected.
By default these connections are not removed because they cannot be restored
if the target node is swapped back with the source node.
|
|
force(f)
|
boolean
|
|
|
Forces the command to do the node cast operation even if the nodes do
not share a common base object. When this flag is specified the command
will try to do the best possible attribute matching when swapping the
command. It is not recommended to use the '-swapValues/sv' flag with
this flag.
|
|
swapNames(sn)
|
boolean
|
|
|
Swap the names of the nodes. By default names are not swapped.
|
|
swapValues(sv)
|
boolean
|
|
|
Indicates if the commands should exchange attributes on the common attributes
between the two nodes. For example, if the nodes are the same base type
as a transform node, then rotate, scale, translate values would be copied
over.
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
tr1 = cmds.createNode( 'transform' )
tr2 = cmds.createNode( 'transform' )
cmds.connectAttr( tr1 + ".t", tr2 + ".t" )
cmds.connectAttr( tr2 + ".r", tr1 + ".r" )
theT = tr1
cmds.select( theT, replace=1 )
cmds.addAttr( ln="unmatched", at="long" )
middle_man = cmds.createNode( 'transform' )
cmds.connectAttr( theT + ".unmatched", middle_man + ".tx" )
swapNode = cmds.createNode( 'transform' )
cmds.nodeCast( theT, swapNode, disconnectUnmatchedAttrs=true )