PDA

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


Jacobborsting
02-15-2011, 01:54 PM
Hi

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 :)

Thanks,

My header looks like this:
class testCmd : public MPxCommand
{
public:
testCmd();
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;
}

Keilun
02-15-2011, 03: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.

Jacobborsting
02-15-2011, 04:20 PM
doit() wasnt returning kSuccess.. it is now. and undo works :)

Thanks.

CGTalk Moderation
02-15-2011, 04: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.