Tomethy Tomethy - 2 months ago 11
Python Question

setAttr of a list in maya python

I'm still figuring out how Python and Maya work together so forgive ignorance on my part. So I'm trying to change the attributes of a list of joints in maya using a loop like so:

for p in jointList:
cmd.getAttr(p, 'radius', .5)

and I get this error:

Invalid argument 1, '[u'joint1']'. Expected arguments of type ( list, )

I have no idea what I'm doing wrong.


Unless you work with pyMel you need to specify attr name and node to get or set.

for getAttr :

for p in jointList:
    val = cmd.getAttr('%s.radius' % (p))

for setAttr :

for p in jointList:
    cmd.setAttr('%s.radius' % (p), .5)