if on:
import Rhino
import os
import ghpythonlib.treehelpers as th
a = []
b = []
path = None
if (dir is not None):
dir = dir.strip()
if dir.endswith(os.sep):
dir = dir[:-1]
if (os.path.isdir(dir)):
path = dir
if (path is None):
path = os.path.dirname(ghenv.Component.OnPingDocument().FilePath)
print("Search Path: {}".format(path))
dirList = os.listdir(path)
for file in dirList:
results = []
if (file.endswith(".3dm")):
file_w_path = os.path.join(path, file)
rhinoFile = Rhino.FileIO.File3dm.Read(file_w_path)
notes = rhinoFile.Notes.Notes
results.append(["Path: {}".format(path), "File: {}".format(file), notes])
print(results)
a.append(results)
# b = th.list_to_tree(a)
Uncommenting the last line of code crashes Grasshopper
notes_in_directory_python.gh (12.6 KB)