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)