Go to: Return value. Flags. Examples.

Synopsis

optionVar [flags]

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

The -query option can return int, float, string, int[], float[], or string[] values, depending on the type of the variable. -exists will return 1 or 0. Calls that set a variable will return nothing. The -list option returns an array of strings.

Flags

arraySize, clearArray, exists, floatValue, floatValueAppend, intValue, intValueAppend, list, query, remove, removeFromArray, stringValue, stringValueAppend, version

Long name (short name)[argument types]Properties
-intValue (-iv) string int
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). This is a multi-use flag.
-intValueAppend (-iva) string int
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. This is a multi-use flag.
-floatValue (-fv) string float
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) This is a multi-use flag.
-floatValueAppend (-fva) string float
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. This is a multi-use flag.
-stringValue (-sv) string1 string2
creates a new variable named "string1" with string value "string2". If a variable already exists with this name, it is overridden in favour of the new value. (even if the type is different) This is a multi-use flag.
-stringValueAppend (-sva) string1 string2
adds the value "string2" to the end of the array of strings named "string1". 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. This is a multi-use flag.
-remove (-rm) string
removes the variable named "string", if one exists. This is a multi-use flag. 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
removes the element numbered "int" in the array named "string". Everything beyond it then gets shuffled down.
-version (-v) int
Preferences version number to warn about incompatbile preference files
-clearArray (-ca) string
If there is an array named "string", it is set to be empty. Empty arrays are not saved.
-arraySize (-as) string
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.
-exists (-ex) string
returns 1 if a variable named "string" exists, 0 otherwise. All other flags will be ignored if this is used. (Query has higher precedence)
-query (-q) string
returns the value of the variable named "string". All other flags will be ignored if this is used. If there is no variable of the given name, the integer 0 is returned. This can return an int, a float, a double, an intArray, a floatArray, or a doubleArray.
-list (-l)
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).

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

Examples

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