pymel.core.language.MelGlobals

digraph inheritance5502590ccd { rankdir=TB; ranksep=0.15; nodesep=0.15; size="8.0, 12.0"; "Container" [shape=box,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=8,style="setlinewidth(0.5)",height=0.25]; "Iterable" [shape=box,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=8,style="setlinewidth(0.5)",height=0.25]; "Mapping" [shape=box,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=8,style="setlinewidth(0.5)",height=0.25]; "Sized" -> "Mapping" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Iterable" -> "Mapping" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Container" -> "Mapping" [arrowsize=0.5,style="setlinewidth(0.5)"]; "MelGlobals" [fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",URL="#pymel.core.language.MelGlobals",style="setlinewidth(0.5)",tooltip="A dictionary-like class for getting and setting global variables between mel and python.",height=0.25,shape=box,fontsize=8]; "MutableMapping" -> "MelGlobals" [arrowsize=0.5,style="setlinewidth(0.5)"]; "MutableMapping" [shape=box,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=8,style="setlinewidth(0.5)",height=0.25]; "Mapping" -> "MutableMapping" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Sized" [shape=box,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=8,style="setlinewidth(0.5)",height=0.25]; }

class MelGlobals

A dictionary-like class for getting and setting global variables between mel and python.

An instance of the class is created by default in the pymel namespace as melGlobals.

To retrieve existing global variables, just use the name as a key:

>>> melGlobals['gResourceFileList'] 
[u'defaultRunTimeCommands.res.mel', u'localizedPanelLabel.res.mel', ...]
>>> # works with or without $
>>> melGlobals['gFilterUIDefaultAttributeFilterList']  
[u'DefaultHiddenAttributesFilter', u'animCurveFilter', ..., u'publishedFilter']

Creating new variables requires the use of the initVar function to specify the type:

>>> melGlobals.initVar('string', 'gMyStrVar')
'$gMyStrVar'
>>> melGlobals['gMyStrVar'] = 'fooey'

The variable will now be accessible within MEL as a global string.

class MelGlobalArray(type, variable, *args, **kwargs)
append(val)
extend(val)
setItem(index, value)
MelGlobals.VALID_TYPES = ['string', 'string[]', 'int', 'int[]', 'float', 'float[]', 'vector', 'vector[]']
classmethod MelGlobals.get(variable, type=None)

get a MEL global variable. If the type is not specified, the mel whatIs command will be used to determine it.

classmethod MelGlobals.getType(variable)

Get the type of a global MEL variable

MelGlobals.get_dict(variable, default=None)
classmethod MelGlobals.initVar(type, variable)

Initialize a new global MEL variable

classmethod MelGlobals.keys()

list all global variables

MelGlobals.melTypeToPythonType = {'int': <type 'int'>, 'float': <type 'float'>, 'string': <type 'str'>, 'vector': <class 'pymel.core.datatypes.Vector'>}
classmethod MelGlobals.set(variable, value, type=None)

set a mel global variable

MelGlobals.typeMap = {}