protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode) { // Rhino automatically sets up an undo record when a command is run, // but... the undo record is not saved if nothing changes in the // document (objects added/deleted, layers changed,...) // // If we have a command that doesn't change things in the document, // but we want to have our own custom undo called then we need to do // a little extra work double d = MyFavoriteNumber; if (Rhino.Input.RhinoGet.GetNumber("Favorite number", true, ref d) == Rhino.Commands.Result.Success) { double current_value = MyFavoriteNumber; doc.AddCustomUndoEvent("Favorite Number", OnUndoFavoriteNumber, current_value); MyFavoriteNumber = d; } return Rhino.Commands.Result.Success; }
protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode) { // Rhino automatically sets up an undo record when a command is run, // but... the undo record is not saved if nothing changes in the // document (objects added/deleted, layers changed,...) // // If we have a command that doesn't change things in the document, // but we want to have our own custom undo called then we need to do // a little extra work double d = MyFavoriteNumber; if (Rhino.Input.RhinoGet.GetNumber("Favorite number", true, ref d) == Rhino.Commands.Result.Success) { double current_value = MyFavoriteNumber; doc.AddCustomUndoEvent("Favorite Number", OnUndoFavoriteNumber, current_value); MyFavoriteNumber = d; } return(Rhino.Commands.Result.Success); }