我通常不会发布如此看似基本的内容,但整个下午我一直感到困惑。
每当我尝试运行此代码时,Maya都会给我一个非常非特定的“语法错误”,任何人都可以看到此问题吗?
import maya.cmds as cmds
def listSelMesh(*args):
cmds.textScrollList("ab_meshList", en=1, ra=1) #CLEAR THE OLD LIST
trans = cmds.ls(sl=1) #LIST SELECTED OBJECTS
meshList = cmds.listRelatives(trans, c=1) or [] #GET ANY SHAPES
shapeList = cmds.ls(meshList, t=1) #GET ANY MESHES
for trans in shapeList:
cmds.textScrollList("ab_meshList", e=1, a=trans) #APPEND THE CLEARED LIST WITH THE NEW SHAPES
#Create the UI
def createUI(pWindowTitle, pApplyCallback):
windowID = 'ba_skinExport'
#If the UI is already open, delete the pre-existing instance
if cmds.window(windowID, exists=True):
cmds.deleteUI(windowID)
cmds.window(windowID, title=pWindowTitle, sizeable=True, resizeToFitChildren=True)
#Layout the columns in the UI
cmds.columnLayout(adjustableColumn=True)
form = cmds.formLayout()
text1 = cmds.text(label='Selected mesh')
shapeList = cmds.textScrollList("ab_meshList", p=form, h=75)
btn1 = cmds.button(label='Load', command=listSelMesh)
btn2 = cmds.button(label='Export', command=pApplyCallback)
btn3 = cmds.button(label='Import', command=pApplyCallback)
btn4 = cmds.button(label='Cancel', command=cancelCallback, w=85)
cmds.showWindow()
cmds.formLayout(form, e=1,
attachForm=((shapeList, "top", 10), (shapeList, "left", 100), (shapeList, "right", 10),
(btn1, "top", 92), (btn1, "left", 100), (btn1, "right", 10),
(text1, "top", 92), (text1, "left", 20),
(btn2, "top", 144), (btn2, "left", 100), (btn2, "right", 100),
(btn3, "top", 144), (btn3, "left", 100), (btn3, "right", 100),
(btn4, "top" 144), (btn4, "left", 10)
))
createUI('ba_skinExport', applyCallback)
最佳答案
更改此行,(缺少,
)
(btn4, "top" 144)
至
(btn4, "top", 144)
关于python - Maya中的语法错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29332391/