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

Synopsis

dimWhen( string string , [clear=boolean], [false=boolean], [true=boolean])

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

dimWhen is undoable, NOT queryable, and NOT editable.

This method attaches the named UI object (first argument) to the named condition (second argument) so that the object will be dimmed when the condition is in a particular state. This command will fail if the object does not exist. If the condition does not exist (yet), that's okay --- a placeholder will be used until such a condition comes into existence. The UI object should be one of two things, either a control or a menu item.

Return value

None

Flags

clear, false, true
Long name (short name) Argument types Properties
false(f) boolean create
Dim the object when the condition is false.
true(t) boolean create
Dim the object when the condition is true. (default)
clear(c) boolean create
Remove the condition on the specified dimmable.

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

#    Create a window with a menu item and button that will dim if
#    there are no objects selected in the scene.
#
window = cmds.window(menuBar=True, title='dimWhen Example')
cmds.menu( label='Edit' )
menuItem = cmds.menuItem(label='Delete Selection', command='cmds.delete()')
cmds.columnLayout(adjustableColumn=True)
button = cmds.button(label='Delete Selection', command='cmds.delete()')

#    Create a few buttons to create some objects, select all the objects in
#    the scene, and clear the selection.
#
cmds.button(label='Create Objects', command='cmds.sphere(); cmds.cone(); cmds.cylinder();')
cmds.button(label='Select All', command='cmds.select(all=True)')
cmds.button(label='Select Nothing', command='cmds.select(clear=True)')

#    Add the dim conditions.
#
cmds.dimWhen( 'SomethingSelected', button, false=True )
cmds.dimWhen( 'SomethingSelected', menuItem, false=True )

cmds.showWindow( window )