import Rhino
import scriptcontext
# if the switch is on:
if ImportSwitch == True:
opt = Rhino.FileIO.FileReadOptions()
opt.ImportMode = True
# if the delete is on:
if DeleteSwitch == True:
objtype = Rhino.DocObjects.ObjectType.AnyObject
enumSettings = Rhino.DocObjects.ObjectEnumeratorSettings()
enumSettings.ObjectTypeFilter = objtype
guids = [o.Id for o in scriptcontext.doc.Objects.FindByFilter(enumSettings)]
scriptcontext.doc.Objects.Delete(guids, True)
# for each file:
for fpath in FilePaths:
# import it
scriptcontext.doc.ReadFile(fpath, opt)
layerTree = []
# get everything on the layers
for layname in LayerNames:
objs = scriptcontext.doc.Objects.FindByLayer(layname)
guidString = ','.join([str(obj.Id) for obj in objs])
layerTree.append(guidString)
a = layerTree
the input variables are:
ImportSwitch , Item access, Boolean type hint
DeleteSwitch, Item access, Boolean type hint
FilePaths, list access, string type hint
LayerNames, list access string type hint
scriptcontext.doc is targeted to the Rhino doc, not the gh doc
if ImportSwtich is False, and I change the the contents of FilePaths, I would expect this to not read any files. But it reads files any time that the contents of FilePaths are changed. even while ImportSwitch is off.
... and the guidstrings are a hack becauuse I don't know how to make DataTrees in python. : /
my apologies if I'm posting too many issues. It means that I'm really excited about this component. :D
Here is my gh python script:
the input variables are:
ImportSwitch
, Item access, Boolean type hintDeleteSwitch
, Item access, Boolean type hintFilePaths
, list access, string type hintLayerNames
, list access string type hintscriptcontext.doc is targeted to the Rhino doc, not the gh doc if ImportSwtich is False, and I change the the contents of FilePaths, I would expect this to not read any files. But it reads files any time that the contents of FilePaths are changed. even while ImportSwitch is off.
... and the guidstrings are a hack becauuse I don't know how to make DataTrees in python. : /
my apologies if I'm posting too many issues. It means that I'm really excited about this component. :D