Objects.Replace(obj, _profile); breaks history?


#1

Hi,
So I have a command that puts a curve into the document with history added to it:

HistoryRecord history = new HistoryRecord(this, History_Version);
…(add some history to historyRecord)
obj = RhinoDoc.ActiveDoc.Objects.AddCurve(_profile, null, history, false);

(background info: this _profile is sitting on another curve, and I am using history so that if the base curve is moved this curve moves with it.)

So then later we re-run this command and edit the shape of this _profile curve, and now want to replace the curve we added above using:

RhinoDoc.ActiveDoc.Objects.Replace(obj, _profile);

This Replace appears to drop the history, I think Rhino even tells you that you are about to break history.

(I do not want to delete and re-add this _profile, as this breaks any history attached to this _profile curve. For example we sweep a surface using this _profile as one of the profiles to sweep. If I delete and add the profile then the history of the sweep is broken.)

So I am looking for something like:
RhinoDoc.ActiveDoc.Objects.Replace(obj, _profile) that keep the history.
or some way to re-add the history back to this replaced object. (either way would work?)

If you need any more info, I could probably make a simple demo plugin, to show the full problem.

Thanks

GordonJ.


(Dale Fugier) #2

Hi Gordon,

Here is a simple, sample Sweep1 command that supports history.

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsSweep1.cs

With this, I can rebuild the shape curve, move its control points, etc., all that call Objects.Replace without breaking history.

If this doesn’t help, I might need an example from you…