我正在使用Python在Maya中创建用户界面。我一直收到这个错误:
Error: line 1: keyword can't be an expression
有人知道如何解决这个问题吗?
import maya.cmds as cmds
if mc.window(ram, exists =True):
mc.deleteUI(ram)
ram = cmds.window("RenamerWin",t = "Renamer Tool", w=300, h=300)
cmds.columnLayout(adj = True)
cmds.text("Welcome to the tool renamer")
cmds.separator(h=10)
cubW = cmds.intSliderGrp(1 = "Width",min =0, max =10, field =True)
cubH = cmds.intSliderGrp(1 = "Height",min =0, max =10, field =True)
cubD = cmds.intSliderGrp(1 = "Depth",min =0, max =10, field =True)
cmds.button(l = "Create a Cube",c="myCube()")
cmds.showWindow(ram)
def myCube():
myCubeWidth = cmds.intSliderGrp(cubW , q= True,value =True)
myCubeHeight = cmds.intSliderGrp(cubH , q= True,value =True)
myCubeDepth = cmds.intSliderGrp(cubWD , q= True,value =True)
finalCube = cmds.polyCube(w=myCubeWidth,h=myCubeHeight,d=myCubeDepth , n = "myCube")
答案 0 :(得分:0)
一些事情:
mc
和cmds
。如果您在听众中的不同时间完成了这项工作,但它不会按照书面形式工作,那么这可能会有效。ram
。对于之前没有运行过此操作的人来说,第2行将会失败。myCube()
这是一个工作版本;检查你所拥有的差异。请注意,我将整个内容放在def中,以确保它不会让您遇到早期运行剩余时间的麻烦:
import maya.cmds as cmds
def example ():
ram = 'RenamerWin'
if cmds.window(ram, q = True, exists =True):
cmds.deleteUI(ram)
ram = cmds.window("RenamerWin",t = "Renamer Tool", w=300, h=300)
cmds.columnLayout(adj = True)
cmds.text("Welcome to the tool renamer")
cmds.separator(h=10)
cubW = cmds.intSliderGrp(l = "Width", min =0, max = 10, field = True)
cubH = cmds.intSliderGrp(l = "Height", min =0, max = 10, field = True)
cubD = cmds.intSliderGrp(l = "Depth", min =0, max = 10, field = True)
def myCube(_):
myCubeWidth = cmds.intSliderGrp(cubW , q= True,value =True)
myCubeHeight = cmds.intSliderGrp(cubH , q= True,value =True)
myCubeDepth = cmds.intSliderGrp(cubD , q= True,value =True)
finalCube = cmds.polyCube(w=myCubeWidth,h=myCubeHeight,d=myCubeDepth , n = "myCube")
cmds.button(l = "Create a Cube",c=myCube)
cmds.showWindow(ram)
example()