Go to: Synopsis. Return value. Keywords. Related. Flags. Python examples.

Synopsis

hudSliderButton([string], [allowOverlap=boolean], [block=int], [blockAlignment=string], [blockSize=string], [buttonLabel=string], [buttonLabelFontSize=string], [buttonPressCommand=script], [buttonReleaseCommand=script], [buttonShape=string], [buttonWidth=int], [decimalPrecision=int], [internalPadding=int], [maxValue=float], [minValue=float], [padding=int], [section=int], [sliderDragCommand=script], [sliderIncrement=float], [sliderLabel=string], [sliderLabelFontSize=string], [sliderLabelWidth=int], [sliderLength=int], [sliderPressCommand=script], [sliderReleaseCommand=script], [type=string], [value=float], [valueAlignment=string], [valueFontSize=string], [valueWidth=int], [visible=boolean])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

hudSliderButton is NOT undoable, queryable, and editable.

This command creates a Heads-up Display (HUD) slider button control which is placed in a 2D inactive overlay plane on the 3D viewport. It is to be used to provide hands-on interaction designated by a user script. The HUD slider button control is derived from a generic HUD object and thus inherits a similar workflow.

Although this command provides much of the same functionality as the headsUpDisplay command, it does not provide headsUpDisplay layout controls such as layoutVisibility, nextFreeBlock, lastOccupiedBlock, exists, remove, etc. To access that functionality, please use the headsUpDisplay command. This command is focused solely around the creation and management of HUD slider button controls. Similarly, all operations performed by this command are limited to HUDs that are slider button controls.

The only mandatory flags, on creation are the section and block flags.

Like the headsUpDisplay command, upon creation of a HUD slider button, an ID number will be assigned to it. This can be used to remove the HUD slider via the headsUpDisplay command (-rid/removeID [int IDNumber]), if desired. Alternatively, the headsUpDisplay command can remove HUD objects via their position (section and block), or their unique name.

Return value

intID number of the Heads-Up Display (HUD).
string|int|int[2]HUD name, HUD ID or Section and block value, for respective remove commands.

In query mode, return type is based on queried flag.

Keywords

hud, headsupdisplay, slider, hudslider, hudsliderbutton, button

Related

button, floatSlider, headsUpDisplay, intSlider

Flags

allowOverlap, block, blockAlignment, blockSize, buttonLabel, buttonLabelFontSize, buttonPressCommand, buttonReleaseCommand, buttonShape, buttonWidth, decimalPrecision, internalPadding, maxValue, minValue, padding, section, sliderDragCommand, sliderIncrement, sliderLabel, sliderLabelFontSize, sliderLabelWidth, sliderLength, sliderPressCommand, sliderReleaseCommand, type, value, valueAlignment, valueFontSize, valueWidth, visible
Long name (short name) Argument types Properties
allowOverlap(ao) boolean createqueryedit
Sets the Heads-Up Display to be visible regardless of overlapping section widths/limitations (see -s/section flag description for more details).
block(b) int createqueryedit
Denotes the individual block that the HUD will reside in, within a section. Each section is composed of a single column of blocks. The total number of blocks contained within each section is variable.

The number of blocks that will be visible within each section is dependent on the size of blocks contained in each section and the current size of the window. Blocks begin enumerating from 0 and flexibly increase based on need.

For HUD sliders, the format differs from that of the standard HUD. The layout using parameters defined by the formatting flags listed below (eg. justify, padding, labelWidth, valueWidth) is shown below:

__________________________________________________________________________
|     |     |      |           |      |       |      |        |     |     |
|  P  |  J  |  LW  |  Slider   |  IP  | Value |  IP  | Button |  J  |  P  |
|_____|_____|______|___________|______|_______|______|________|_____|_____|
P = Sub-block of width, padding
J = Justification of the entire block
LW = Sub-block of width, labelWidth
Slider = Length of the slider
SliderValue = Sub-block of width, valueWidth
Button = Sub-block of width, buttonWidth
IP = Internal Padding

Block Positioning

Blocks on the top section begin from the top edge of the main viewport, while the bottom section begins from the bottom edge. Blocks are dynamically removed from visibility from the midpoint of the viewport. So, a relatively large block number will not draw to the viewport.

Lastly, there can be at most one HUD occupying a block at any time. Trying to position a HUD in an occupied block will result in an error. Keep this in mind when positioning the HUD.

blockAlignment(ba) string createqueryedit
Specifies the alignment of the block within its respective column. Available alignments are: "center", "left" and "right". The default alignment is "left".
blockSize(bs) string createqueryedit
Sets the height of each block. Available heights are: small, medium and large. In pixel measurements, each corresponds to a 20, 35 or 50 pixel height, respectively.
buttonLabel(bl) string createqueryedit
Text label of the HUD button.
buttonLabelFontSize(bfs) string createqueryedit
Sets the font size of the button label. Available sizes are: small and large.
buttonPressCommand(bpc) script createqueryedit
Specifies the procedure or script to run during a button mouse click event.
buttonReleaseCommand(brc) script createqueryedit
Specifies the procedure or script to run during a button mouse release event.
buttonShape(bsh) string createqueryedit
Specifies the shape of the button. Available button shapes are: "rectangle" and "roundRectangle". The first will draw a rectangular button, while the latter is a rectangle with rounded edges.
buttonWidth(bw) int createqueryedit
Specifies the width of the button.
decimalPrecision(dp) int createqueryedit
Sets the decimal precision of any floating point value returned by the command. The valid range of precision values are 1 to 8.
internalPadding(ip) int createqueryedit
Specifies the amount of padding between the internal elements of the HUD. For the hudSlider, this represents the padding between the slider bar and the slider value. The default padding is 10.
maxValue(max) float createqueryedit
Specify the maximum value of the slider. Note: Although this flag takes in a FLOAT as an argument, if the HUD type is "int", the value will be automatically converted internally to an integer.
minValue(min) float createqueryedit
Specify the minimum value of the slider. Note: Although this flag takes in a FLOAT as an argument, if the HUD type is "int", the value will be automatically converted internally to an integer.
padding(p) int createqueryedit
Specifies the width of both the left and right margins of a block. Default value is 15 pixels.
section(s) int createqueryedit
Defines the section the HUD will appear in. There are 10 sections divided across the screen. Five columns and two rows make up the ten element matrix which divide the main viewport. Here is a visual layout of the sections.

 ________________________
|    |    |    |    |    |
|    |    |    |    |    |
| 0  | 1  | 2  | 3  | 4  |
|    |    |    |    |    |
|____|____|____|____|____|
|    |    |    |    |    |
|    |    |    |    |    |
| 5  | 6  | 7  | 8  | 9  |
|    |    |    |    |    |
|____|____|____|____|____|

Each section is denoted by a number from 0 to 9 as illustrated above. For example, if the second column of the top row was desired, the section would be defined as: -sec 1

To prevent HUD objects from displaying over each other and causing a clutter of letters, each row has a defined visibility precedence, where each section would have a visibility priority level. Depending on each priority level, when the screen space begins to shrink to a point where the section widths of a given row begin to collide, the HUD automatically compensates for this by removing the sections of least priority. These sections are made invisible and a warning is issued to inform the user of the removal. This continues until only the section of highest priority remains.

For each row, the priorities are defined as follows. Using the top row as an example: Section 0, has the highest priority, followed by Section 4, making the outermost sections of highest priority. Next in the list is Section 2, and lastly Sections 1 and 3 are of the equal and least priority. This priority structure can be applied to the bottom row as well. The two outermost sections have the highest priority, followed by the middle section, and finally the remaining two sections are of lowest priority.

This means that as the viewport gradually decreases in width to the point where sections in the top row begin to overlap, sections 1 and 3 will be removed from view first, followed by section 2, and finally section 4. A similar note is provided below for the block layout.

sliderDragCommand(sdc) script createqueryedit
Specifies the procedure or script to run during a slider mouse drag event.
sliderIncrement(si) float createqueryedit
Specify the number of increments along the slider. If not specified or set to 0 or less, the slider will be linearly even and continuous from minValue to maxValue. Note: Although this flag takes in a FLOAT as an argument, if the HUD type is "int", the value will be automatically converted internally to an integer.
sliderLabel(sl) string createqueryedit
Text label of the HUD slider.
sliderLabelFontSize(sfs) string createqueryedit
Sets the font size of the slider label. Available sizes are: small and large.
sliderLabelWidth(slw) int createqueryedit
Specifies the pixel width of the virtual "textbox" which will hold the label. The contents of this "textbox" will be left justified. If the width of the actual label exceeds the width of the "textbox," the label will be truncated to fit within the dimensions of the "textbox." (To see a layout of a block, see the description of the -block flag.)
sliderLength(sln) int createqueryedit
Specifies the length of the slider in pixels.
sliderPressCommand(spc) script createqueryedit
Specifies the procedure or script to run during a slider mouse click event.
sliderReleaseCommand(src) script createqueryedit
Specifies the procedure or script to run during a slider mouse release event.
type(t) string createqueryedit
Specify the numeric type of the HUD. Available types are: "float" and "int".
value(v) float createqueryedit
Set/Return the slider value if the HUD is a valid HUD slider. Note: Although this flag takes in a FLOAT as an argument, if the HUD type is "int", the value will be automatically converted internally to an integer.
valueAlignment(va) string createqueryedit
Specifies the alignment of the data blocks and the data text, within a HUD block. Available alignments are: "left" and "right". The default alignment is "left".
valueFontSize(vfs) string createqueryedit
Sets the font size of the slider value. Available sizes are: small and large.
valueWidth(vw) int createqueryedit
Specifies the pixel width of the virtual "textbox" which will hold the slider value. (To see a layout of a block, see the description of the -block flag.)
visible(vis) boolean createqueryedit
Sets the visibility of the Heads-Up Display on and off.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

# Define a procedure to execute on press/drag/release. This procedure
# will explicitly set any selected transforms to a given position along
# the X axis based on the value of a given HUD slider.
#
def translateXSliderButton( HUD ):
	cmds.undoInfo( swf=True )
	selList = cmds.ls( sl=True )
	for object in selList:
		if cmds.objectType( object, isType='transform' ):
			cmds.setAttr( object+".tx", cmds.hudSliderButton( HUD, query=True, v=True ) )
# Create our slider button.  Use lambda to create an "anonymous" function that invokes the
# callback with the desired button name argument.
#
cmds.hudSliderButton( 'HUDTranslateXSliderButton', s=5, b=5, vis=True, sl='Slider:', value=0, type='int', min=-10, max=10, slw=50, vw=50, sln=100, si=1, bl='Button', bw=60, bsh='rectangle', brc=lambda : translateXSliderButton( 'HUDTranslateXSliderButton' ))