Can't save UserData with Object.UserData,Only Object.Attributes.UserData

Hi everyone, i can’t save a custom UserData in a RhinoObject.
like this.


only save at Object.Attributes, Does anyone know why?

1 Like

That’s the only reliable way, we’ve found it to work

See my post here

hi bro, I mean, isn’t it easy to get confused?

Custom User data never worked reliably for us, which is why we serialize to json and save as strong to UserDictionary instead.

Oh, maybe that’s a good solution too. Thank you

1 Like

@jstevenson - can you expand on this?

– Dale

1 Like

Sorry I’ve searched the forum but I cannot find my earlier troubles back in 2022. But I only remember that writing data to UserData wasn’t working, or wasn’t saving or loading not sure which.

We changed our process to always write our data onto RhinoObject.Attributes.UserDictionary and now we don’t have any issues losing data.

It may have been related to trying to use Custom UserData objects, but now we only use strings and just serialize to json on our objects.

Was your UserData class in a dll separate to your Rhino Plugin? I recall having issues with that ~ 5 years ago.

1 Like

It likely, since we keep our data models in a common project, and share them with several components of our application and cloud services.

But I can barely remember dinner yesterday these days… :wink:

Hi.
Still not, I have tried, can’t define UserData into a public library, it will not be saved to a.3dm file.
Just UserData, perhaps stored in json into a UserDictionary and serialized, can define a common class library.

Curious if there was any resolution on this issue. I’m having trouble with a custom defined UserData class. We are working on a Rhino and grasshopper plugin that can work in tandem, so we moved shared code like the UserData class to a shared dll. I’ll take a look at using the UserDictionary approach. Ultimately we are going to set up a postgreSQL data base to store the majority of the data, which needs to sync to our online database. All we really need is our own persistent guid and potentially some other flags. Any disadvantages of using a UserDictionary?

None that I’m aware of. I’d opt for User Dictionaries :slight_smile: .

Cool, thanks!

I might be doing this wrong but the data is appearing under the user text attributes panel. I don’t want to allow users to be able to edit this data since it will contain data like guid’s that is necessary for the plugin to work. I was looking for something I could access programmatically but was not visible to the user.

Are you using UserDictionary or UserStrings?

User Dictionary should not be visible to the User. UserStrings will be.

Got it, Thanks!