import sys import re import pymel.util as _util import pymel.internal.pmcmds as cmds import pymel.internal.factories as _factories import pymel.internal.startup as _startup import pymel.internal as _internal import pymel.versions as _versions import maya.mel as _mm _logger = _internal.getLogger(__name__) def _resolveUIFunc(name): if isinstance(name, basestring): import windows try: return getattr(windows, name) except AttributeError: try: cls = getattr(dynModule, name) return cls.__melcmd__() except (KeyError, AttributeError): pass else: import inspect if inspect.isfunction(name): return name elif inspect.isclass(name) and issubclass(name, PyUI): name.__melcmd__() raise ValueError, "%r is not a known ui type" % name
""" import melparse try: from pymel.util.external.ply.lex import LexError except ImportError: from ply.lex import LexError import pymel.util as util import pymel.internal as internal import pymel.internal.factories as _factories import pymel import pymel.core as pm import os log = internal.getLogger(__name__) """ This is a dictionary for custom remappings of mel procedures into python functions, classes, etc. If you are like me you probably have a library of helper mel scripts to make your life a bit easier. you will probably find that python has a built-in equivalent for many of these. i've provided a few entries as examples to show you how to implement remappings in mel2py. the first procedure in the dictionary is 'firstElem', which simply returns the first element of a string array, useful when the first element of a command is all you need. as you can see, the key in the dictionary is the procedure name, and the value is a function which takes two inputs: a list of arguments to the procedure being remapped, and a ply yacc token object, which you probably will not need to use. the function should return a string representing the new command. also, note that the list of arguments will all be strings and will already be converted into their python equivalents. in the case of 'firstElem', it will perform conversions like the following: firstElem( ls(sl=1) ) --> ls(sl=1)[0] firstElem( myListVar ) --> myListVar[0]
import sys, re import pymel.util as _util import pymel.internal.pmcmds as cmds import pymel.internal.factories as _factories import pymel.internal as _internal import pymel.versions as _versions import maya.mel as _mm _logger = _internal.getLogger(__name__) def _resolveUIFunc(name): if isinstance(name, basestring): import windows try: return getattr(windows, name) except AttributeError: try: cls = getattr(dynModule, name) return cls.__melcmd__() except (KeyError, AttributeError): pass else: import inspect if inspect.isfunction(name): return name elif inspect.isclass(name) and issubclass(name, PyUI): name.__melcmd__() raise ValueError, "%r is not a known ui type" % name
""" from melparse import * try: from pymel.util.external.ply.lex import LexError except ImportError: from ply.lex import LexError import pymel.util as util import pymel.internal as internal import pymel.internal.factories as _factories import pymel import os log = internal.getLogger(__name__) """ This is a dictionary for custom remappings of mel procedures into python functions, classes, etc. If you are like me you probably have a library of helper mel scripts to make your life a bit easier. you will probably find that python has a built-in equivalent for many of these. i've provided a few entries as examples to show you how to implement remappings in mel2py. the first procedure in the dictionary is 'firstElem', which simply returns the first element of a string array, useful when the first element of a command is all you need. as you can see, the key in the dictionary is the procedure name, and the value is a function which takes two inputs: a list of arguments to the procedure being remapped, and a ply yacc token object, which you probably will not need to use. the function should return a string representing the new command. also, note that the list of arguments will all be strings and will already be converted into their python equivalents. in the case of 'firstElem', it will perform conversions like the following: firstElem( ls(sl=1) ) --> ls(sl=1)[0]