Unable to Undo Document Changes Made Through Eto Form

Hi, I am trying to make a Rhino Plug-in using Eto. I just found that I am not able to undo the document changes made through Eto.Forms.Button. Can anyone please let me know why this is happening? Thank you in advance!

Here is the code:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
    Eto.Forms.Form form = new Eto.Forms.Form();
    Eto.Forms.Button button = new Eto.Forms.Button
    {
        Text = "Run Script",
    };
    button.Click += (sender, e) => doc.Objects.Add(new Point3d(1,2,3));
    form.Content = button;
    form.Show();

    return Result.Success;
}

When I run this command and click the button, a point will be generated. However this change cannot be undone.

Inside your anonymous function you need to bracket your document modifying code with RhinoDoc.BeginUndoRecord Method and RhinoDoc.EndUndoRecord Method.

1 Like

Works like a charm! Thank you so much!

1 Like