試圖使我創建的腳本能夠多次運行。如果我運行它,一旦它的工作原理,但我第二次獲得:如果存在對象在Maya中添加一個新的對象名稱Python
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)
我已經組合3個對象,然後該組被反覆另一個19倍創造螺旋DNA鏈。我想使名稱相對,如果對象存在,它會根據已經存在的內容創建一個新的對象(例如strandLName 20 ++)。如果我可以在這個位置上做同樣的事情,那麼每次腳本運行時鏈的連續增長都是非常棒的。