While you will often need to add one-way controls (such as buttons) that trigger functions upon user input, you will also often need to retrieve information from the user before taking an action. In this example, we'll be looking at how to grab input from field controls, in both integer and float varieties.
The finished script will create a given number of polygonal spheres, each with a given radius. The resulting UI will look like the following:
Pressing the Make Spheres button with the previously mentioned settings of 4 spheres at a radius of 0.5 units each will result in a line of spheres along the x-axis:
Create a new script and name it makeSpheres.py
. Add the following code:
import maya.cmds as cmds global sphereCountField global sphereRadiusField def showUI(): global sphereCountField global sphereRadiusField myWin = cmds.window(title="Make Spheres", widthHeight=(300, 200)) cmds.columnLayout() sphereCountField = cmds.intField...