我正在尝试编写一个脚本,在选定关节的情况下按下按钮时,将复制选定关节的变换值,然后从选项菜单中创建一个选定的控制器。我的问题是获取读取选项菜单的代码。我尝试了几个变体,都说没有带有所选名称的选项菜单。
代码如下...
import maya.cmds as maya
def testWin():
winName = maya.window(title="test", rtf = True, mxb = False)
maya.columnLayout()
maya.button(label = "run test", c = "test()")
shapeMenu = maya.optionMenu( label='Shape Menu', changeCommand="test()" )
maya.menuItem( label='Circle' )
maya.menuItem( label='Square' )
maya.menuItem( label='Triangle' )
maya.showWindow(winName)
testWin()
def test():
sel = maya.ls(type = "joint", sl=True)
if not sel:
print "select at least 1 JOINT"
else:
new_pos = maya.xform(q=True, t=True, ws=True)
new_rot = maya.xform(q=True, rotation=True, ws=True)
shape = maya.optionMenu("Shape Menu", q = True, value = True)
if shape == "Circle":
new_control = maya.circle(center = new_pos)
elif shape == "Square":
new_control = maya.nurbsSquare(center = new_pos)
elif shape == "Triangle":
new_control = maya.circle(center = new_pos, degree = 1, sections = 3)发布于 2018-04-24 06:00:15
您不能确定maya是否会为您提供创建GUI对象时所要求的名称-在本例中,它永远不会起作用,因为返回的名称将没有空格。
您应该通过从testWin()函数返回shapeMenu的值来捕获选项菜单的名称,然后在test()函数中使用该值
https://stackoverflow.com/questions/49868459
复制相似问题