Hello,
I have a python script that currently takes in GUIDs of Model Objects & returns a data tree structure based on the group name in the rhino document.
By inputting the GUIDs and not the Model Objects themselves, I lose all Element User Text attached to those model objects after the python node operation.
Currently I can just reassign the Element User Data to the newly created data tree by using the Match Tree Structure component from TT Toolbox.
However, I would love to figure out how to simply pass the model objects through the python node without needing this extra step.
I’m confused on how to reference model objects in python and can’t find specific information on that in the API documentation as they are a new (i think?) object type for Rhino 8.
Here is what it looks like in graph space:
And here is the python code leveraging the GUID method:
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
import clr
sc.doc = Rhino.RhinoDoc.ActiveDoc
def DoSomething():
group_names = rs.GroupNames()
name_array = []
for gn in group_names:
obj_ids = rs.ObjectsByGroup(gn)
bool = True
for obj in obj_ids:
if str(obj) not in Geometry: bool = False
if not obj_ids: continue
count = len(obj_ids)
if bool:
name_array.append(gn)
return name_array
names = DoSomething()
clr.AddReference("Grasshopper")
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree
dataTree = DataTree[object]()
sc.doc = Rhino.RhinoDoc.ActiveDoc
i=0
for name in names:
objs = rs.ObjectsByGroup(name)
for item, thing in enumerate(objs):
branch_id = i
path = GH_Path(branch_id)
dataTree.Add(thing, path)
Groups = dataTree
i = i+1
sc.doc = ghdoc
Thank you for your time and assistance!
