public static bool HideGroupById(Document doc, int groupidnum, bool n) { ElementId groupid = new ElementId(groupidnum); try { Element elem = doc.GetElement(groupid); Group g = elem as Group; IList<ElementId> ids = g.GetMemberIds(); if (n == true) { doc.ActiveView.HideElements(ids); return true; } else { doc.ActiveView.UnhideElements(ids); return true; } } catch (Exception ex) { return false; } } public static void HideGroupsById(Document doc, List<int> groupidnums) { foreach (var idnum in groupidnums) { ElementId groupid = new ElementId(idnum); Element elem = doc.GetElement(groupid); Group g = elem as Group; IList<ElementId> ids = g.GetMemberIds(); doc.ActiveView.HideElements(ids); } }