Hi,
I am developing a Rhinocommon.dll 5.14 and Rhinocommon.dll 7.5 .Net 4.8 plugin in Windows 10 using the geometries contained in the RhinoDoc.ActiveDoc.
I reproduced the issues reported as 1’ and 2’ on Rhino 5.14. On Rhino 7.5, 2’ seems to work correctly.
3’ is only a feature explanation.
1’
With the sequence
- a1 start an undo block from an UI event outside a command
- b1 call RhinoObject.GeometryBase.SetUserString(“test1Key”, “test1Value”) on an existing RhinoObject inside the document retrieving it with the RhinoDoc.Objects.FindById (obtaining a Rhino.DocObjects.PolyCurve from a Guid)
- c1 change the color of the object blocking the display using the colorsource.ColorSourceFromObject
- d1 close the undo block keeping a1/b1/c1/d1 executed synchronously in the same stack started by a1
- a2 start an undo block from a UI event outside a command
- b2 call RhinoObject.GeometryBase.SetUSerString(“test1Key”, “”) on an existing RhinoObject inside the document (a polycurve)
- c2 change the color of the object blocking the display using the colorsource.ColorSourceFromObject
- d2 close the undo block
If I try to redo running the RhinoScript “Undo”, the color changes with the setting associated to the undo block, but the KeyValuePair string does not reappear as setted in b1
If I enclose a/b/c/d in a command and access the RhinoDoc from the command parameter instead of the static pointer Rhino.RhinoDoc.ActiveDoc, I reproduce the same problem
If I traslate the geometry for example (100,0,0) and then (-100,0,0) before setting the user string, the userstring is handled correctly by the Rhinoceros UndoRedo manager, as in
id1 = BeginUndoRecord()
rhinoObject.Geometry.Transform(Rhino.Geometry.Transform.Translation(new Vector3d(100, 0, 0))); *
rhinoObject.Geometry.Transform(Rhino.Geometry.Transform.Translation(new Vector3d(-100, 0, 0))); *
rhinoObject.Geometry.SetUserString(key, value);
rhinoObject.Attributes.ObjectColor = oColor;
rhinoObject.Attributes.ColorSource = objectColorSource;
rhinoObject.Attributes.PlotColor = oColor;
rhinoObject.Attributes.PlotColorSource = objectPlotColorSource;
rhinoObject.CommitChanges();
EndUndoRecord(id1)
If I
a’ move the object from Rhinoceros Viewport UI
b’ set the string without applying a tranform as workaround (creating an undo block as reported above)
c’ move the object from Rhinoceros Viewport UI
d’ try to redo all the steps
the string sent in b’ is committed in the undo redo queue by c’: when I undo to b’ I find the string, but also when I undo to the first move a’ before setting the string.
Is there a way to avoid the dummy geometry change * in rhino5.14 and rhino7.5 to allow the undo redo on ‘rhinoObject.Geometry.SetUserString(key, value)’ ?
2’
If I import a 3dm with RhinoCommon.dll as in
var fro = new Rhino.FileIO.FileReadOptions();
fro.ScaleGeometry = false;
fro.BatchMode = true;
fro.NewMode = true;
Rhino.RhinoDoc.ReadFile(fullpath, fro);
and then try to use the undo redo feature, the undo from the script “_-Undo” does not happen.
If I import the 3dm as in
var script1 = “_-New None";
var script2 = "-Import " + fullpath + " _Enter”;
rc = true;
rhinoDocIn.Modified = false;
if (rc)
rc = Rhino.RhinoApp.RunScript(script1, true);
if (rc)
rc = Rhino.RhinoApp.RunScript(script2, true);
rhinoDocIn.Modified = false;
the undo redo feature works correctly.
On rhino7.5, also Rhino.RhinoDoc.ReadFile(fullpath, fro) works correctly
On rhino5.14 am I missing something?
3’
With the sequence
- a add an event handler to Rhino.Command.UndoRedo
- b create 5 undoredo blocks, receiving correctly 5 increments of UndoRedoEventArgs.UndoSerialNumber declaring the undoredo blocks just created.
- c call “Undo” script, receiving from Rhino.Command.UndoRedo a new UndoRedoEventArgs.UndoSerialNumber for the undo script treated as a new command and inside the events of the undo block recovered with UndoRedoEventArgs.UndoSerialNumber corresponding to the fourth block recovered
If I embed in the user RhinoDoc a RhinoObject with a userstring that holds the id given by RhinoApp.BeginUndoRecord, on the undo and redo operations I retrieve the original id that was declared from Rhinocommon on the creation of the undoredo block.
Is it possible to disable the creation of a new UndoRedoEventArgs.UndoSerialNumber when I recall a previous undoredo block with the scripts “Undo” and “Redo”?
Or being able to recover the original UndoSerialNumber after executing multiple undo and redo?
If not, I have to measure the sequence of the 4 callbacks declaring a recalled undoredo block and recall the dataentry history in the plugin I am developing.