Message 1 of 5
Why don't work ReferenceIntersector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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 FunctionI use Dir = 1 and Dir = -1. Function find some points. But some points don't find.