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

Synopsis

optionVar [-arraySize string] [-clearArray string] [-exists string] [-floatValue string float] [-floatValueAppend string float] [-intValue string int] [-intValueAppend string int] [-list] [-remove string] [-removeFromArray string int] [-stringValue string string] [-stringValueAppend string string] [-version int]

optionVar is undoable, queryable, and NOT editable.

This command allows you to set and query variables which are persistent between different invocations of Maya. These variables are stored as part of the preferences.

Return value

int0 or 1 for the exists option
string[]When the list option is used

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

Flags

arraySize, clearArray, exists, floatValue, floatValueAppend, intValue, intValueAppend, list, remove, removeFromArray, stringValue, stringValueAppend, version
Long name (short name) Argument types Properties
-arraySize(-as) string create
returns the size of the array named "string". If no such variable exists, it returns 0. If the variable is not an array, it returns 1.
-clearArray(-ca) string createmultiuse
If there is an array named "string", it is set to be empty. Empty arrays are not saved.
-exists(-ex) string create
returns 1 if a variable named "string" exists, 0 otherwise. All other flags will be ignored if this is used. (Query has higher precedence)
-floatValue(-fv) string float createmultiuse
creates a new variable named "string" with double value "float". If a variable already exists with this name, it is overridden in favour of the new value (even if the type is different)
-floatValueAppend(-fva) string float createmultiuse
adds this value to the end of the array of floats named "string". If no such array exists, one is created. If there was a float value with this name before, it becomes the first element of the array. If any other kind of value existed, it is overridden.
-intValue(-iv) string int createmultiuse
creates a new variable named "string" with integer value "int". If a variable already exists with this name, it is overridden in favour of the new value (even if the type is different).
-intValueAppend(-iva) string int createmultiuse
adds this value to the end of the array of ints named "string". If no such array exists, one is created. If there was an int value with this name before, it becomes the first element of the array. If any other kind of value existed, it is overridden.
-list(-l) create
this returns a list of all the defined variable names. All other flags will be ignored if this one is used. (Query and exists flags have a higher precedence).
-remove(-rm) string createmultiuse
removes the variable named "string", if one exists.
Note: all removals are done before any value setting, if both the -r and other (-sv, -iv, -fv) flags are used in the same command.
-removeFromArray(-rfa) string int createmultiuse
removes the element numbered "int" in the array named "string". Everything beyond it then gets shuffled down.
-stringValue(-sv) string string createmultiuse
creates a new variable named using the first string with value given by the second string. If a variable already exists with this name, it is overridden in favour of the new value (even if the type is different)
-stringValueAppend(-sva) string string createmultiuse
adds the value given by the second string to the end of the array of strings named by the first string. If no such array exists, one is created. If there was a string value with this name before, it becomes the first element of the array. If any other kind of value existed, it is overridden.
-version(-v) int create
Preferences version number to warn about incompatbile preference files

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 be used more than once in a command.

MEL examples

optionVar -iv "defaultTriangles" 4 -sv "defaultFileName" "buffalo.maya";
optionVar -exists "defaultTriangles";
// Result: 1 //
optionVar -q "defaultFileName";
// Result: buffalo.maya //
optionVar -list;
optionVar -remove defaultTriangles;
optionVar -exists "defaultTriangles";
// Result: 0 //