Why don't work ReferenceIntersector

Why don't work ReferenceIntersector

AndrewButenko
Advocate Advocate
731 Views
4 Replies
Message 1 of 5

Why don't work ReferenceIntersector

AndrewButenko
Advocate
Advocate

I try get point on toposurface with my function:

 

Function GetPointOnTopoSurface(doc As Document, p As XYZ, Dir As Integer) As XYZ

        ' Find a 3D view to use for the ReferenceIntersector constructor
        Dim collector As New FilteredElementCollector(doc)
        Dim isNotTemplate As Func(Of View3D, Boolean) = Function(v3) Not (v3.IsTemplate)
        'Dim view3D As View3D = collector.OfClass(GetType(View3D)).Cast(Of View3D)().First(isNotTemplate)
        Dim view3D As View3D = collector.OfClass(GetType(View3D)).Cast(Of View3D)().Where(Function(x) x.Name = doc.ActiveView.Name).First(isNotTemplate)

        '---------------------------
'Draw line Dim q As New XYZ(p.X, p.Y, p.Z + Dir * 150) Dim l As Line = Line.CreateBound(p, q) drawCurveDoc(doc, l) '--------------------------- Dim pTop As XYZ = p ' Project in the negative Z direction down to the floor. Dim rayDirection As New XYZ(0, 0, Dir) Dim filter As New ElementClassFilter(GetType(TopographySurface)) Dim refIntersector As New ReferenceIntersector(filter, FindReferenceTarget.All, view3D) If IsNothing(refIntersector.FindNearest(pTop, rayDirection)) Then Return p End If Dim referenceWithContext As ReferenceWithContext = refIntersector.FindNearest(pTop, rayDirection) Dim reference As Reference = referenceWithContext.GetReference() Dim intersection As XYZ = reference.GlobalPoint Return intersection End Function

I use Dir = 1 and Dir = -1. Function find some points. But some points don't find.

 

732 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Dear Andrew,

 

Your code looks perfectly all right to me.

 

Maybe you should create a complete minimal reproducible case to prove the problem exists:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

I could pass that on to the development team for analysis.

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 5

Admin.CTI
Participant
Participant

I have the exact same problem. Maybe the reference intersector does not work on topos?


0 Likes
Message 4 of 5

AndrewButenko
Advocate
Advocate

Hi!

I figured it out. If the ray hits the topoline between mesh(triangls), then the function assumes that the topo does not exist. 

 

Message 5 of 5

Admin.CTI
Participant
Participant

Thank you. I actually solved in another way that i cannot remember. But thanks for the support.

0 Likes