Static class providing common API global functions.
MGlobal is currently a stub which only implements a small portion of the class's total functionality.
Constructors
MGlobal is a pure static class. It cannot be instantiated and therefore has no constructors.
str() Support
Not applicable as the class cannot be instantiated.
repr() Support
Not applicable as the class cannot be instantiated.
Member Function Documentation
OpenMaya.MGlobal.addToModel
(
)
static
addToModel(MObject, MObject) -> None
This method is used to add new dag objects to the model. If no parent node
is specified, then the node is added under the world. When a node is
added under the world, then a transform node is automatically created as
a parent. This assumes that the node being added is not already a
transform node.
This method is only valid for dag nodes. If the specified
object is not of type MFn::kDagNode then MS::kInvalidParameter will be returned.
OpenMaya.MGlobal.addToModelAt
(
)
static
addToModelAt(MObject, MVector, double[3], double[3], rotateOrder=MTransformationMatrix.kXYZ) -> None
Adds the specified dag object to the DAG and transform the object
by the specified arguments.
This method is only valid for dag nodes. If the specified
object is not of type MFn::kDagNode then MS::kInvalidParameter
will be returned.
OpenMaya.MGlobal.animSelectionMask
(
)
static
animSelectionMask() -> MSelectionMask
Returns the animation selection mask.
OpenMaya.MGlobal.apiVersion
(
)
static
apiVersion() -> int
Returns a number describing the version of the Maya API at runtime.
OpenMaya.MGlobal.className
(
)
static
className() -> string
Returns the name of this class.
OpenMaya.MGlobal.clearSelectionList
(
)
static
clearSelectionList() -> None
Removes all items from the active selection list.
OpenMaya.MGlobal.closeErrorLog
(
)
static
closeErrorLog() -> None
This method closes the API error log file. If error logging is currently
enabled this method disables it.
The error log is time and date stamped before it is closed.
After the log is closed the error log path name is reset to the default
path name.
If the error log file is already closed, then no action is taken.
Note that if a log is reopened after it is closed, all information previously
logged to it is lost.
OpenMaya.MGlobal.componentSelectionMask
(
)
static
componentSelectionMask() -> MSelectionMask
Returns the component selection mask.
OpenMaya.MGlobal.currentToolContext
(
)
static
currentToolContext() -> MObject
Returns the current tool context as an MObject.
OpenMaya.MGlobal.defaultErrorLogPathName
(
)
static
defaultErrorLogPathName() -> string
Determines the default path name of the error log file.
Returns an empty string on failure.
OpenMaya.MGlobal.deleteNode
(
)
static
deleteNode(MObject) -> None
Delete the given dag node or dependency graph node.
OpenMaya.MGlobal.disableStow
(
)
static
disableStow() -> bool
This method is used to query if the disabling of Stowing (hiding)
and Unstowing (showing) windows is active.
OpenMaya.MGlobal.displayError
(
)
static
displayError(msg) -> None
Display an error in the script editor.
Name:
displayError(msg)
Parameters:
msg - string
Returns:
Description:
Display an error in the script editor.
OpenMaya.MGlobal.displayInfo
(
)
static
displayInfo(msg) -> None
Display an informational message in the script editor.
Name:
displayInfo(msg)
Parameters:
msg - string
Returns:
Description:
Display an informational message in the script editor.
OpenMaya.MGlobal.displayWarning
(
)
static
displayWarning(msg) -> None
Display a warning in the script editor.
Name:
displayWarning(msg)
Parameters:
msg - string
Returns:
Description:
Display a warning in the script editor.
OpenMaya.MGlobal.doErrorLogEntry
(
)
static
doErrorLogEntry(string) -> bool
Logs an entry in the currently open log file. It is not necessary for error
logging to be enabled, but a log file must be open.
A newline is appended to each log entry.
OpenMaya.MGlobal.errorLoggingIsOn
(
)
static
errorLoggingIsOn() -> bool
This method determines whether or not API errors are being logged.
OpenMaya.MGlobal.errorLogPathName
(
)
static
errorLogPathName() -> string
Determines the path name of the current error log file.
Returns the null stringon failure.
OpenMaya.MGlobal.executeCommandOnIdle
(
)
static
executeCommandOnIdle(string, bool displayEnabled=False) -> None
Sets a MEL command to execute on the next idle event. Since the command
will likely not be executed until some time after control is returned to
caller, there is no access to the command results.
This method is thread safe and can be called from a thread other than
Maya's main thread. However, that thread must still be part of the Maya
process. Calling this method from a completely separate process will
not work and may lead to unpredictable behaviour.
OpenMaya.MGlobal.executeCommandStringResult
(
)
static
executeCommandStringResult(string, bool displayEnabled=False, bool undoEnabled=False) -> string or [string, string, ...]
Executes a MEL command that returns a string or an array of strings
result from the command engine depending on the number of return values.
Optionally allows display of the command in the Command Window to be
enabled or disabled. Defaults to disabled. Optionally allows undo
for the command to be enabled or disabled. Defaults to disabled.
Note: This is not thread safe; you may use executeCommandOnIdle instead
OpenMaya.MGlobal.getAbsolutePathToResources
(
)
static
getAbsolutePathToResources() -> string
Return the absolute path of Maya's "Resources" fold on the system,
including the "Resources" folder itself.
OpenMaya.MGlobal.getActiveSelectionList
(
)
static
getActiveSelectionList(orderedSelectionIfAvailable=False) -> MSelectionList
Return an MSelectionList containing the nodes, components and
plugs currently selected in Maya. If orderedSelectionIfAvailable
is True, and tracking is enabled, will return the selected items
in the order that they were selected.
getAssociatedSets(MSelectionList) -> list
This utility method finds all the sets that the items in
the given selection list are members of.
OpenMaya.MGlobal.getFunctionSetList
(
)
static
getFunctionSetList(MObject) -> (string, string, ...)
Returns a tuple of strings that represent the type of each function
set that will accept this object.
Returns a tuple of strings that represent the type of each function set that will accept this object.
OpenMaya.MGlobal.getHiliteList
(
)
static
getHiliteList() -> MSelectionList
Returns a copy of the hilite list. The hilite list contains all DAG objects
that are hilited for component selection mode. (e.g. when the user right clicks
over a Mesh object and chooses the "vertex" option the Mesh line drawing changes
color and the mesh is added to the hiliteList.)
OpenMaya.MGlobal.getLiveList
(
)
static
getLiveList() -> MSelectionList
Returns a copy of the live list. When a user performs a
"Modify->Make Live" in the user interface the currently selected
objects are added to the live list.
OpenMaya.MGlobal.getPreselectionHiliteList
(
)
static
getPreselectionHiliteList() -> MSelectionList
Gets the objects for which Maya is displaying a preselection
highlight in the viewports.
OpenMaya.MGlobal.getRichSelection
(
)
static
getRichSelection(defaultToActiveSelection=True) -> MRichSelection
Returns the current rich selection (usually the active selection with
any soft selection and symmetry applied). If no rich selection exists
and 'defaultToActiveSelection' is True, the current active selection
will be returned instead.
OpenMaya.MGlobal.getSelectionListByName
(
)
static
getSelectionListByName(name) -> MSelectionList
Returns an MSelectionList with all of the objects that match the
specified name. The name may use the same type of regular expressions
as can be used in MEL commands. For example, the pattern 'pCube*' will
match all occurrences of objects whose names begin with 'pCube'.
Returns a selection list with all of the objects that match the specified name. The name may use the same type of regular expressions as can be used in MEL commands. For example, the pattern "pCube*" will match all occurrences of objects whose names begin with "pCube".
OpenMaya.MGlobal.isRedoing
(
)
static
isRedoing() -> bool
true if Maya is currently in the middle of a redo.
OpenMaya.MGlobal.isSelected
(
)
static
isSelected(MObject) -> bool
Determines whether the given object is on the active selection list.
OpenMaya.MGlobal.isUndoing
(
)
static
isUndoing() -> bool
true if Maya is currently in the middle of an undo.
OpenMaya.MGlobal.isYAxisUp
(
)
static
isYAxisUp() -> bool
This method returns true if, currently, the Y-axis is UP.
OpenMaya.MGlobal.isZAxisUp
(
)
static
isZAxisUp() -> bool
This method returns true if, currently, the Z-axis is UP.
OpenMaya.MGlobal.mayaState
(
)
static
mayaState() -> int
Returns an enumerated type specifying the way in which Maya was invoked.
kInteractive Running with a UI
kBatch Running without a UI
kLibraryApp Running as a standalone (MLibrary) application.
kBaseUIMode Running with UI enabled but Maya's std UI scripts not run.
OpenMaya.MGlobal.mayaVersion
(
)
static
mayaVersion() -> string
Returns a string describing this version of Maya.
OpenMaya.MGlobal.miscSelectionMask
(
)
static
miscSelectionMask() -> MSelectionMask
Returns the miscellaneous selection mask.
OpenMaya.MGlobal.objectSelectionMask
(
)
static
objectSelectionMask() -> MSelectionMask
Returns the object selection mask.
OpenMaya.MGlobal.optionVarDoubleValue
(
)
static
optionVarDoubleValue(string) -> double
This method is used to get the option variable value of type double
OpenMaya.MGlobal.optionVarExists
(
)
static
optionVarExists(string) -> bool
This method is used to check if the option variable exists
OpenMaya.MGlobal.optionVarIntValue
(
)
static
optionVarIntValue(string) -> int
This method is used to get the option variable value of int type
OpenMaya.MGlobal.optionVarStringValue
(
)
static
optionVarStringValue(string) -> MString
This method is used to get the option variable value of type string
OpenMaya.MGlobal.removeFromModel
(
)
static
removeFromModel(MObject) -> None
Removes the specified dag node from the scene.
This method is only valid for dag nodes. If the specified
object is not of type MFn::kDagNode then MS::kInvalidParameter
will be returned.
Note that this method doesn't delete the dag node which means
the node must be added back to scene by calling either
MGlobal::addToModel() or MGlobal::addToModelAt() in later
calls, otherwise the dag node is leaked. To delete the dag node,
call MGlobal::deleteNode() instead.
OpenMaya.MGlobal.removeOptionVar
(
)
static
removeOptionVar(string) -> None
This method is used to remove the option variable
OpenMaya.MGlobal.resetToDefaultErrorLogPathName
(
)
static
resetToDefaultErrorLogPathName() -> None
Closes the current log file if it is open, and then resets the log path to
the default path.
Logging is disabled and the log file speicified by the default path is not opened.
If logging is disabled, it remains disabled.
Use startErrorLogging() to enable logging to the default log file.
If the current path is the default path, no action is taken,
but an invalid parameter error is returned.
Note that if the default log is reopened after it is closed, all information
previously logged to it is lost.
OpenMaya.MGlobal.selectByName
(
)
static
selectByName(string, listAdjustment=kReplaceList) -> None
Puts objects that match the give name on the active selection list.
OpenMaya.MGlobal.selectCommand
(
)
static
selectCommand(MSelectionList, listAdjustment=kReplaceList) -> None
Set the active selection list, by calling the built in Maya select
command. This differs from setActiveSelectionList in that in this
version Maya takes over the selection list you give it and will be
responsible for maintaing the necessary information required for
undo, redo, and journaling.
OpenMaya.MGlobal.selectFromScreen
(
)
static
selectFromScreen(short, short, listAdjustment=kAddToList, selectMethod=kWireframeSelectMethod) -> None
selectFromScreen(short, short, short, short, listAdjustment=kAddToList, selectMethod=kWireframeSelectMethod) -> None
Perform click-pick type selection on the dag. If an object intersects
the click point then it is selected according to listAdjustment.
OpenMaya.MGlobal.selectionMethod
(
)
static
selectionMethod() -> int
Determines the selection method that should be used in the currently active
viewport. This is useful as input to the "selectFromScreen" functions.
OpenMaya.MGlobal.selectionMode
(
)
static
selectionMode() -> int
Get current selection mode:
kSelectObjectMode Objects are selected as a whole. Components are not directly accessible.
kSelectComponentMode Components such as vertices are selectable in this mode.
kSelectRootMode Selecting the child in a hierarchy will also select its root DAG node.
kSelectLeafMode Selecting the child in a hierarchy will result only in that child being selected.
kSelectTemplateMode Templated objects are selectable in this mode.
OpenMaya.MGlobal.setActiveSelectionList
(
)
static
setActiveSelectionList(MSelectionList, listAdjustment=kReplaceList) -> None
Set the active selection list.
The selection items on the given list will update the contents of the active selection
list as indicated by the listAdjustment parameter.
Valid listAdjustment values are:
kReplaceList #Totally replace the list with the given items.
kXORWithList #Any of the items which are already on the list will be removed.
#Any which are not already on the list will be added to the end
#of the list.
kAddToList #Remove the items from the list.
kAddToHeadOfList #Add the items to the beginning of the list.
OpenMaya.MGlobal.setAnimSelectionMask
(
)
static
setAnimSelectionMask(mask) -> selfsetAnimSelectionMask(type) -> self
Set the animation selection mask to the supplied value.
* mask (MSelectionMask) - The selection mask.
* type (int) - The selection type (see MSelectionMask.addMask() for a list of values).
OpenMaya.MGlobal.setComponentSelectionMask
(
)
static
setComponentSelectionMask(mask) -> selfsetComponentSelectionMask(type) -> self
Set the component selection mask to the supplied value.
* mask (MSelectionMask) - The selection mask.
* type (int) - The selection type (see MSelectionMask.addMask() for a list of values).
OpenMaya.MGlobal.setDisableStow
(
)
static
setDisableStow(bool) -> None
This method is used to make the visiblity of all Maya windows unchangable.
If set to true, it disables any attempts to change the visiblity of any window.
In addition, all popup windows will be supressed.
OpenMaya.MGlobal.setDisplayCVs
(
)
static
setDisplayCVs(MSelectionList, bool) -> None
Controls drawing of control points in the specified selection list.
The selection items on the given list will be marked for drawing. This
overrides Maya's current draw list and allow, for example, the drawing
of control points without being in vertex selection mode.
OpenMaya.MGlobal.setErrorLogPathName
(
)
static
setErrorLogPathName(string) -> None
Determines the default path name of the error log file.
Returns an empty string on failure.
OpenMaya.MGlobal.setHiliteList
(
)
static
setHiliteList(MSelectionList) -> None
Sets the current hilite list. The current selection list is unchanged.
OpenMaya.MGlobal.setMiscSelectionMask
(
)
static
setMiscSelectionMask(mask) -> selfsetMiscSelectionMask(type) -> self
Set the miscellaneous selection mask to the supplied value.
* mask (MSelectionMask) - The selection mask.
* type (int) - The selection type (see MSelectionMask.addMask() for a list of values).
OpenMaya.MGlobal.setObjectSelectionMask
(
)
static
setObjectSelectionMask(mask) -> selfsetObjectSelectionMask(type) -> self
Set the object selection mask to the supplied value.
* mask (MSelectionMask) - The selection mask.
* type (int) - The selection type (see MSelectionMask.addMask() for a list of values).
OpenMaya.MGlobal.setOptionVarValue
(
)
static
setOptionVarValue(string, int) -> bool
setOptionVarValue(string name, double) -> bool
setOptionVarValue(string name, string) -> bool
This method is used to set the option variable value of int, bool, string type
OpenMaya.MGlobal.setPreselectionHiliteList
(
)
static
setPreselectionHiliteList(MSelectionList) -> None
Sets the objects for which Maya will display a preselection
highlight in the viewports.
The objects/components in the list will be drawn in Maya's
preselection highlight style on the next viewport refresh
(if preselection highlighting is enabled in the preferences).
If preselection highlighting is not enabled, Maya will still
store the list.
OpenMaya.MGlobal.setRichSelection
(
)
static
setRichSelection(MRichSelection) -> None
Set the current rich selection.
OpenMaya.MGlobal.setSelectionMode
(
)
static
setSelectionMode(int) -> None
Set the current selection mode.
See selectionMode() for a list of valid modes.
OpenMaya.MGlobal.setTrackSelectionOrderEnabled
(
)
static
setTrackSelectionOrderEnabled() -> None
Set whether Maya should maintain an active selection list which
maintains object and component selection order.
OpenMaya.MGlobal.setYAxisUp
(
)
static
setYAxisUp() -> None
This method sets the flag to identify which axis is Up, and
rotates the ground plane around around the X-axis 90 degrees to get
the Y-Up from Z-Up.
OpenMaya.MGlobal.setZAxisUp
(
)
static
setZAxisUp() -> None
This method sets the flag to identify which axis is Up, and
rotates the ground plane around around the X-axis 90 degrees to get
the Y-Up from Y-Up.
OpenMaya.MGlobal.sourceFile
(
)
static
sourceFile(string) -> None
Causes the MEL command engine to open the named file and execute
the contents of the file as a MEL script. If the provided fileName
is a Unix absolute pathname, then that file is opened. If a relative
pathname is provided, the directories indicated by the environment
variable, MAYA_SCRIPT_PATH, will be searched for a matching filename.
OpenMaya.MGlobal.startErrorLogging
(
)
static
startErrorLogging() -> None
startErrorLogging(string)
This method enables output to the API error log file specified by the path.
If another error log file is already open this method time and date stamps
the log, and closes it.
The new error log is time and date stamped when it is opened.
If the new path name is the same as the current path name, this method ensures
that logging is enabled, but no other action is taken.
OpenMaya.MGlobal.stopErrorLogging
(
)
static
stopErrorLogging() -> None
This method disables output to the API error log but does not close the log file.
OpenMaya.MGlobal.trackSelectionOrderEnabled
(
)
static
trackSelectionOrderEnabled() -> bool
Returns whether the selection order is currerntly being tracked.
OpenMaya.MGlobal.unselect
(
)
static
unselect(MObject) -> None
unselect(MDagPath, MObject) -> None
Remove the given object/components from the active selection list.
If components is null then the object will be unselected, otherwise
the components will be unselected.
Perform marquee type selection on the dag. If an object intersects the
selection rectangle, it is selected according to listAdjustment.
OpenMaya.MGlobal.unselectByName
(
)
static
unselectByName(string) -> None
Removes objects matching the pattern from the active selection list.
OpenMaya.MGlobal.upAxis
(
)
static
upAxis() -> MVector
This method returns the model's current up axis.
OpenMaya.MGlobal.viewFrame
(
)
static
viewFrame(double) -> None
viewFrame(MTime) -> None
Sets the global time to the specified time. This function is optimized
for sequential time values that are monotonically increasing. While
one can set the time randomly with this function, a significant
performance hit will be incurred.
Member Data Documentation
OpenMaya.MGlobal.kAddToHeadOfList = 4
static
Name:
kAddToHeadOfList
Type:
int
Description:
Add the items to the beginning of the list.
OpenMaya.MGlobal.kAddToList = 2
static
Name:
kAddToList
Type:
int
Description:
Add the items to the end of the list.
OpenMaya.MGlobal.kBaseUIMode = 3
static
Name:
kBaseUIMode
Type:
int
Description:
Running with UI functionality enabled but Maya's standard UI startup scripts are not run. Allows users to provide their own UI.
OpenMaya.MGlobal.kBatch = 1
static
Name:
kBatch
Type:
int
Description:
Running without a UI.
OpenMaya.MGlobal.kInteractive = 0
static
Name:
kInteractive
Type:
int
Description:
Running with a UI.
OpenMaya.MGlobal.kLibraryApp = 2
static
Name:
kLibraryApp
Type:
int
Description:
Running as standalone (MLibrary) application.
OpenMaya.MGlobal.kRemoveFromList = 3
static
Name:
kRemoveFromList
Type:
int
Description:
Remove the items from the list.
OpenMaya.MGlobal.kReplaceList = 0
static
Name:
kReplaceList
Type:
int
Description:
Totally replace the list with the given items.
OpenMaya.MGlobal.kSelectComponentMode = 1
static
Name:
kSelectComponentMode
Type:
int
Description:
Select components.
OpenMaya.MGlobal.kSelectLeafMode = 3
static
Name:
kSelectLeafMode
Type:
int
Description:
Select DAG leaves.
OpenMaya.MGlobal.kSelectObjectMode = 0
static
Name:
kSelectObjectMode
Type:
int
Description:
Select objects.
OpenMaya.MGlobal.kSelectRootMode = 2
static
Name:
kSelectRootMode
Type:
int
Description:
Select DAG roots.
OpenMaya.MGlobal.kSelectTemplateMode = 4
static
Name:
kSelectTemplateMode
Type:
int
Description:
Select templated objects.
OpenMaya.MGlobal.kSurfaceSelectMethod = 0
static
Name:
kSurfaceSelectMethod
Type:
int
Description:
Select based on the surface of the objects.
OpenMaya.MGlobal.kWireframeSelectMethod = 1
static
Name:
kWireframeSelectMethod
Type:
int
Description:
Select based on the wireframe of the objects.
OpenMaya.MGlobal.kXORWithList = 1
static
Name:
kXORWithList
Type:
int
Description:
Any of the items which are already on the list will be removed. Any which are not already on the list will be added to the end of the list.