I’m revisiting how I use the undo stack for my Extension and am twisting in knots a bit..
I have a bunch of settings for my extension. Global ones I can stores with Sketchup.write_default - but there are also model-specific settings. I’ve always just added them to a dictionary in the model. The problem is that generates an undo operation which really isn’t what I want. I’m just setting up default settings for the model - “undo-ing” the default settings is meaningless..
If the setting is driven by the user, then it makes a lot of sense to make it explicit and have an Undo / Redo (the issue is not just the Undo stack, but the fact that the model is modified). At least this makes it clear to user that something is saved in the model.
This means that you must read the parameters from the model, because if you store it in variables, you may be out of sync in case of Undo (or Revert model).
I seldomly do a start operation in Append mode. Not ideal however, but I only do it for a few settings like MRU list or last selection in a list, which do not really matter as data or plugin parameters, but which are convenient for the user to retrieve when he goes back to the model.
Just to report back. I ended up reworking the LightUp preferences to use a Defaults dictionary so that asking for a preference that has yet to be set, gets the default else what was set by the user.
It means a freshly loaded model is not altered and shows no Undo ops.