[RhinoCommon] CustomMeshObject - how to use RecordHistory?


(Menno Deij - van Rijswijk) #1

We use a CustomMeshObject in our plug-ins. I have tried to add instances of this class with a HistoryRecord to the RhinoDoc, but have not succeeded in finding out how to do this.

Typically, we add the custom object like this:

Mesh m; // defined elsewhere
MyCustomMeshObject o = new MyCustomMeshObject(m);
doc.Objects.AddRhinoObject(o);
Guid g = o.Id;

But: RhinoDoc.AddRhinoObject has no signature that also supports adding a HistoryRecord.

I’ve tried the approach below, but replacing the mesh with the custom mesh object breaks the history immediately.

HistoryRecord h = new HistoryRecord(this, 1);
WriteHistory(h);

Guid g = doc.Objects.AddMesh(m, null, h, false);
RhinoObject obj = doc.Objects.Find(g);
            
MyCustomMeshObject o = new MyCustomMeshObject(obj.Geometry as Mesh);
doc.Objects.Replace(new ObjRef(obj), o); // this breaks the history defined above

@dale or @stevebaer, do you have any hints on how to support history with custom objects?


(Dale Fugier) #2

I am not seeing a way to add a HistoryRecord to a custom object. Clearly there should be an override to doc.AddRhinoObject where you could pass a HistoryRecord object.

I’ve addded this feature to the RhinoCommon wish list. If we ever make the list public, you can see your item here.

http://mcneel.myjetbrains.com/youtrack/issue/RH-22907


(Menno Deij - van Rijswijk) #3

Ok. I am not familiar with the C++ SDK, but can this be achieved in that environment?


(Dale Fugier) #4

Yes it can.


(Menno Deij - van Rijswijk) #5

If this is going to be implemented in RhinoCommon, functionality for CustomObjects should also be added to ReplayHistory. Specifically to

replayData.Result[0].UpdateTo[...]

Currently, only standard geometry is allowed in the Update statements. So, even though I succeeded in setting a history record on my custom object by some excursion to C++ from C#, replay history is only capable to update as a mesh, not a custom mesh.

It would be nice to have this functionality in an upcoming SR, if possible.


(Brian Gillespie) #6

RH-22907 is fixed in the latest Rhino 6 Service Release Candidate


#7

Hi,

I’m having problems using the method recently implemented: [RhinoCommon] AddRhinoObject HistoryRecord

Regards,


(Brian Gillespie) #8

RH-43591 is fixed in the latest Service Release Candidate