Revit 二次开发—隐藏组

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);
            }
        }

猜你喜欢

转载自blog.csdn.net/weixin_40626630/article/details/86664380