I understand and study with the creation of nodes on
I’m trying to create a node that makes the Boolean difference of solids (I know that it is in the grasshopper). For educational purposes, I do it.
Can you please tell me how to fix it, such an error occurs
GetDataTree requires an argument of type GH_Structure<IGH_Goo>. DataTree does not derive from IGH_Structure, in my opinion it won’t work. You need
GH_Structure<GH_Brep> solid = new GH_Structure<GH_Brep>();
GH_Structure<GH_Brep> difference = new GH_Structure<GH_Brep>();
if (!DA.GetDataTree(0, out solid)) return;
if (!DA.GetDataTree(1, out difference)) return;
The datatype can be inferred when the method is called. No idea though why you would want tree access in the first place.
Thank you very much for the clarification.
I want to do the following
there is a solid tree on each branch
and there is a tree of bodies (there are several on each branch) that need to be subtracted from each solid body
Or can this problem be solved easier?
I now get an error after the changes in the following
Anyways, as for your screenshots: If you want to access a Branch, you need to use an indexer ( there is no method to call). tree.Branch[path] should return the list which is stored in that path.
As for the second one, the DataTree class and the GH_Structure class are unrelated (they have similar functionality but are not compatible). So assigning the one to the other won’t work. If you would really want to do that, you need to rebuild the tree. Don’t do it.
But yeah, generally speaking, I think the boolean difference component works with List/List. The RhinoCommon command in the API also works with two Lists of Breps. If you want to work with trees, you need make sure they are compatible (same branch count, matching path structure, etc.) and manage all that. I think it’s easier letting Grasshopper do that, but maybe I don’t see the full picture here.