pymel.core.language

Functions and classes related to scripting, including MelGlobals and Mel

Functions

assignCommand This command allows the user to assign hotkeys and manipulate the internal array of named command objects.
commandEcho This command controls what is echoed to the command window.
condition This command creates a new named condition object whose true/false value is calculated by running a mel script.
conditionExists Returns True if the named condition exists, False otherwise.
connectControl This command attaches a UI widget, specified as the first argument, to one or more dependency node attributes. The attributes/nodes don’t have to exist yet, they will get looked up as needed. With no flag specified, this command works on these kinds of controls: floatField, floatScrollBar, floatSlider, intField, intScrollBar, intSlider, floatFieldGrp, intFieldGrp, checkBox, radioCollection, and optionMenu. With the indexflag, It will also work on the individual components of all other groups. This command sets up a two-way connectionbetween the control and the (first-specified) attribute. If this first attribute is changed in any way, the control will be appropriately updated to match its value. Summary: if you change the control, ALL the connected attributes change. If you change the FIRST attribute attached to the control, then the control will change. NOTE: the two-way connection will not be established if the attributes do not exist when the connectControlcommand is run. If the user later uses the control, the connection will be established at that time. To effectively use connectControlwith radioCollections and optionMenus, you must attach a piece of data to each radioButton and menuItem. This piece of data (an integer) can be attached using the dataflag in the radioButtonand menuItemcommands. When the button/item is selected, the attribute will be set to the value of its data. When the attribute is changed, the collection (or optionMenu) will switch to the item that matches the new attribute value. If no item matches, it will be left unchanged. There are some specialized controls that have connection capability (and more) built right into them. See attrFieldSliderGrp, attrFieldGrp, and attrColorSliderGrp. Using these classes can be easier than using connectControl.
deleteUI This command deletes UI objects such as windows and controls. Deleting a layout or window will also delete all of its children. If a flag is used then all objects being deleted must be of the specified type. This command may not be edited or queried. NOTE: it is recommended that the type flags be used to disambiguate different kinds of objects with the same name.
dimWhen This method attaches the named UI object (first argument) to the named condition (second argument) so that the object will be dimmed when the condition is in a particular state. This command will fail if the object does not exist. If the condition does not exist (yet), that’s okay — a placeholder will be used until such a condition comes into existence. The UI object should be one of two things, either a control or a menu item.
disable This command enables or disables the control passed as argument.
encodeString This action will take a string and encode any character that would need to be escaped before being sent to some other command.
evalDeferred This command takes the string it is given and evaluates it during the next available idle time.
evalEcho Derived from mel command maya.cmds.evalEcho
format This command takes a format string, where the format string contains format specifiers.
getLastError Derived from mel command maya.cmds.getLastError
getMelGlobal
getMelType return the name of the closest mel type equivalent for the given python object.
getProcArguments Derived from mel command maya.cmds.getProcArguments
isTrue This commmand returns the state of the named condition.
isValidMelType
rtype:bool
itemFilter This command creates a named itemFilter object. This object can be attached to selectionConnection objects, or to editors, in order to filter the item lists going through them. Using union, intersection and difference filters, complex composite filters can be created.
itemFilterAttr This command creates a named itemFilterAttr object. This object can be attached to editors, in order to filter the attributes going through them. Using union and intersection filters, complex composite filters can be created.
itemFilterRender This command creates a named renderTypeFilter object. This object can be attached to selectionConnection objects, or to editors, in order to filter the renderType lists going through them. Using union and intersection filters, complex composite filters can be created.
itemFilterType This command queries a named itemFilter object. This object can be attached to selectionConnection objects, or to editors, in order to filter the item lists going through them. Using union and intersection filters, complex composite filters can be created.
lsUI This command returns the names of UI objects.
objectTypeUI This command returns the type of UI element such as button, sliders, etc.
pause Pause for a specified number of seconds for canned demos or for test scripts to allow user to view results.
python Derived from mel command maya.cmds.python
pythonToMel convert a python object to a string representing an equivalent value in mel
refresh This command is used to force a redraw during script execution.
renameUI This command renames the UI object passed as first arument to the new name specified as second argument. If the new name is a duplicate, or not valid, then re-naming fails and the old name is returned.
scriptJob This command creates a script job, which is a MEL command or script. This job is attached to the named condition, event, or attribute. Each time the condition switches to the desired state (or the trigger is triggered, etc), the script is run. Script jobs are tied to the event loop in the interactive application. They are run during idle events. This means that script jobs do not exist in the batch application. The scriptJob command does nothing in batch mode. This triggering happens very frequently so for speed considerations no events are forwarded during playback. This means that you cannot use scriptJob -tc tcCallback;to alter animation behaviour. Use an expression instead, or the rendering callbacks preRenderMeland postRenderMel. When setting up jobs for conditions, it is invalid to setup jobs for the true state, false state, and state change at the same time. The behaviour is undefined. The user can only setup jobs for the true and/or false state, or only for the state change, but not three at the same time. i.e. if you do: // Set up a job that runs for the life of the application. // This job cannot be deleted with the killcommand no matter what. scriptJob -e SelectionChangedprint Annoying Message!\n-permanent;// set up a job for the true state scriptJob -ct playingBackplayBackCallback;// set up a job for the false state scriptJob -cf playingBackplayBackCallback;then you should NOT do scriptJob -cc playingBackplayBackCallback;otherwise it will lead to undefined behaviour. This command can also be used to list available conditions and events, and to kill running jobs.
selectionConnection This command creates a named selectionConnection object. This object is simply a shared selection list. It may be used by editors to share their highlight data. For example, an outliner may attach its selected list to one of these objects, and a graph editor may use the same object as a list source. Then, the graph editor would only display objects that are selected in the outliner. Selection connections are UI objects which contain a list of model objects. Selection connections are useful for specifying which objects are to be displayed within a particular editor. Editor’s have three plug socketswhere a selection connection may be attached. They are: mainListConnectionan inputsocket which contains a list of objects that are to be displayed within the editorselectionConnectionan outputsocket which contains a list of objects that are selectedwithin the editorhighlightConnectionan inputsocket which contains a list of objects that are to be highlightedwithin the editorThere are several different types of selection connections that may be created. They include: activeLista selection connection which contains a list of everything in the model which is active (which includes geometry objects and keys)modelLista selection connection which contains a list of all the geometry (i.e. excluding keys) objects that are currently activekeyframeLista selection connection which contains a list of all the keys that are currently activeworldLista selection connection which contains a list of all the objects in the worldobjectLista selection connection which contains one model object (which may be a set)listLista selection connection which contains a list of selection connectionseditorLista selection connection which contains a list of objects that are attached to the mainListConnection of the specified editorsetLista selection connection which contains a list of all the sets in the worldcharacterLista selection connection which contains a list of all the characters in the worldhighlightLista selection connection which contains a list of objects to be highlighted in some fashionBelow is an example selectionConnection network between two editors. Editor 1 is setup to display objects on the activeList. Editor 2 is setup to display objects which are selected within Editor 1, and objects that are selected in Editor 2 are highlighted within Editor 1: – Editor 1– – Editor 2– inputList–| main | | |-| main | | | | sele |–| | | sele |–| |-| high | | | high | | | | ————- ————- | |————- fromEditor2 ————-| The following commands will establish this network: selectionConnection -activeList inputList; selectionConnection fromEditor1; selectionConnection fromEditor2; editor -edit -mainListConnection inputList Editor1; editor -edit -selectionConnection fromEditor1 Editor1; editor -edit -mainListConnection fromEditor1 Editor2; editor -edit -selectionConnection fromEditor2 Editor2; editor -edit -highlightConnection fromEditor2 Editor1; Note: to delete a selection connectionuse the deleteUI commandNote: commands which expect objects may be given a selection connection instead, and the command will operate upon the objects wrapped by the selection connectionNote: the graph editor and the dope sheet are the only editors which can use the editor connection to the highlightConnection of another editorWARNING: some flag combinations may not behave as you expect. The command is really intended for internal use for managing the outliner used by the various editors.
setMelGlobal
setParent This command changes the default parent to be the specified parent.
setUITemplate This command sets the current(default) command template for the ELF commands. The special name NONE can be used to set no templates current. See uiTemplatecommand also.
stackTrace Flags:
stringArrayIntersector The stringArrayIntersector command creates and edits an object which is able to efficiently intersect large string arrays. The intersector object maintains a sense of the intersection so far, and updates the intersection when new string arrays are provided using the -i/intersect flag. Note that the string intersector object may be deleted using the deleteUI command.
uiTemplate This command creates a new command template object.
waitCursor This command sets/resets a wait cursor for the entire Maya application. This works as a stack, such that for each waitCursor -state oncommand executed there should be a matching waitCursor -state offcommand pending. Warning:If a script fails that has turned the wait cursor on, the wait cursor may be left on. You need to turn it off manually from the command line by entering and executing the command ‘waitCursor -state off’.

Classes

Catch Reproduces the behavior of the mel command of the same name.
Env A Singleton class to represent Maya current optionVars and settings
Mel This class is a convenience for calling mel scripts from python, but if you are like me, you’ll quickly find that it is a necessity.
MelGlobals A dictionary-like class for getting and setting global variables between mel and python.
OptionVarDict A singleton dictionary-like class for accessing and modifying optionVars.
OptionVarList

Exceptions

class MelArgumentError

Bases: pymel.core.language.MelError, exceptions.TypeError

The arguments passed to the MEL script are incorrect

args
message
exception message
class MelConversionError

Bases: pymel.core.language.MelError, exceptions.TypeError

MEL cannot process a conversion or cast between data types

args
message
exception message
class MelError

Bases: exceptions.RuntimeError

Generic MEL error

args
message
exception message
class MelSyntaxError

Bases: pymel.core.language.MelError, exceptions.SyntaxError

The MEL script has a syntactical error

args
filename
exception filename
lineno
exception lineno
message
exception message
msg
exception msg
offset
exception offset
print_file_and_line
exception print_file_and_line
text
exception text
class MelUnknownProcedureError

Bases: pymel.core.language.MelError, exceptions.NameError

The called MEL procedure does not exist or has not been sourced

args
message
exception message

Table Of Contents

Commands

Modules

This Page