RhinoObject Replace (CustomObject)

Hello everyone,

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());
    }

Hi @Federico_Borello,

Can you put together a simple example, that we can run here, that repeat the issue you are seeing?

Thanks,

– Dale

Hi @dale ,

I attached here a .rar with the sample I’m working on (Rhino and GH file, my compiled .dll and the classes as separate c# files)

Many thanks for your help,
Federico

Sample.rar (106.3 KB)

HI @dale @stevebaer,

did you have chance to look at this issue?

I keep having the some duplication issue as well as the CustomObject disappearing after duplication.
Any help would be appreciated.

Many thanks,
Federico

Hi @Federico_Borello,

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?

Thanks,

– Dale


ENCORE_Debug.rar (18.1 MB)

Hi Dale,

first thanks for taking the time to have a look.

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.

Many thanks in advance.
Federico