I am currently working on an automated rig script and I faced an issue I cannot understand. Here is the simplified part of the code I'm looking a solution for :
import pymel.core as pm
ik_box = pm.curve(n='ik_arm_box_curve', d=1, p=[(1, 1, 1),(1, 1, -1),(-1, 1, -1),(-1, 1, 1),(1, 1, 1),(1, -1, 1),(1, -1, -1),(1, 1, -1),(-1, 1, -1),(-1, -1, -1),(1, -1, -1),(-1, -1, -1),(-1, -1, 1),(-1, 1, 1),(-1, -1, 1),(1, -1, 1)], k=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])
pm.setAttr(ik_box + 'Shape.v', 0)
ik_circle = pm.circle(n='ik_arm_circle_curve', c=(0,0,0), nr=(1,0,0), r=2)
pm.setAttr(ik_circle + 'Shape.v', 0)
The thing I cannot understand here is that the setAttr works properly with my ik_box but with the circle it gaves me this error :
TypeError: can only concatenate list (not "str") to list
? So why is it working with my ik_box and then it considers my ik_circle as a list ?
Knowing that I'm making my own script based on this very useful tutorial :
https://youtu.be/zA9lz8-1uQ4?t=526
(You can pause immediatly and see in the bottom of the code that he creates the shapes and then edit their visibility the way I did, and everything works fine for him)
? So then I tried to print these ik_circle elements to see what it means:
ik_circle = pm.circle(n='ik_arm_circle_curve', c=(0,0,0), nr=(1,0,0), r=2)
print(ik_circle[0])
print(ik_circle[1])
And it gaves me ik_arm_circle_curve and makeNurbCircle2.
? From there, I found out the "constructionHistory(ch)" flag and applied it:
ik_circle = pm.circle(n='ik_arm_circle_curve', c=(0,0,0), nr=(1,0,0), r=2, ch=0)
print(ik_circle[1])
? Fine, it's out of range, there's no more list.
ik_circle = pm.circle(n='ik_arm_circle_curve', c=(0,0,0), nr=(1,0,0), r=2, ch=0)
pm.setAttr(ik_circle + 'Shape.v', 0)
TypeError: can only concatenate list (not "str") to list
? Here we go again.. A list with only one element inside of it.
I am fairly new to python, I probably miss some fundamentals, but if you have any advice or explanation I would appreciate.
question from:
https://stackoverflow.com/questions/65845605/setattr-visibility-of-several-shapes-leads-to-an-error-only-for-circle-shapes