Is there a simple way to empty the UndoRecord in Rhino? I have a command I’m creating for a plugin that needs to disable the ability to undo any previous actions. I cannot find anything in the Rhinocommon API. There is the UndoRecord class, but I do not know where I could obtain the active instance of it, if there is one.
using Rhino;
using Rhino.Commands;
using Rhino.Input;
namespace TestCs7
{
[CommandStyle(Style.NotUndoable)]
public class TestCSykes : Command
{
public override string EnglishName => "TestCSykes";
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var rc = RhinoGet.GetCircle(out var circle);
if (rc == Result.Success)
{
doc.Objects.AddCircle(circle);
doc.Views.Redraw();
}
return Result.Success;
}
}
}
And if you just want to prevent any undo then you want to use RhinoDoc.ClearUndoRecords Method. Note though that users are probably not going to like it if suddenly their undos are impossible.
Hey @Dale, thanks for the answer, I assume this means the command itself cannot be undone, but anything that happened before the command still can be? Are commands NotUndoable by default as you have to create your own custom Undo methods usually.