我是Python新手,当我编译下面的Python代码时,我得到了
plz帮我修复
from maya import cmds
sel = cmds.ls(sl=1)
controller = None
preParent = None
for i in sel:
cmds.select(cl=1)
if controller == None or cmds.objExists(controller) == False:
controller1 = cmds.circle( nr=(1, 0, 0 ), name = i+"Ctrl")[0]
else:
controller1 = cmds.duplicate(controller, name = i + "Ctrl")[0]
grp = cmds.group(em =1, name = i+"Grp")
cmds.parent(controller1, grp)
pc = cmds.parentConstraint(i, grp, mo=0)
cmds.delete(pc)
cmds.pointConstraint(controller1, i, mo=0)
cmds.orientConstraint(controller1, i, mo=0)
if preParent != None:
cmds.parent(grp, preParent)
preParent = controller1
答案 0 :(得分:0)
在这里,我通过PyCharm格式函数运行代码。
from maya import cmds
sel = cmds.ls(sl=1)
controller = None
preParent = None
for i in sel:
cmds.select(cl=1)
if controller == None or cmds.objExists(controller) == False:
controller1 = cmds.circle(nr=(1, 0, 0), name=i + "Ctrl")[0]
else:
controller1 = cmds.duplicate(controller, name=i + "Ctrl")[0]
grp = cmds.group(em=1, name=i + "Grp")
cmds.parent(controller1, grp)
pc = cmds.parentConstraint(i, grp, mo=0)
cmds.delete(pc)
cmds.pointConstraint(controller1, i, mo=0)
cmds.orientConstraint(controller1, i, mo=0)
if preParent != None:
cmds.parent(grp, preParent)
preParent = controller1