View Full Version : [API] MPxCommand undoIt() doesn't get called

02 February 2011, 02:54 PM

I'm trying to implement an undo function to my api command. But the undoIt() function doesn't get called when I undo in maya. Nothing is added to maya's undo queue.

Any pointers would be great :)


My header looks like this:
class testCmd : public MPxCommand
virtual ~testCmd();
static void* creator();
bool isUndoable() const;

MStatus doIt(const MArgList&);
MStatus redoIt();
MStatus undoIt();

and I have implemented the following in the .cpp file:

bool testCmd::isUndoable() const
return true;

MStatus testCmd::undoIt()
MGlobal::displayInfo ( "undo" );
return MS::kSuccess;

02 February 2011, 04:30 PM
That code looks like it should work. Is your doIt returning kSuccess? If not, it won't get logged. That's the only other reason I can think of. Also double check the definition your method overrides to make sure they're exactly right. I think they are.

02 February 2011, 05:20 PM
doit() wasnt returning kSuccess.. it is now. and undo works :)


CGTalk Moderation
02 February 2011, 05:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.