I am in need of some help, not sure how active this forum is anymore.

I am looking to see if there is any way to make a optionMenu run a command 
for each option in the drop down menu? I am pretty new to maya python so I 
do not know very much, but google is less helpful than finding everything 
out myself.

Here is the code that i currently have, I just am not sure how to connect 
the commands to the actual window ui;


-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/41b21fb8-843c-4451-a372-811fbca6e109n%40googlegroups.com.
import maya.cmds as cmds

def createObjects():
    new_object = cmds.optionMenu('amountOptions', q=True, v=True)
    
def createSphere():
    cmds.polySphere()
    
def createCube():
    cmds.polyCube()
    
def createCylinder():
    cmds.polyCylinder()
    
def createPlane():
    cmds.polyPlane()
    
def createCamera():
    cmds.camera()

    
def duplicateObj1():
    for obj in cmds.ls(sl=True):
        for index in range(1):
            cmds.duplicate()

def duplicateObj5():
    for obj in cmds.ls(sl=True):
        for index in range(5):
            cmds.duplicate()

def duplicateObj10():
    for obj in cmds.ls(sl=True):
        for index in range(10):
            cmds.duplicate()

def duplicateObj25():
    for obj in cmds.ls(sl=True):
        for index in range(25):
            cmds.duplicate()

def duplicateObj50(): 
    for obj in cmds.ls(sl=True):
        for index in range(50):
            cmds.duplicate() 

def duplicateObj100():  
    for obj in cmds.ls(sl=True):
        for index in range(100):
            cmds.duplicate()
    

if cmds.window('windows', exists=True):
    cmds.deleteUI('windows')
    
cmds.window('windows', t="Function Tool", w=150)


cmds.columnLayout()
cmds.rowColumnLayout(nc=3, co=[[1,"both",3],[2,"both",4],[3,"both",3]], h=25)
cmds.optionMenu('objectOptions',l='Object:', w=120)
cmds.menuItem(l=' ')
cmds.menuItem(l='Sphere')
cmds.menuItem(l='Cube')
cmds.menuItem(l='Cylinder')
cmds.menuItem(l='Plane')
cmds.menuItem(l='Camera')

cmds.optionMenu('amountOptions', l='Amount:', w=99)
cmds.menuItem(l=' ')
cmds.menuItem(l='1')
cmds.menuItem(l='5')
cmds.menuItem(l='10')
cmds.menuItem(l='25')
cmds.menuItem(l='50')
cmds.menuItem(l='100')
cmds.button(l='Create')
cmds.setParent('..')

cmds.showWindow()

Reply via email to