Maya API

OK, so I’m working on a tool that utilizes a script job that runs when certain objects are selected.
The problem with this is when Undoing, you run into a cycle where you, during an undo, reselect the object and the script runs again. This prevents undos and so I am working out a way around this.

Now the particular piece of API that allows me to accomplish this is MGlobal.isUndoing. This will determine whether the selection is happening because of an Undo and will allow me to write around the error. Here is my problem

In python this would be a simple matter of importing Mglobal.
Import maya.MGlobal as MGlobal
int Obj = MGlobal.isUndoing()

I am however working in Mel because my script is embedded in a maya script node and I have no idea how to get a hold of the Class to use. Anyone have any info on how to work with Maya API outside of pymel or python API?

You can try calling the python commands from mel with the “python” command. So something like this might do the trick:


python( "import maya.OpenMaya as OM");
int $isUndoing = python( "OM.MGlobal.isUndoing()" );

very good call. It appears to be doing what I was wanting it to do, I will implement in immediately to see if it functions. Big thanks!

Now that the problem is averted, I still would like to know if it is even possible to access maya’s API libraries without using python (I know you can build a plugin and compile it etc, but without doing that or using python)

Very big thanks for that response