This is a pretty cool solution! The only problem I get, is a barrage of the following error everytime I run it from a fresh Maya. I am parsing a command list (nothing too harsh, just simply Mel statements recorded earlier. But with a fresh maya, it seems I always get the following error running the following solution - - -
# File "<maya console>", line 4, in <module> # File "<maya console>", line 11, in validateMelCommand # RuntimeError: There are no more commands to undo. On Fri, Aug 28, 2009 at 8:25 PM, Chad Dombrova <[email protected]> wrote: > not sure how robust this is, but it seems to work: > > import maya.cmds as cmds > import maya.mel as mel > def isValidMelCmd( cmdStr ): > undoState = cmds.undoInfo(q=1, state=1) > cmds.undoInfo(state=1) > isValid = None > try: > mel.eval(cmdStr) > except: > isValid = False > else: > isValid = True > cmds.undo() > finally: > cmds.undoInfo(state=undoState) > return isValid > > isValidMelCmd( "setAttr persp.tx 2" ) > # Result: True # > isValidMelCmd( "3etAttr persp.tx 2" ) > # Result: False # > > if you wanted to make it work for python statements, it wouldn't be hard. > just use eval instead of mel.eval > > -chad > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
