Skip to content

Instantly share code, notes, and snippets.

@notionparallax
Created April 22, 2013 08:30
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save notionparallax/5433271 to your computer and use it in GitHub Desktop.
Save notionparallax/5433271 to your computer and use it in GitHub Desktop.
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
from clr import AddReference as addr
addr("Grasshopper")
from System import Object
from Grasshopper import DataTree
from Grasshopper.Kernel.Data import GH_Path
def raggedListToDataTree(raggedList):
rl = raggedList
result = DataTree[object]()
for i in range(len(rl)):
temp = []
for j in range(len(rl[i])):
temp.append(rl[i][j])
#print i, " - ",temp
path = GH_Path(i)
result.AddRange(temp, path)
return result
def dataTreeToList(aTree):
theList = []
for i in range(aTree.BranchCount ):
thisListPart = []
thisBranch = aTree.Branch(i)
for j in range(len(thisBranch)):
thisListPart.append( thisBranch[j] )
theList.append(thisListPart)
return theList
print raggedListToDataTree(dataTreeToList(somePts))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment