algorithmic modeling for Rhino
The more I start to develop grasshopper plugins, the more I start to wonder what the correct way to handle different input structures is. For example, lets say I have a component with two inputs. How do I handle it if there is a item/item vs item/list vs list/item/ vs item/tree. Etc. etc.
All of the existing Grassopper components seem to handle these situations very gracefully. How do I make sure that my components do the same thing?
Thanks
Tags:
Hi Ryan,
The type of data you request is another decision you need to make. I usually ask for System.Double, System.Int32 and Rhino.Geometry.Brep instead of GH_Double, GH_Integer and GH_Brep as it makes my component code easier. The necessary conversions are handled by the DA object. It sometimes makes sense to get an IGH_Goo or IGH_GeometricGoo, but that's rare.
--
David Rutten
david@mcneel.com
Hello,
this is an old thread, but I have a similar question. I can't get an idea of how should I handle DataTrees inside plugins. Right now I have something like this:
GH_Structure<IGH_Goo> boxInfo = null;
if (!DA.GetDataTree<IGH_Goo>(0, out boxInfo)) return;
But it makes some problems later, because I have to cast types.
This code doesn't work however:
DataTree<int> boxInfo = new DataTree<int>();
DA.GetDataTree(0, ref boxInfo);
As I mentioned before, I can try to cast IGH_Goo to int later in code, but you mentioned that getting IGH_Goo rarely makes sense. What would be a good solution then?
Thank you in advance,
Krzysztof Nazar
Thanks for advice. Right now I'm good with
[some IGH_Goo instance].CastTo<int>(out [some integer variable])
...but wasn't sure if it's the right / efficent way.
I have to check out these "Solid principles"
Best,
Krzysztof
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by