Reputation: 21
Does anyone know if ReferenceIntersector works with TopografySurfaces? Cannot make it work. I need to find a point on the surface based on a intersection with a line.
Upvotes: 1
Views: 755
Reputation: 43
Did you solve it? If not, i gave it a try and for me this Code here works fine:
public XYZ ProjectPointOnTopographySurface(XYZ point, int direction)
{
// For getting the 3D view
View3D view3D = new FilteredElementCollector(Document)
.OfClass(typeof(View3D))
.Cast<View3D>()
.Where(v => v.Name == "{3D}")
.FirstOrDefault();
XYZ vectorDirection = new XYZ(0, 0, direction);
ElementClassFilter intersectionFilter = new ElementClassFilter(typeof(TopographySurface));
ReferenceIntersector referenceIntersector = new ReferenceIntersector(intersectionFilter, FindReferenceTarget.All, view3D);
ReferenceWithContext referenceWithContext = referenceIntersector.FindNearest(point, vectorDirection);
return referenceWithContext.GetReference().GlobalPoint;
}
Upvotes: 2
Reputation: 8294
Regardless of whether the ReferenceIntersector
does or does not work with topography surfaces, you can pretty easily solve the problem you describe yourself using other means. Simply ask the surface for its tessellated representation. That will return a bunch of triangles. Then, implement your own algorithm to intersect a triangle with the line. That should give you all you need, really.
Upvotes: 1