In this code, I have an object creation menu that takes in values from a slider and uses that in the creation of the primitive - How can I actually get the sliders to store the number displayed as right now it just does nothing.
I could remove the sliders but ideally, id like to have them for a nicer user interface
import maya.cmds as mt
def ShowUI():
if mt.window("Main", exists = True):
mt.deleteUI("Main")
mt.window("Main", title = "Maya Primitives", w = 300, h = 500)
mt.columnLayout("MainLayout", w = 300, h =500)
mt.optionMenu("PolygonMenu", w = 250, label = "Polygon Selection:")
mt.menuItem(label = "Sphere")
mt.menuItem(label = "Cube")
mt.menuItem(label = "Cylinder")
mt.button("Create", label = "Create", w = 300, command=ObjectCreation)
mt.button("Delete", label = "Delete", w = 300, command=DeleteButton)
mt.button("Clear", label = "Clear", w = 300, command=SceneClear)
mt.showWindow("Main")
def DeleteButton(*args):
mt.delete()
def SceneClear(*args):
mt.delete(all=True, c=True)
def ObjectCreation(*args):
currentValue = mt.optionMenu("PolygonMenu", query=True, value=True)
if currentValue == "Sphere":
SphereSlider()
SphereRadius = mt.intSliderGrp(Sphradius, q = True, Value=True)
finalSphere= mt.polySphere(r=SphereRadius, name = "Sphere", ch=False)
elif currentValue == "Cube":
CubeSlider()
CubeWidth = mt.intSliderGrp(CubeW, q = True, Value=True)
CubeHeight = mt.intSliderGrp(CubeH, q = True, Value=True)
CubeDepth = mt.intSliderGrp(CubeD, q = True, Value=True)
finalSphere= mt.polyCube(w=CubeWidth, h=CubeHeight, d=CubeDepth, name = "Cube", ch=False)
elif currentValue == "Cylinder":
CylinderSlider()
CyclinderRadius = mt.intSliderGrp(Cylradius, q = True, Value=True)
CyclinderHeight = mt.intSliderGrp(CylH, q = True, Value=True)
finalCylinder= mt.polyCylinder(r=CylinderRadius, h=CylinderHeight, name = "Cylinder", ch=False)
def SphereSlider():
Sphradius = mt.intSliderGrp(l="Radius",min=0,max=25, field=True)
def CubeSlider():
CubeW = mt.intSliderGrp(l="Width", min=0, max=25, field=True)
CubeH = mt.intSliderGrp(l="Height", min=0, max=25, field=True)
CubeD = mt.intSliderGrp(l="Depth", min=0, max=25, field=True)
def CylinderSlider():
Cylradius = mt.intSliderGrp(l="Radius",min=0,max=25, field=True)
CylH = mt.intSliderGrp(l="Height", min=0, max=25, field=True)
ShowUI()