public static List<Element> GetAllBlocks(Document doc) { try { FilteredElementCollector collector = new FilteredElementCollector(doc); List<Element> elems = collector.OfClass(typeof(FamilyInstance)). OfCategory(BuiltInCategory.OST_StructuralFraming). ToElements(). ToList(); return elems; } catch (Exception) { TaskDialog.Show("Error", "获取到所有节段失败"); return null; } }