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)
classmethod MelGlobals.initVar(type, 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 = {}

Previous topic

pymel.core.language.Mel

Next topic

pymel.core.language.OptionVarDict

Core

Core Modules

Other Modules

This Page