The colorEditorcommand displays a modal dialog that may be used to specify colors in RGB or HSV. The default behaviour when no arguments are specified is to provide an initial color of black (rgb 0.0 0.0 0.0). The command will return the user’s color component values along with a boolean to indicate whether the dialog was dismissed by pressing the “OK” button. As an alternative to responding to the colorEditorcommand’s return string you can now query the -rgb/rgbValue, -hsv/hsvValue, and -r/resultflags to get the same information.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
alpha (a) | float | ||
hsvValue (hsv) | float, float, float | ||
Three float values corresponding to the hue, saturation, and value color components, where the hue value ranges from 0.0 to 360.0 and the saturation and value components range from 0.0 to 1.0. Use this flag to specify the initial color of the Color Editor, or query this flag to determine the color set in the editor. |
|||
parent (p) | unicode | ||
Specify the parent window for the dialog. The dialog will be centered on this window and raise and lower with it’s parent. By default, the dialog is not parented to a particular window and is simply centered on the screen. |
|||
result (r) | bool | ||
This query only flag returns true if the dialog’s “OK” button was pressed, false otherwise. If you query this flag immediately after showing the Color Editor then it will return the same value as the boolean value returned in the colorEditorcommand’s return string.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list. |
|||
rgbValue (rgb) | float, float, float | ||
Three float values corresponding to the red, green, and blue color components, all of which range from 0.0 to 1.0. Use this flag to specify the initial color of the Color Editor, or query this flag to determine the color set in the editor. |
Derived from mel command maya.cmds.colorEditor
Example:
import pymel.core as pm
# Example 1.
#
pm.colorEditor()
if pm.colorEditor(query=True, result=True):
values = pm.colorEditor(query=True, rgb=True)
print 'RGB = ' + str(values)
values = pm.colorEditor(query=True, hsv=True)
print 'HSV = ' + str(values)
alpha = pm.colorEditor(query=True, alpha=True)
print 'Alpha = ' + str(alpha)
else:
print 'Editor was dismissed'
# Example 2.
#
result = pm.colorEditor()
buffer = result.split()
if '1' == buffer[3]:
values = pm.colorEditor(query=True, rgb=True)
print 'RGB = ' + str(values)
alpha = pm.colorEditor(query=True, alpha=True)
print 'Alpha = ' + str(alpha)
else:
print 'Editor was dismissed'