Hello everyone,
From what I have read this appears to be a great place to discuss the Maya API.
I normally wouldn't bother anybody with my questions, but I have searched high
and low and cannot seem to find the answer. Maybe someone will know this offhand...
Sorry this is a long one but I like to be detailed. =)
I have a very simple plug-in derived from MPxCommand.
It's only purpose is to generate a mesh from pre-existing data loaded by a different plug-in.
The structure of the plug-in is as follows :
doIt()
{
simply parses arguments (none right now)
then does the actual work
return redoIt();
}
redoIt()
{
creates a new transform node using MFnTransfom.create()
records the object hande of my new transform as a class member
Uses the function MFnMesh.create() to generate a new mesh parented under the above transform
// I plan to use a MDGModifier to create a shading network via MEL once I have squashed this bug
}
undoIt()
{
I use a MDGModifier coupled with a recursive function to delete the root transform I saved + any children
return MDGModifier.doIt();
}
Well the good news is that the plug-in works wonderfully despite one very annoying condition.
I can call the plug-in as many times as I want, creating geometry and translating/editing said geometry.
I can even UNDO all the way back to my very first command call!
Here is the problem... redo works UNTIL it hits one of my command calls.
The strange thing is, Redo actually performs correctly on my command ONE TIME!
The problem is any further attempt to redo ANYTHING from that point on...
Will give me the error "Error: There are no more commands to redo."
It's like my redo code decided to do it's job and flush the REDO stack.
I know the MDGModifier is handy with undo and redo, however I don't see how I can utilize it to create geometry with
MFnMesh... That is why I manually track and destroy my nodes in undo.
I am at a loss... what am I missing? I simply destroyed the nodes that I created...
Is the undo chain embedded in the nodes that I created? Is that why deleting them broke my redo?
I can't find documentation on this anywhere...
I know that shape modifying tools use the whole inMesh outMesh system for their construction history.
I didn't think brand new meshes required that... was I wrong?
I noticed that the basic shape(cube,plane,sphere, etc) commands in Maya do not have this problem.
What could they be doing differently? I would very much like to peek in and see... unfortunately that is impossible.
I thought It might be a Selection related problem, so I saved and restored selection states respectively. Alas that did absolutely nothing besides making my command a bit more user friendly by auto selecting the generated meshes.
If anyone has a clue as to what this might be, please do not hesitate to respond.
A HUGE thank you in advance to anyone who is willing to take the time to read this.