pymel.core.language.MelGlobals

Inheritance diagram of MelGlobals

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 = {}