Maya Python referencing optionMenu returns as non-existent

Dalia Hileman Source

I am trying to write a script that, on button press with a joint selected, will copy the transform values from the selected joint(s) and then create a controller selected from an option menu. My problem is getting the code to read the option menu. I've tried several variations and all say there is no option menu with the selected name.

Code follows....

import maya.cmds as maya

def testWin():
    winName = maya.window(title="test", rtf = True, mxb = False)

    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' )



def test():
    sel = = "joint", sl=True)
    if not sel:
        print "select at least 1 JOINT"

        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 = = new_pos)
        elif shape == "Square":
            new_control = maya.nurbsSquare(center = new_pos)
        elif shape == "Triangle":
            new_control = = new_pos, degree = 1, sections = 3)


comments powered by Disqus