pymel.core.general.copyAttr

copyAttr(*args, **kwargs)

Given two nodes, transfer the connections and/or the values from the first node to the second for all attributes whose names and data types match. When values are transferred, they are transferred directly. They are not mapped or modified in any way. The transferAttributes command can be used to transfer and remap some mesh attributes. The attributes flag can be used to specify a list of attributes to be processed. If the attributes flag is unused, all attributes will be processed. For dynamic attributes, the values and/or connections will only be transferred if the attributes names on both nodes match. This command does not support geometry shape nodes such as meshes, subds and nurbs. This command does not support transfer of multi-attribute values such as weight arrays. In query mode, return type is based on queried flag.

Flags:

Long Name / Short Name Argument Types Properties
attribute / at unicode ../../../_images/create.gif
  The name of the attribute(s) for which connections and/or values will be transferred. If no attributes are specified, then all attributes will be transferred.
containerParentChild / cpc bool ../../../_images/create.gif
  For use when copying from one container to another only. This option indicates that the published parent and/or child relationships on the original container should be transferred to the target container if the published names match.
inConnections / ic bool ../../../_images/create.gif
  Indicates that incoming connections should be transferred.
keepSourceConnections / ksc bool ../../../_images/create.gif
  For use with the outConnections flag only. Indicates that the connections should be maintained on the first node, in addition to making them to the second node. If outConnections is used and keepSourceConnections is not used, the out connections on the source node will be broken and made to the target node.
outConnections / oc bool ../../../_images/create.gif
  Indicates that outgoing connections should be transferred.
renameTargetContainer / rtc bool ../../../_images/create.gif
  For use when copying from one container to another only. This option will rename the target container to the name of the original container, and rename the original container to its old name + Orig. You would want to use this option if your original container was referenced and edited, and you want those edits from the main scene to now apply to the new container.
values / v bool ../../../_images/create.gif
  Indicates that values should be transferred. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.copyAttr

Example:

import pymel.core as pm

# transfer input connections and values from locator1 to locator2
#
pm.copyAttr('locator1','locator2',inConnections=True,values=True)
# transfer only the translateX and translateY values
#
pm.copyAttr('locator1','locator2',values=True,attribute=['tx','translateY'])