我有以下错误消息:#Error:IndentationError:unindent与任何外部缩进级别都不匹配#
我试图删除所有缩进并替换每个缩进的四个空格,但我仍然遇到此错误。
我该怎么办?
import pymel.core as pm
class UI():
def __init__(self):
print 'init'
def renameselection (self):
sel=pm.ls(sl=True)
dialog = pm.promptDialog(title='Rename Object',message='Enter Name:', button=['OK', 'Add','Cancel'],defaultButton='OK',cancelButton='Cancel',dismissString='Cancel')
if dialog == 'OK':
name = pm.promptDialog(query=True, text=True)
for e in sel :
e.rename(name)
if dialog == 'Add':
name = pm.promptDialog(query=True, text=True)
for e in sel:
e.rename(e+name)
def CreateCircularController(self):
dialog = pm.promptDialog(title='Name',message='Name CTL:', button=['OK','_CTL','Cancel'],defaultButton='OK',cancelButton='Cancel',dismissString='Cancel')
selectedJoint=pm.ls(sl=True)
name = pm.promptDialog(query=True, text=True)
for e in selectedJoint:
if dialog=='OK':
Controller=pm.circle(nr=(0,1,0),n=name)
ControllerGrp=pm.group(Controller,n=name)
if dialog=='_CTL':
Controller=pm.circle(nr=(0,1,0),n=name+'CTL')
ControllerGrp=pm.group(Controller,n=name+'CTL')
pm.parent(ControllerGrp,selectedJoint,r=1)
pm.parent(ControllerGrp,w=1)
def buttonfunction(self,*args):
print ('Rename')
renameselection()
def secondButtonfunction(self,*args):
print ('Create Controller')
CreateCircularController()
####### Layout
def uipopup(self):
mrwindow = pm.window( title="Bjorn_rigging_wizzard", iconName='BWZ', widthHeight=(200, 400) )
# if set to true adjustable column will automatically update the UI layout if the user rezizes the window.
pm.columnLayout( adjustableColumn=True )
# text in the menu
pm.text(label='Select function doctor...')
# layout of the menu, collums are downward and rows are horizontally made side by side
pm.columnLayout (columnAttach=('both', 5), rowSpacing=10, columnWidth=(100))
# buttons are made into variables so that they can be called upon later with the setCommand - which enables functionallity
buttonOne = pm.button(label='Rename', width=100, command=self.buttonfunction)
buttonTwo = pm.button(label='Controller on selection', width=100)
buttonTwo.setCommand(self.secondButtonfunction)
# the setParent with '..' goes one back in hierachey, you will see the following text being outside of the "div" of the buttons.
pm.setParent('..')
pm.text(' ')
pm.text('Blaabjergb.com')
# once everything is build we can show the window
pm.showWindow( mrwindow )
UI1=UI()
UI1.uipopup()
答案 0 :(得分:0)
注意到def CreateCircularController
之前有5个空格,而另一个方法定义之前有4个空格。请确保每个方法定义前面都有4个空格。
由于def CreateCircularController(self):
之后的空行,也会出现错误。请删除空行,然后重试。