Message 1 of 2
how do i use BoundingBoxIntersectsFilter to find floors intersecting with stair BoundingBox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to find the floors my stairs is going to and from
I am using BoundingBoxIntersectsFilter to find the floors that are intersecting with my stairs BoundingBox. when I then find the floors I want to take the one with the highest Z value, and save it to "Upper slab ref". And the one with the lowest Z value and save it to "Lower slab ref".
And now to the problem when I try to do this I will get to many floors or non at all
how can I make it so it will always find the right floors, in any given situation.
The middle stair will get 4 floors
The highest stair will get 2 floors but non of them is from the upper floor. and the lowest stair will find non at all.
code is shown below
ICollection<Element> AllStairs = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Stairs).WhereElementIsNotElementType().ToElements();
FilteredElementCollector collectorSlab = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType();
foreach (Element el in AllStairs)
{
IDictionary<string, double> StairsSlab = new Dictionary<string, double>();
List<string> allSlabs = new List<string>();
BoundingBoxXYZ bb = el.get_BoundingBox(doc.ActiveView);
Outline outline = new Outline(bb.Min, bb.Max);
BoundingBoxIntersectsFilter bbfilter = new BoundingBoxIntersectsFilter(outline);
collectorSlab.WherePasses(bbfilter).ToElements();
if (collectorSlab != null)
{
foreach (Element e in collectorSlab)
{
BoundingBoxXYZ location = e.get_BoundingBox(doc.ActiveView);
double zPoint = location.Max.Z;
allSlabs.Add(e.Id.ToString());
StairsSlab.Add(e.Id.ToString(), zPoint);
}
}
if (StairsSlab[allSlabs[0]] > StairsSlab[allSlabs[1]])
{
tr.Start("Reload");
el.LookupParameter("Upper slab ref").Set(allSlabs[0].ToString());
el.LookupParameter("Lower slab ref").Set(allSlabs[1].ToString());
tr.Commit();
}
else
{
tr.Start("Reload");
el.LookupParameter("Upper slab ref").Set(allSlabs[1].ToString());
el.LookupParameter("Lower slab ref").Set(allSlabs[0].ToString());
tr.Commit();
}
}