Hello all,
I'm trying to make an addin to automatically join geometry of intersecting walls and floors. My idea is to make 2 collectors for wall and floor. Then make a for-loop to iterate through all floor elements, find boundingbox of each element then apply boundingboxintersectsfilter to the wall collector, then join all intersecting wall with the floor. However, after the first iteration, the wall collector does not return to previous state with all the wall elements in the document, so I cannot apply the new element filter onto it. Is there a way to "reverse" the collector back in the for-loop?
Thanks.
Attached bellow is my code:
//col1 is wall collector; col2 is floor collector.
foreach (Element f in col2) { BoundingBoxXYZ a = f.get_BoundingBox(doc.ActiveView); Outline b = new Outline(a.Min, a.Max); BoundingBoxIntersectsFilter filter = new BoundingBoxIntersectsFilter(b,-0.5); IList<Element> ele = col1.WherePasses(filter).ToElements(); foreach (Element w in ele) { JoinGeometryUtils.JoinGeometry(doc, w, f); }
// code to return col1 to previous state. }
Solved! Go to Solution.
Solved by FAIR59. Go to Solution.
You can save the elementIds of the walls and use those as the basis for an FilterElementCollector repeatedly
ICollection<ElementId> wallIDs = col1.ToElementIds(); foreach (Element f in col2) { BoundingBoxXYZ a = f.get_BoundingBox(doc.ActiveView); Outline b = new Outline(a.Min, a.Max); BoundingBoxIntersectsFilter filter = new BoundingBoxIntersectsFilter(b,-0.5); // IList<Element> ele = col1.WherePasses(filter).ToElements(); IList<Element> ele = new FilteredElementCollector(doc,wallIDs) .WherePasses(filter).ToElements(); foreach (Element w in ele) { JoinGeometryUtils.JoinGeometry(doc, w, f); } // code to return col1 to previous state. }
Can't find what you're looking for? Ask the community or share your knowledge.