I’m working on a series of Rhino CustomObjects with custom UserData attached.
My custom object class has a OnDataUpdated event method which should replace the current object geometry with the a new one with a new set of input parameters.
The method below works fine the first 2/3 times replacing correctly the geometry then starts duplicating it; somehow seems like the ObjRef is not getting deleted/replaced after few iterations.
Any idea why that happens?
internal override void OnDataUpdated(object sender, EventArgs e)
{
var data = sender as nBeam;
var doc = RhinoDoc.ActiveDoc;
doc.Objects.Replace(new ObjRef(this), data.Create());
}
Sorry, for the delay on this. When you first posted the zip file, I was confused what the DLL was (Rhino plug-in, Grasshopper plug-in). And since there wasn’t a project that I could build and run, I got distracted.
Anyway, I can see you have several classes. And at first glance all looks good. What I need is a way to repeat what you are seeing - in a debugging session preferred. Can you give me step by step instruction on how I can do this?
I recorded a short video which shows the process and the current two issues:
I create an nBeamObject (CustomBrepObject) on a curve
I update the nBeamObject properties and replace the prior object with the new updated one
Issue 1:
After 3 update cycles it starts duplicating with a non CustomBrepObject and keeps duplicating exponentially, looks like is not delete the reference in the active doc.
Issue 2:
When the CustomBrepObject is transformed or copied, it remains selectable but disappears.
I attached also the solution with a Debug session to be able to replicate.