can only concatenate list (not "str") to list -- PROBLEM

can only concatenate list (not "str") to list -- PROBLEM

danielblaze
Contributor Contributor
4,176 Views
1 Reply
Message 1 of 2

can only concatenate list (not "str") to list -- PROBLEM

danielblaze
Contributor
Contributor

Hi, i'm trying to mirror the channel box attributes of my left joint chain from left to right.

However i'm getting an error with list concatenation!!

Image and code attached below

 

Can someone help me please?

Thanks

Daniel

______________________________

import maya.cmds as cmds

sel = cmd.ls(sl=True, dag=True)

leftSel = sel[:len(sel)/2]
rightSel = sel[len(sel)/2:]

cbAttr = cmd.listAttr(leftSel, k=1)

for i in cbAttr:

L_objVal = cmds.getAttr(leftSel + '.' + i)

if i == 'translateX':
cmds.setAttr(rightSel + '.' + i, L_objVal*-1)

if i == 'translateY':
cmds.setAttr(rightSel + '.' + i, L_objVal)

if i == 'translateZ':
cmds.setAttr(rightSel + '.' + i, L_objVal)

if i == 'rotateX':
cmds.setAttr(rightSel + '.' + i, L_objVal)

if i == 'rotateY':
cmds.setAttr(rightSel + '.' + i, L_objVal)

if i == 'rotateZ':
cmds.setAttr(rightSel + '.' + i, L_objVal)

if i == 'scaleX':
cmds.setAttr(rightSel + '.' + i, L_objVal)

if i == 'scaleY':
cmds.setAttr(rightSel + '.' + i, L_objVal)

if i == 'scaleZ':
cmds.setAttr(rightSel + '.' + i, L_objVal)

0 Likes
Accepted solutions (1)
4,177 Views
1 Reply
Reply (1)
Message 2 of 2

lanh.hong
Alumni
Alumni
Accepted solution

Hi danielblaze,

 

The reason you're getting that error is because leftSel and rightSel are lists while '.' and i  are strings. So concatenating a list with strings does not work in Python. You'd have to loop through the elements in leftSel/rightSel lists if you want to concat with the strings. 

 

Regards,

Lanh


Lanh Hong
Developer Technical Services
Autodesk Developer Network



0 Likes