Skip to content

Instantly share code, notes, and snippets.

@piac
piac / list_to_tree.py
Last active September 24, 2024 09:20
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
@piac
piac / clone.cs
Created June 20, 2011 13:30
Duplicate or Clone example to have less calls
using System;
class Program
{
static void Main(string[] args)
{
var c = new Curve();
var cc = c.Clone(); //cc is Curve