User Data Objects on Trims and Surfaces

Hi Community,

I am trying to add some user data objects (which are derived from UserData) to
surfaces and to trims. But by saving the file the ShouldWrite is not executed
for the user data objects which are laying on the trims, but it works properly
for the surfaces.
Also if I try to edit some points of my surface the user data
method onDuplicate is not performed and all the user data is lost. That happens for both, the trims
and the surfaces. Is there a way to manually enforce the run of those
methods or to overcome this problem?
I am using Rhino Common with C#.


Hi Tobi,

When attaching user data (of any kind) to Brep components, if you want the data to persist, then attach the data to the underlying geometry, not the topology.

For example, instead of attaching user data to BrepTrim, you’d want to attach it to the trim’s underlying 2D curve instead. Unfortunately, I don’t see a way to get there - I would expect BrepTrim to have a member that returned the index of the underlying 2D curve. I’ve added a request for this to the pile.

– Dale

Hi Dale, thanks for your help!
I tried so, now by safing the document the ShouldWrite is performed for the curves, too.
But still if I modify something on the element (trimming, moving of one point, etc. ) I always lose all user data objects. Is there a way to overcome this problem? I would expect that the OnDuplicate function would be performed, but it is just performed for simple movements of the entire Brep.


Attaching user data to Brep components can be somewhat tricky. Here is an example you can reference.

Why do you need to duplicate the Brep here? Is it not suficient to add the userdata object directly on the existing elements of the old Brep?