Delete from Undo Multiple

Hi everyone,


I have been working with undo/redo operations connected with my plugin. I am recording some operations in plugin to manage list operations for some calculations. Some calculations are geometry related some of them not. For example, you know, there are operations like Scale, Scale1D, Scale2D, Move, and some gumball interactions to manipulate geometry. After catching manipulated geometry by RhinoDoc.ReplaceRhinoObject event, I update them. But when I want to undo/redo this reactions still there (of course there is). But I want to delete this operations on stack. I just want to plugin specific recordings. Is it possible?

I tried as below to workaround it but didn’t success.

public RhinoDoc Doc { get;} => RhinoDoc.ActiveDoc;

public void UpdatePluginObjectAfterReplacing(List<MyPluginObject> objects)
    Doc.Undo(); // tried workaround here to get rid of this Scale1D, for example
    Doc.ClearRedoRecords(); // clear redo stack to get rid of Scale1D also there

    uint sn = Doc.BeginUndoRecord("Update Reaction");
    // some operations to update geometry and objects for my plugin

Do you have any idea or best practices for these kind of undo/redo operations which are dependent to RhinoDoc.ReplaceRhinoObject event? Hope it’s clear.

Thanks in advance,

Any thoughts? :confused:

Hi @oguzhankoral,

Not really. I guess we’d need to know more details about what you are recording (and how and why of course). I’m assume you are trying to achieve a single undo record that will undo the Rhino operation and your recording at the same time?

– Dale

Hi @dale,

Yes exactly like what you said. After reactions like Scale1D, Rotate…, My plugin get values from e.NewObject from arguments of RhinoDoc.ReplaceRhinoObject. Then my plugin object recreate itself according to new values. I need to implement my plugin recording to Rhino’s implicit Scale1D recording.

I will prepare sample project for it to show you. Because as you can imagine it’s quite important future for plugins. Until this time, if you have any thoughts i will be so pleased to if you let me know.


Hi again @dale,

Finally I prepared simple and similar version of my plugin for this undo/redo issue. The process that I mention you can understand below gif.

You can debug directly in UpdateMyPluginObjectAfterReplacing method in MyPluginObjectController file. You can also change values from UI (there is a duplication causing from event registration just ignore it please, I dont have problems with UI changes). You will understand my problem when you did same reactions in gif.

Thanks in advance

Thanks @oguzhankoral. I hope to have time to look at this next week.

– Dale

Thanks @dale. Looking forward for your ideas. If I will be able to improve any approach, I will update project in GitHub by writing descriptive commit notes.