revit api 实现过滤墙图元并选中

 1 public IList<Element> findElementsByCategory(Autodesk.Revit.UI.UIApplication aApp,
 2     Document aDoc, BuiltInCategory ACategory)
 3 {
 4     FilteredElementCollector collector = new FilteredElementCollector(aDoc).OfCategory(
 5         ACategory).WhereElementIsNotElementType();
 6 
 7     IList<Element> oList = new List<Element>();
 8     foreach (Element ent in collector)
 9         oList.Add(ent);
10     return oList;
11 }
12 
13 Document doc = commandData.Application.ActiveUIDocument.Document;
14 Selection sel = commandData.Application.ActiveUIDocument.Selection;
15 IList<Element> oList = findElementsByCategory(commandData.Application,
16     doc, BuiltInCategory.OST_Walls);
17 ICollection<ElementId> oSelSet = new List<ElementId>();
18 foreach (Element ent in oList)
19     oSelSet.Add(ent.Id);
20 sel.SetElementIds(oSelSet);

 

posted on 2018-01-09 22:53  小夏coding  阅读(331)  评论(0编辑  收藏  举报

导航