Trying to get the layers that are in a group


I am trying to get all the layers used in a group, then I want to run a function based on the layer names that are INSIDE that selected group.

I have found plenty of other methods, but they all involve selecting every object in the document on a layer.

Any help would be awesome!, C#, RS, or Python, anything you got i can work with :slight_smile:

I think this extension method should do it:

public static class GroupTableExtensionMethods
  /// <summary>
  /// Returns the layer indices of Group members
  /// </summary>
  public static int[] GroupLayers(this GroupTable groupTable, int groupIndex)
    if (groupIndex > 0 && groupIndex < groupTable.Count)
      var rhino_objects = groupTable.GroupMembers(groupIndex);
      var hash_set = new HashSet<int>();
      foreach (var rh_obj in rhino_objects)
      return hash_set.ToArray();
    return new int[0];