undo a command (scripting)

 From:  Michael Gibson
10939.10 In reply to 10939.9 
Hi Peer,

re:
> But, I'm still not sure how to get an undo unit when changing object visibility, lock state, or selection state.

There isn't currently any facility exposed for a script command to generate this kind of undo.

Normally in MoI this type of object property manipulation is not done in a dedicated command because it can also be useful to be able to perform them while still running inside of a command.


> What happens when I click on the Visible.png icon in the browser?

The function SceneBrowserItem::OnStatusClick() is called, which among other things calls the internal C++ functions:

SaveSelectionUndo();

AlterStatus( ... );

SetSelectionUndoRevision();


> What gets called when I do selection using the scene browser or object properties dialog?

When you do selection using the scene browser, SceneBrowserItem::OnSelectionClick() is called which among other things calls:

SaveSelectionUndo();

Selects stuff...

SetSelectionUndoRevision();


When you do it selection by clicking on a label in the object properties dialog, detailedFilterClicked() is called which among other things calls:

SaveSelectionUndo();

... Manipulates selection ....

SetSelectionUndoRevision();


So what you need to do for having a selection undo is to call SaveSelectionUndo() first, then after all changes to hidden/locked/selected have been done SetSelectionUndoRevision() needs to be called to establish which geometry revision number the selection undo is tired to.

Selection undo doesn't actually generate a normal undo unit that goes in the undo stack, it's a special case in undo where before processing anything from the regular undo stack it checks if there is a stored selection undo available that matches the current database revision number and if there is restores that instead of performing the regular undo.

I'll set up script access to SaveSelectionUndo()/SetSelectionUndoRevision() off of geometryDatabase so it will be possible for you to use it too.

- Michael