Object attributes

Hi,

I would like to ask how can I add attributes to geometry objects in rhino C++ SDK?
For example is it possible to have a curve that stores a list of string besides curve it self i.e. “ID0”, “Cut5”, “Cut7”?

Is there any documentation how can I attach additional attributes?
Is it only restricted to string data or can it also be additional geometry?

Or you will need to use ON_UserData. Create a subclass for your user data and override Read and Write functions to load and save your user data to ON_BinaryArchive when the object that the user data is attached to is loaded or saved in 3dm file.

https://developer.rhino3d.com/api/cpp/class_o_n___user_data.html

Thank you very much, it is nice to have this option, without creating custom classes.

How can I know if I attached attributes correctly?
For instance I added radius value to a line:

int count = 0;
for (auto& output : lines) {
	CRhinoCurveObject* curve_object = context.m_doc.AddCurveObject(output, &attributes);

	// Attach user string to object's attributes
	CRhinoObjectAttributes attribs = curve_object->Attributes();
	ON_wString key ( L"radius" );
	ON_wString text  (L"%f",radii[count]);
	attribs.SetUserString(key, text);
	context.m_doc.ModifyObjectAttributes(curve_object, attribs);

	group_members.Append(curve_object);
	count++;
}

But I do not see anything here:

These user-strings don’t show up in Rhino. But you can retrieve them, and they should (“should” :wink: ) be saved to 3dm automatically.