#错误:unindent与任何外部缩进级别都不匹配

时间:2018-01-23 06:40:11

标签: python

我是Python新手,当我编译下面的Python代码时,我得到了

错误:unindent与任何外部缩进级别

都不匹配

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

1 个答案:

答案 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