How to get all the groups in the active grasshopper document using grasshopper API, I want to retrieve all the groups in the active document and change their attributes, but I can’t find a way to query all groups in the document.
Also what is a good resource to understand how the grasshopper API works, like an explanation for how things are organized with some samples?
Hi,
You can iterate through all document objects and check for the GH_Group type.
List<GH_Group> groups = new List<GH_Group>();
foreach (IGH_DocumentObject igho in GrasshopperDocument.Objects)
{
if (igho is GH_Group)
{
GH_Group gr = igho as GH_Group;
//do your stuff here
groups.Add(gr);
}
}
A = groups;
GetGroups.gh (8.6 KB)
MetaHopper plugin also has components to access groups, set their colors and names.
1 Like
Great, Thank you.