- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey guys, so here is what I'm trying to do: select a shape via checkbox and hit execute, then create the shape of your choosing. Atleast in theory that is how it should work, in practice however: it just creates cylinders from the cylinder option and thats it, so if anyone wants to take a crack at it, here you go:
import maya.cmds as cmds
#Creates ui.
if cmds.window(window, exists =True):
cmds.deleteUI(window)
window = cmds.window( title = "DS Shape Builder Demo", widthHeight=(300, 200) )
cmds.columnLayout(adjustableColumn=True)
#Creates variable to indecate the check box status. 1=Checked 0=Not Checked.
cubeNum = 0
cubeNum1 = 0
cubeNum2 = 0
#Creates Button funtion.
def defaultButtonPush(*args):
#The Print checks if button is pushed and what is the check box status.
print "Button is pushed."
print cubeNum
#Check box argument finds the status of the variable and determines what to do.
#Eather create a cube or display a error dialog box.
if cubeNum == 1:
print "Cube Creation sucessful"
cmds.polyCube()
else:
cmds.confirmDialog(t="Error",m="Cube will not be created."+ 'n' + 'Please check the box to create a cube.')
def defaultButtonPush(*args):
print "Button is pushed."
print cubeNum1
if cubeNum1 == 1:
print "Sphere Creation sucessful"
cmds.polySphere()
else:
cmds.confirmDialog(t="Error",m="Sphere will not be created."+ 'n' + 'Please check the box to create a Sphere.')
def defaultButtonPush(*args):
print "Button is pushed."
print cubeNum2
if cubeNum2 == 1:
print "Cylinder Creation sucessful"
cmds.polyCylinder()
else:
cmds.confirmDialog(t="Error",m="Cylinder will not be created."+ 'n' + 'Please check the box to create a Sphere.')
#Creates check box.
#In the onCommand Script (onc) and offCommand Script (ofc) flags all commands must be made in between double quotes.
cmds.checkBox(label='Cube',value=False,align='left',onCommand="cubeNum = 1", offCommand="cubeNum = 0")
cmds.checkBox(label='Sphere',value=False,align='left',onCommand="cubeNum1 = 1", offCommand="cubeNum1 = 0")
cmds.checkBox(label='Cylinder',value=False,align='left',onCommand="cubeNum2 = 1", offCommand="cubeNum2 = 0")
#Creates Button.
cmds.button( label='Execute', command=defaultButtonPush ,align='left' )
cmds.showWindow()
Solved! Go to Solution.