myFirstPythonScript…copyAttributes

I’ve won’t hail myself as the ultimate scripting wizard…I think I’m pretty average to be fair, but its always nice to make certain tasks a bit quicker.   Here’s a basic python script you can use to copy attributes between 2 selected objects.

 

”’import maya.cmds as mc”’

 

#COPY ATTRIBUTES

 

#get attributesfromfirst selected

cntrls = mc.ls (sl=1, tr=1)

print cntrls

cnt = len(cntrls)

print cnt

 

#check if two items are selected

if cnt != 2 :

mc.warning (“SELECT TWO OBJECT ONLY”)

 

if cnt == 2:

#get attributes from master item

attrList = mc.listAttr (cntrls[0], v=1, k=1)

print attrList

#add attributes to next selected item

for attr in attrList :

mc.addAttr (cntrls[1], k=True, at=”float”, ln=attr)

 

 

 

Leave a Reply