import scriptcontext as sc
groups = sc.doc.ActiveDoc.Groups
for group in groups:
group_name = group.Name
group_objCount = sc.doc.ActiveDoc.Groups.GroupObjectCount(group.Index)
some_value = group.GetUserString("some_key")
but Rhino 5 throws an error that groups is non-sequence…
so then I could do something like this:
for i in range(groups.Count):
group_name = sc.doc.ActiveDoc.Groups.Groupmembers(i)[0]
group_objCount = len(sc.doc.ActiveDoc.Groups.GroupNames(i))
Unlike Rhino 6, Rhino 5 does not have a Rhino.DocObjects.Group class. Thus, it’s doubtful you can get the user strings from a Group object using RhinoCommon in Rhino 5.
import Rhino
import scriptcontext as sc
def GetGroupUserText(id, key):
rs = Rhino.RhinoApp.GetPlugInObject("RhinoScript")
if rs:
return rs.GetGroupUserText(id, key)
return None
for index in range(sc.doc.Groups.Count):
if not sc.doc.Groups.IsDeleted(index):
group = sc.doc.Groups.FindIndex(index)
if group:
value = GetGroupUserText(group.Name, "test")
if value:
print "Name:", group.Name, ", Value:", value
for index in range(sc.doc.Groups.Count):
if not sc.doc.Groups.IsDeleted(index):
group = sc.doc.Groups.GroupName(index)
if group:
value = GetGroupUserText(group, "test")
if value:
print "Name:", group, ", Value:", value