嗨,我是一個Python和腳本編寫的新手,閱讀了很多教程,並嘗試創建腳本,將curveShapes合併到一條具有多形狀的曲線,它對我來說工作正常。但在這裏我有一個錯誤,當我啓動腳本第一次發射後瑪雅它給了我回溯,如果它是一個運行時它不給任何錯誤或回溯:Maya python腳本將幾條曲線合併爲一條
// Error: Not enough objects or values.
# Traceback (most recent call last):
# File "<maya console>", line 2, in <module>
# File "C:/Users/.../maya/2017/scripts\CreateOneCurve.py", line 17, in <module>
# cmds.parent(r=True, s=True)
# RuntimeError: Not enough objects or values. //
這裏我的腳本:
#Funcion for create list of objects
def listCurveObj():
shapeList = cmds.ls(cmds.listRelatives(s=True), s=True)
groupList = cmds.ls(cmds.group(em=True, n='Curve#'))
listAllobjects = []
for obj in groupList:
listAllobjects.extend(shapeList)
listAllobjects.extend(groupList)
return listAllobjects
#Create one Curve
cmds.select(listCurveObj())
cmds.parent(r=True, s=True)
#Clean scene
transforms = cmds.ls(type='transform')
deleteList = []
for tran in transforms:
if cmds.nodeType(tran) == 'transform':
children = cmds.listRelatives(tran, c=True)
if children == None:
print '%s, has no childred' %(tran)
deleteList.append(tran)
if len(deleteList) > 0:
cmds.delete(deleteList)
任何人都可以幫忙嗎?
只是爲了記錄,最好使用'pymel.core'而不是'maya.cmds',它非常相似,但給了更多的控制權。我有時候會重新安裝maya,然後看看,可能需要幾天時間:) – Peter