pymel.core.language.getMelType

getMelType(pyObj, exactOnly=True, allowBool=False, allowMatrix=False)

return the name of the closest MEL type equivalent for the given python object. MEL has no true boolean or matrix types, but it often reserves special treatment for them in other ways. To control the handling of these types, use allowBool and allowMatrix. For python iterables, the first element in the array is used to determine the type. for empty lists, ‘string[]’ is returned.

>>> from pymel.all import *
>>> getMelType( 1 )
'int'
>>> p = SCENE.persp
>>> getMelType( p.translate.get() )
'vector'
>>> getMelType( datatypes.Matrix )
'int[]'
>>> getMelType( datatypes.Matrix, allowMatrix=True )
'matrix'
>>> getMelType( True )
'int'
>>> getMelType( True, allowBool=True)
'bool'
>>> # make a dummy class
>>> class MyClass(object): pass
>>> getMelType( MyClass ) # returns None
>>> getMelType( MyClass, exactOnly=False )
'MyClass'
Parameters :
pyObj

can be either a class or an instance.

exactOnly : bool

If True and no suitable MEL analog can be found, the function will return None. If False, types which do not have an exact mel analog will return the python type name as a string

allowBool : bool

if True and a bool type is passed, ‘bool’ will be returned. otherwise ‘int’.

allowMatrix : bool

if True and a Matrix type is passed, ‘matrix’ will be returned. otherwise ‘int[]’.

Return type:

str

Previous topic

pymel.core.language.getMelGlobal

Next topic

pymel.core.language.getProcArguments

Core

Core Modules

Other Modules

This Page