Storing GLOBAL Strings/Attributes/Custom Data in the RhinoDoc in C#?

Hi there.

I’ve used other CAD systems which allow the programmatic storage of GLOBAL document attributes. These attributes are document-specific and, therefore, I cannot simply store them in the User Settings. They must be portable from one user to another and they must be stored ideally inside the RhinoDoc.

For example, I need to store and retrieve a number of ‘Job’ attributes which are then read on document load and control other aspects of the plug-in.

The alternative will be to store this in a file, which will (possibly) live in the same folder/directory as the 3dm file and I can then load the data from there. This approach would work as desired, but it is not the preferred user experience I am hoping to achieve, since it is not IF but WHEN a user will forget to copy the ‘Attributes’ file, thus negating any previous work.

Any ideas are welcome and greatly appreciated!

Have you looked into Notes or User Data? Or have I misunderstood what you want to do?

Hi AIW. Thank you for replying!

Yes! This would accomplish what I need! I can just store all my data as a string and then retrieve it. I do have a couple of questions:

  1. Will this string be visible by the User?
  2. Do you know if I could break something by storing my data here? I don’t want to block valid/legitimate functionality by storing my data.

Thanks again!

PS: I found the Notes right away under the RhinoDoc object. Do you happen to know where the UserData is found?

Thanks again!

1 Like

Based on the wonderful suggestion by AIW I looked into doc.Strings. There seems to be an unlimited number of strings that can be stored in the doc. This delivers on my needs.

If you use Notes, I believe the user just needs to open them via a builtin menu selection or command. On the few occasions where I’ve just used them from the Rhino commands (rather than generating them from a plugin) the Note window will appear on startup if the model is saved with it open.

I’ve never used User Data, but I believe you will need to provide a method in your plugin to display the data. I wouldn’t know where to find the methods, but they must be there somewhere. :grin:

Your need is exactly why these functions were developed, so I don’t think there’s any danger of that.