Go to: Synopsis. Return value. Related.
Flags. Python
examples.
connectAttr( attribute attribute , [force=boolean], [lock=boolean], [nextAvailable=boolean], [referenceDest=string])
Note: Strings representing object names and
arguments must be separated by commas. This is not depicted in the
synopsis.
connectAttr is undoable, NOT queryable, and NOT
editable.
Connect the attributes of two dependency nodes and return the names
of the two connected attributes. The connected attributes must be
be of compatible types. First argument is the source attribute,
second one is the destination. Refer to dependency node
documentation.
string |
A phrase containing the names of the connected attributes. |
connectionInfo, isConnected, listConnections
force, lock,
nextAvailable, referenceDest
Long name (short name) |
Argument types |
Properties |
lock(l) |
boolean |
|
|
If the argument is true, the destination attribute is locked
after making the connection. If the argument is false, the
connection is unlocked before making the connection. |
|
force(f) |
boolean |
|
|
Forces the connection. If the destination is already connected,
the old connection is broken and the new one made. |
|
nextAvailable(na) |
boolean |
|
|
If the destination multi-attribute has set the indexMatters to
be false with this flag specified, a connection is made to the next
available index. No index need be specified. |
|
referenceDest(rd) |
string |
|
|
This flag is used for file io only. The flag indicates that the
connection replaces a connection made in a referenced file, and the
flag argument indicates the original destination from the
referenced file. This flag is used so that if the reference file is
modified, maya can still attempt to make the appropriate
connections in the main scene to the referenced object. |
|
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
cmds.createNode( 'transform', n='firstGuy' )
cmds.createNode( 'transform', n='secondGuy' )
# Connect the translation of two nodes together
cmds.connectAttr( 'firstGuy.t', 'secondGuy.translate' )
# Connect the rotation of one node to the override colour
# of a second node.
cmds.connectAttr( 'firstGuy.rotate', 'secondGuy.overrideColor' )