They werenât available in Rhino 5. They were introduced in Rhino 6. ButâŚIn the sample file at the end of that page, there is a gh file. That file contains 2 methods:
1 - one component using GH Classes to make datatrees (a little trickier, but works in Rhino 5)
2 - one component using Treehelpers, (which are great, but only in Rhino 6).
I see, thanks. They should change the documentation, because at the top it says you are viewing the documentation for âRhino 5â, which makes following the example for Rhino 5 frustrating if they didnât exist at that time.
using the example file from this page: (the treehelper fails, as expected, in rhino 5)
this is the code from that example, using GH classes: itâs not using the treehelper function at all.
import Rhino
# for accesssing GH classes
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree
import System.Array as array
layerTree = DataTree[object]() # make a DataTree
for i in range(len(layernames)):
objs = Rhino.RhinoDoc.ActiveDoc.Objects.FindByLayer(layernames[i])
if objs:
geoms = [obj.Geometry for obj in objs]
path = GH_Path(array[int]([0,0,i]))
layerTree.AddRange(geoms, path)
a = layerTree
ok, couple things.
1 - that is the correct link and file
2 - your screen shot is showing the component using TreehelpersâŚthis will not work in Rhino 5
3 - the component ABOVE that uses GH classes. It will work in Rhino 5.
The script in that component requires some geometry to be on the layers that are named in the layernames input. If there is no geometry in the Rhino document, on those layers, there will be no output from the component.
Yes very sorry, I noticed that I was looking at the wrong box. When you said two examples, I thought it was the grasshopper groups that you were talking about.
any chance you have a typo somewhere? Make sure that the input spelling of âlayernamesâ is the same as where it is referenced in your code, (line 10).