Skip to content

Instantly share code, notes, and snippets.

View tomeido's full-sized avatar
🐈‍⬛

tomeido tomeido

🐈‍⬛
View GitHub Profile
@tomeido
tomeido / list_to_tree.py
Created March 24, 2022 05:45 — forked from piac/list_to_tree.py
Transforms DataTrees in Grasshopper to nestings of lists, and vice versa
def list_to_tree(input, none_and_holes=True, source=[0]):
"""Transforms nestings of lists or tuples to a Grasshopper DataTree"""
from Grasshopper import DataTree as Tree
from Grasshopper.Kernel.Data import GH_Path as Path
from System import Array
def proc(input,tree,track):
path = Path(Array[int](track))
if len(input) == 0 and none_and_holes: tree.EnsurePath(path); return
for i,item in enumerate(input):
if hasattr(item, '__iter__'): #if list or tuple