Grasshopper

algorithmic modeling for Rhino

If I call the function below it will not run. If i comment out any calls that clear the persistent data it will work. Adding persistent data will append it to the list as expected. This methodology used to work some time ago, but it seems that it was changed. Is there any way to currently change/clear persistent data on a component?

Grasshopper.Kernel.Parameters.Param_String strSize = (Grasshopper.Kernel.Parameters.Param_String)this.Params.Input[2];

strSize.PersistentData.Clear();

//strSize.ClearPersistentData() // this also doesnt work
strSize.AddPersistentData(new Grasshopper.Kernel.Types.GH_String(size2));
strSize.ExpireSolution(false);

this.ExpireSolution(true);
GH_Document doc = this.OnPingDocument();
doc.NewSolution(false);

Thank you.

Views: 963

Replies to This Discussion

strSize.ClearPersistentData()

Is gone. Since Persistent supports DataTrees I only expose the tree itself via the PersistentData property. Thus, param.PersistentData.Clear() is indeed the best way to clear it. Similarly, AddPersistentData is a panic function, since you're adding known types you're better off using; param.PersistentData.Append(new GH_String(size2));

Incidentally the AddPersistentData already calls ExpireSolution(false) on the parameter as well as OnObjectChanged(GH_ObjectEventType.PersistentData), so you don't have to call those if you go the AddPersistentData() route.

this.ExpireSolution(true); will cause a new solution, so you do not have to specifically call doc.NewSolution(false); since that will already have happened. You're now triggering a new solution twice (though, since nothing expired in between the second call will be very quick).

I don't know why PersistentData.Clear() doesn't work, it definitely should, can you make absolutely sure that there's no exception being thrown?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service