Message 1 of 8
How to avoid getting "sub element in an element" when getting all elements?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone.
I use the following code to get all the elements with geometry.
List<Element> mainModeElems = new List<Element>(); FilteredElementCollector collector = new FilteredElementCollector(Document); ICollection<Element> allElements = collector.WhereElementIsNotElementType().ToElements(); Options geoOptions = new Options(); foreach (Element element in allElements) { GeometryElement geomElement = element.get_Geometry(geoOptions); if (geomElement != null) { mainModeElems.Add(element); } }
But this will collect sub element like OST_StairsRuns, OST_RailingTopRail, OST_StairsRailingBaluster and mullions.
I don't need these elements, and these elements cause the ElementIntersectsElementFilter to throw an exception stating "The category of the element is not supported for element intersection filters."
How to filter out these sub elements? I haven't found any differences in attributes between them and the regular overall elements. Now I'm trying to use element.ArePhasesModifiable() for filtering, which seems to work, but could this cause any errors or lead to the omission of certain elements?
Thank you all.