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>
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.