try to save curves with opennurbs and SetUserString
:
ON_NurbsCurve* rhinoCurve = new ON_NurbsCurve(...);
rhinoCurve->SetCV();
rhinoCurve->SetKnot();
// Option 1: SetUserString directly
rhinoCurve->SetUserString(L"MyKey", L"MyValue");
// Option 2: SetUserString through attributes
ON_3dmObjectAttributes* attributes = new ON_3dmObjectAttributes();
attributes->SetUserString(L"MyKey", L"MyValue");
// save model
model.AddManagedModelGeometryComponent(rhinoCurve, attributes);
model.Write(path.c_str(), 0, &error_log);
then read with c++ plugin(command):
CRhinoObjectIterator it(CRhinoObjectIterator::normal_objects, CRhinoObjectIterator::active_objects);
for (object = it.First(); 0 != object; object = it.Next())
{
// Try casting as an instance object
const CRhinoInstanceObject* iref_object = CRhinoInstanceObject::Cast(object);
if (nullptr != iref_object)
{
// Try getting the instance object's definition
const CRhinoInstanceDefinition* idef = iref_object->InstanceDefinition();
if (nullptr != idef)
{
ON_wString idef_name = idef->Name();
dump.Print(L"Instance Model object %d: %ls (%ls)\n", object_count++, iref_object->ShortDescription(false), static_cast<const wchar_t*>(idef_name));
IterateInstanceDefinition(iref_object->InstanceDefinition(), dump);
}
}
else
{
// Just a regular model object
CRhinoObjectAttributes attrib = object->Attributes();
ON_wString userStr;
bool hasKey = attrib.GetUserString(L"MyKey", userStr);
// not work : <
dump.Print(L"Regular Model object %d: %ls\n", object_count++, userStr);
}
}
both attrib.GetUserString()
and object->GetUserString()
return false, any idea?