RhinoObject/Geometry/Attributes, 3 UserData

Hello,

I would like to understand and know when to use UserDataList rather than another ?

RhinoObject.UserData
RhinoObject.Geometry.UserData
RhinoObject.Attributes.UserData

What is the purpose of each ?

Can UserData be shared between multiple objects, geometries, attributes ?

RhinoObject.UserData.ShouldWrite/Read/Write seems never to be called and data is not written to file, Is this normal ?

thank you, jmv.

Hi @kitjmv,

Some background:

RhinoObject.UserData

This is only here because of class inheritance and should not be used.

RhinoObject.Geometry.UserData

This is user data stored on an object’s geometry.

RhinoObject.Attributes.UserData

This is user data stored on an object’s attributes. Generally, this is the best place to store user data.

Two objects cannot reference the same user data object.

– Dale

1 Like

Hello Dale,
So there are only two UserData to differentiate between RhinoObject.Geometry.UserData and RhinoObject.Attributes.UserData

I’ll do some testing to see if there’s a difference between the two when I have time (event calls for example).
But could you tell me why attributes are the best place to store user data. ?
Thank you, jmv.

Attribute user data tends to survive better, during a general modeling session, than geometry user data. I don’t have any data to back this up - just my observation.

– Dale

3 Likes

Hey @dale,

I would like to get back to this. This is not completely clear to me. Why would you store UserData (same class object 3 times on an object) in a class like RhinoObject?
RhinoObject inherits from ModelComponent, right? ModelComponent has a property UserData, so does RhinoObject as inherit class. Now RhinoObject also stores UserData on the geometry and the attributes, always the same class? Why? And why would they survive or not? Could you please give me some more insights. Would be great.

Kindest
Christian

Hi @Christian_Hartz1,

I don’t understand - I’d certainly never do this.

Yep. But RhinoObject is a runtime object - it is never serialized. It’s data members (Geometry and Attributes) are serialized, however.

This really depends on the command or operation. Some commands completely trash the geometry and return something else. End the end, the attributes tend to survive, which is why commands that trash geometry end up putting the new results back on the same layer as the original.

Anyway, you might just have to take my word for it. Unless you’ve got a special requirement, store your user data on the object’s attributes.

– Dale

1 Like

Hey @dale,

thank you once again for your quick reply.

I was not clear on that - the question is: Why does UserData exists 3 times on RhinoObject, which comes along with the question - where to store.

But your explanation shed some light. We are using RhinoObject.Geometry.UserData right now and it seems to work, but I will change to RhinoObject.Attributes.UserData.

Thanks and Kindest
Christian