Go to: Synopsis. Flags. Return value. Python examples.
colorEditor([alpha=float], [hsvValue=[float, float, float]], [parent=string], [result=boolean], [rgbValue=[float, float, float]])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
colorEditor is undoable, queryable, and editable.
The colorEditor command 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
white (rgb 1.0 1.0 1.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 colorEditor command's return string you can now query
the -rgb/rgbValue, -hsv/hsvValue, and -r/result
flags to get the same information.
alpha, hsvValue, parent, result, rgbValue
Long name (short name) |
[argument types] |
Properties |
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.
In query mode, this flag needs a value.
|
|
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.
In query mode, this flag needs a value.
|
|
alpha(a)
|
float
|

|
|
Alpha value ranging from 0.0 to 1.0. Use this flag
to specify the initial alpha value of the Color Editor, or query
this flag to determine the alpha value set in the editor.
In query mode, this flag needs a value.
|
|
parent(p)
|
string
|
|
|
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)
|
boolean
|
|
|
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 colorEditor command's
return string.
In query mode, this flag needs a value.
|
|
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.
|
string
The string format is "float float float boolean". The first three
float values correspond to the color components. If you specify the
the -rgb/rgbValue flag then the values returned will be RGB values.
Similarly, if you specify the -hsv/hsvValue flag then the values
returned will be HSV values. If neither flag is specified then the
default is to return RGB values.
The final argument is 1 if the dialog's "OK" button was pressed,
and 0 if the "Cancel" button was pressed.
import maya.cmds as cmds
# Example 1.
#
cmds.colorEditor()
if cmds.colorEditor(query=True, result=True):
values = cmds.colorEditor(query=True, rgb=True)
print 'RGB = ' + str(values)
values = cmds.colorEditor(query=True, hsv=True)
print 'HSV = ' + str(values)
alpha = cmds.colorEditor(query=True, alpha=True)
print 'Alpha = ' + str(alpha)
else:
print 'Editor was dismissed'
# Example 2.
#
result = cmds.colorEditor()
buffer = result.split()
if '1' == buffer[3]:
values = cmds.colorEditor(query=True, rgb=True)
print 'RGB = ' + str(values)
alpha = cmds.colorEditor(query=True, alpha=True)
print 'Alpha = ' + str(alpha)
else:
print 'Editor was dismissed'