1

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.

2 Answers2

2

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;
    }
Vahdet
  • 43
  • 8
1

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.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17