Is there different between Rhino UserData API and Rhino UserString API?
The two of the API is use to add User Custom data to the Rhino Geometry, Is there different about that?
There are in fact three ways to store meta-data on an object. The most simple is to store strings in the UserString collection (GetUserString() / SetUserString()
). The most complicated is to make a custom user data class that supports serialization. This is stored in the UserData
collection. In between these to you find the, IMHO, sweet spot: the UserDictionary
. There you can store string-key>value
pairs for most common types, and you don’t have to worry about serialization.
But I have an Question, If I store an meta-data using GetUserString()/ SetUserString())
, I find I can not delete then?
I think it can be done like so:
GeometryBase geo; // defined elsehwere
string key = "KEY";
string value = "VALUE";
// set the value
geo.SetUserString(key, value);
// remove the value
geo.GetUserStrings().Remove(key);
OK,ThankYou, I’ll have a try