Message 1 of 10
Doors traversed on path of travel lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
// List to store door elements that the path of travel intersects
List<Element> intersectedDoors = new List<Element>();
// Find a 3D view to use for the ReferenceIntersector constructor
FilteredElementCollector collector = new FilteredElementCollector(mydoc);
View3D view3D = collector
.OfClass(typeof(View3D))
.Cast<View>() // First, cast the collected Elements to Views
.Where(v => v is View3D && !((View3D)v).IsTemplate) // Then check if it is a View3D and not a template
.FirstOrDefault() as View3D; // Finally, cast the result to View3D
List<ElementId> DoorElements = new List<ElementId>();
foreach (var curve in PathOfTravel_Curves)
{
Line curve_line = curve as Line;
XYZ curve_direction = curve_line.Direction;
XYZ curve_Point = curve.GetEndPoint(0);
// Create a category filter for Doors
ElementCategoryFilter doorsCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
ReferenceIntersector My_refIntersector = new ReferenceIntersector(doorsCategoryfilter, FindReferenceTarget.Element, view3D);
//IList<ReferenceWithContext> referencesWithContext = My_refIntersector.Find(curve_Point, curve_direction);
ReferenceWithContext referencesWithContext = My_refIntersector.FindNearest(curve_Point, curve_direction);
if (referencesWithContext != null)
{
var referenceElem = referencesWithContext.GetReference();
var refElem = referenceElem.ElementId;
if (DoorElements.Contains(refElem)){ continue; }
else
{
DoorElements.Add(refElem);
totalNumberOfIntersectedDoors += 1;
}
}
}Hi, I wanted to make a list of all the doors that need to be crossed to follow a path of travel line. This is exactly what Jeremmy Tommik has mentioned in his Github page before : https://github.com/jeremytammik/PathOfTravelDoors
I tried to code what he has recommended, but seems that ReferenceIntersector finds even the doors which are not exactly on the path of travel but the introduced ray is reaching them. I don't know how to avoid it, Any idea?
I am including piece of my code which is doing the task.
(BTW his code does nothing for me, I actually don't see anything in it that can do the task when I open it, maybe there is something that I am not familiar with.)
Developer Advocacy and Support +