Go to: Synopsis. Return value. Keywords.
Related. Flags.
MEL examples.
nodeCast [-copyDynamicAttrs boolean]
[-disableAPICallbacks
boolean] [-disableScriptJobCallbacks
boolean] [-disconnectUnmatchedAttrs
boolean] [-force boolean]
[-swapNames boolean] [-swapValues boolean]
stringstring
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 |
-disableScriptJobCallbacks(
-dsj) |
boolean |
 |
|
-disableAPICallbacks(-dsa) |
boolean |
 |
|
-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. |
|
-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. |
|
-swapNames(-sn) |
boolean |
 |
|
Swap the names of the nodes. By default names are not
swapped. |
|
-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. |
|
-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. |
|
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 be used more than once in a
command. |
// Create two transform nodes and make a connection between them.
//
string $tr1 = `createNode transform`;
string $tr2 = `createNode transform`;
connectAttr -f ($tr1 + ".t") ($tr2 + ".t");
connectAttr -f ($tr2 + ".r") ($tr1 + ".r");
// We want to swap $tr1 out. Create a new node $swapNode that will
// replace $tr1. To prove that this is working, we will add a new
// dynamic attribute to $tr1 and connect it to the middle man.
// If nodeCast cannot find the corresponding attribute on the
// node to be swaped, it will either ignore the connection or
// disconnect the connection based on user input.
//
string $theT = $tr1;
select -r $theT;
addAttr -ln "unmatched" -at "long";
string $middle_man = `createNode transform`;
connectAttr ($theT + ".unmatched") ($middle_man + ".tx");
$swapNode = `createNode transform`;
nodeCast -disconnectUnmatchedAttrs true $theT $swapNode;