algorithmic modeling for Rhino
Hi,
This is an exercise I am always showing when I teach GH-oriented Python to my students. It grafts a list of data into a tree, not through the graft method, but using a for loop instead. By changing the loop you will get the desired result.
import Rhino
#import grasshopper classes
import clr
clr.AddReference("Grasshopper")
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTreenewlist = []
newlist = x[:]
print newlistgraftedTree = DataTree[object]()
for i in range(len(newlist)):
str =newlist[i]
path = GH_Path(i)
graftedTree.AddRange([str],path)A = graftedTree
Best,
M.
would you mind explain the clr module? I dont know what it is
Thanks
-Carcassi.
By importing clr you can basically reference any compiled code in your disk. In this case we are importing the grasshopper.dll. This means we can access pretty much all the classes and methods of the gh plug-in.
This import is automatically available in the VB and C# components, but in the case of the Python one which is a third party component (cc Giulio Piaccentino) this import is not predefined.
Best,
M.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by