I used to be able to attach files as Worksession and retrieve objects by groups in these attached files.
This doesn’t work anymore. Here is a snippet and steps to reproduce :
- Open the attached rhino file and run the script : objects by group are printed
- Open a new rhino file, attach the file and run the script : print result = “[]”
Could you please look into that ?
Thanks a lot!
Sylvain
260225_ObjectsByGroup_WorksessionBUG.3dm (114.7 KB)
import rhinoscriptsyntax as rs
id = rs.GetObject()
groups = rs.ObjectGroups(id)
for group in groups :
objects_by_group = rs.ObjectsByGroup(group)
print(objects_by_group)
edit1 : fixed indent
edit2 : Groups.GroupMembers() seems to be the problem.
https://developer.rhino3d.com/api/rhinocommon/rhino.docobjects.tables.grouptable/groupmembers
import rhinoscriptsyntax as rs
import scriptcontext
import Rhino
id = rs.GetObject()
groups = rs.ObjectGroups(id)
for group_name in groups :
print group_name
group = Rhino.RhinoDoc.ActiveDoc.Groups.FindName(group_name)
index = group.Index
print index
members = Rhino.RhinoDoc.ActiveDoc.Groups.GroupMembers(group.Index)
print members