Hi;
I use Rhino.RhinoDoc.ActiveDoc.Strings.SetString() in c# to write a string to rhino active document, how can I get this string by c++?
Hi@ dale:
Thanks.
Hi @dale,
Do you know some web with explains CRhinoDoc::GetUserString
function usage? I have some problem and I don’t know where is the problem.
https://discourse.mcneel.com/t/rhino-c-getuserstring/100276
Thanks.
Hi @aitorerana,
May this sample will help you.
https://github.com/mcneel/rhino-developer-samples/blob/6/cpp/SampleCommands/cmdSampleUserStrings.cpp
CRhinoGetObject go;
go.SetCommandPrompt(L"Select Curve");
go.SetGeometryFilter(CRhinoGetObject::curve_object);
go.GetObjects(1, 1);
if (go.CommandResult() != CRhinoCommand::success)
{
return CRhinoCommand::success;
}
ON_wString key = L"test";
ON_wString text = L"sample text";
const CRhinoObjRef& ref = go.Object(0);
const CRhinoObject* objj = ref.Object();
ON_Object* obj = const_cast<CRhinoObjectAttributes*>(&objj->Attributes());
// Part 1 start
obj->SetUserString(key, text);
// Part 1 end
// Parte 2 start
ON_wString textStr;
obj->GetUserString(key, textStr);
ON_wString userTextStr;
userTextStr.Format(L"UserText: %s\n", textStr);
RhinoApp().Print(userTextStr);
return CRhinoCommand::success;
Hi @aitorerana,
Here is some text on object user text. Basically, document user text is the same thing.
– Dale
Thank you both!!
@suc_kiet it helps me a lot, now I have other problems but this work good.
@dale I alredy saw that site but didn’t see how to use GetUserString() function.
Thanks again.
Hi Dale, why not Rhino.RhinoDoc.ActiveDoc.Strings.SetString() ?
ahh ok, thanks. I take the opportunity to ask for help, I am using this
RhinoDoc.ActiveDoc.Strings.SetString(“IsLoadedOnCheckIo”,“false”);
but I don’t know why because it returns null
Return Value
Type: String
The previous value if successful and a previous value existed.
– Dale