Maya is adding a pipe '|' to the start of each object's name, to 
distinguish it from the previously grouped object with the same name. If 
you don't include that pipe, anything you do using that name later won't 
work.

So any time you do something like 
nucleo,nucleoHistory = mc.polyCylinder(name=nucleoName, ch=1)
you should use the returned value (nucleo, in this case) instead of 
nucleoName for future operations with that object. eg:
mc.setAttr(nucleo + '.translateX', 5)

You're already doing that for grp, but you need to do it for nucleo and the 
strands too.


On Saturday, 18 February 2017 21:18:20 UTC+11, David Clabaugh wrote:
>
> Hi, 
> Trying to make a script I created be able to run multiple times. If I run 
> it once it works, but the second time I get:
>
> # Error: setAttr: Not enough data was provided. The last 0 items will be 
> skipped.
> # Traceback (most recent call last):
> #   File "<maya console>", line 8, in <module>
>
>
>
> Here is my script
>
> import maya.cmds as mc
>
> #Create and place Spiral DNA elements
> for x in range (0,20):
>     strandLName = "strandL" +str(x)
>     nucleoName = "nucleo" +str(x)
>     strandRName = "strandR" +str(x)
>     strandL,strandHistory = mc.polySphere(name=strandLName, ch=1)
>     nucleo,nucleoHistory = mc.polyCylinder(name=nucleoName, ch=1)
>     mc.setAttr(nucleoName + '.translateX', 5)
>     mc.setAttr(nucleoName + '.rotateZ', -90)
>     mc.setAttr(nucleoName + '.scaleX', 0.5)
>     mc.setAttr(nucleoName + '.scaleY', 5)
>     mc.setAttr(nucleoName + '.scaleZ', 0.5)
>     strandR,strandHistory = mc.polySphere(name=strandRName, ch=1)
>     mc.setAttr(strandRName + '.translateX', 10)
>     mc.select(deselect=1)
>     
>     #create empty group
>     grp = mc.group(n=strandLName + 'NULL', em=1)
>     mc.select(deselect=1)
>     
>     #Parent Elements to Group
>     nucleotide = mc.parent(strandL, nucleo, strandR, grp)[0]
>     
>     #Move and rotate groups
>     mc.setAttr(grp + '.translateX', -5.5)
>     mc.xform(grp, cp=1)
>     mc.setAttr(grp + ".translateY", x * 2)
>     mc.setAttr(grp + ".ry", 15 * x)
>     mc.select(deselect=1)
>
>
>
>
>
> # I have 3 objects that have been grouped, I would like to make the names 
> relative so that if the object exists it will create a new object based on 
> what already exists. It would be great if I could do the same with position 
> so that the strand continuously grows each time the script is run.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/256ae303-1d31-43bc-ba6d-90bab2801802%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to