Ah, sorry, I didn’t mentioned, but this is c#, There is no GetUserString here, but I have a GetString().
Still it doesn’t solve my problem as I’m using it without knowing if object have a string assigned, or not. I am trying whenever event RhinoDoc.SelectObjects fires, and I have only one object in my scene.
Strange thing is, that I can see, that object have this value assigned (in the watch in VS), just it’s not taken out fom the method.
to set user text, attached to an object:
private void RunScript(bool bake, GeometryBase geo, string key, string val, ref object A)
{
geo.SetUserString(key, val);
if(bake){
RhinoDocument.Objects.Add(geo);
}
}
to set user text, attached to an object's attributes:
private void RunScript(bool bake, GeometryBase geo, string key, string val, ref object A)
{
Rhino.DocObjects.ObjectAttributes att = RhinoDocument.CreateDefaultAttributes();
att.SetUserString(key, val);
if(bake){
RhinoDocument.Objects.Add(geo, att);
}
}
to modify an object's userdictionary:
private void RunScript(bool bake, GeometryBase geo, string key, string val, ref object A)
{
geo.UserDictionary.Set(key, val);
if(bake){
RhinoDocument.Objects.Add(geo);
}
A = geo;
}
to retrieve a value from an object's userdictionary:
private void RunScript(GeometryBase x, string key, ref object A)
{
A = x.UserDictionary[key];
}