I’m developing a Grasshopper component in c# and I’m trying to use userdictionary to store data attached to geometry.
I can make it to work when the file is open, but when I save+close+reopen the file the data is no longer there.
In the code below the first time I run the component after opening the file I always get “Stored data NOT found”, then I always get “Stored data found”, so the dictionary is in the model, but it is not saved to the file.
How can I make userdictionary survive when saving the file? I am missing something?
private void RunScript(Brep Brep, bool run, ref object A, ref object B)
{
if (run){
object text;
if (Brep.UserDictionary.TryGetValue("test", out text) == false){
Print("Stored data NOT found");
Brep.UserDictionary.Set("test", "myValue");
} else {
Print("Stored data found");
}
A = Brep;
B = text;
}
}