Hi I'm a newbee in python and scripting, read a lot of tutorials and try to create script for combine curveShapes to one curve with multishapes, it's works fine for me. But here i have one bug when i start script first time after launch Maya it gives me traceback and if it was run one time it don't give any errors or tracebacks:
// 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. //
Here my script:
#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)
May anyone can help with it?