On 04/04/2016 at 09:25, xxxxxxxx wrote:
Hi,
first I'd like to say, we are aware of the lack of guidance in the SDK documentation. Sorry, for the inconvenience. We are working on it.
Then I'd like to add some details here:
Robert already demonstrated the creation of an "undo" (I mean, a point something can be undone to) as it is most commonly done in CommandData plugins.
In the background C4D makes a copy of the object passed in AddUndo() (very simplified and only really true for UNDOTYPE_CHANGE). And when the user calls Undo, then this copy will be copied back into the original object.
This already explains, that you don't see any SetDParameter() calls in this process. And it should make clear, that only one AddUndo() is needed for multiple parameter changes on the same object.
For a NodeData derived plugin, you don't have to worry about this, as long as you store all your data in the BaseContainer of the node. In case you have not, you will need to provide a proper CopyTo() implementation (basically copying everything that's not stored in the BaseContainer), so the undo mechanism can work properly.
The surrounding StartUndo()/EndUndo() calls provide the means to group several changes into one single undo step for user convenience.
Just for completeness (and probably of little use in your case), there's also MSG_DOCUMENTINFO_TYPE_UNDO (subtype of MSG_DOCUMENTINFO), which can be used to detect, if the user calls undo.