' --------------------------------------------------------------------------------- ' Extract the normals from the passed arguments, return a customised array ' Normal method based on 996 reporting (to fix oddity with MX normal report method MFWPSMcNormal) ' --------------------------------------------------------------------------------- Sub Get_Normals(ByVal cModelName As String, ByVal cStringName As String, dXRefStart As Double, dYRefStart As Double, _ dXRefEnd As Double, dYRefEnd As Double, ByRef dDistanceStart As Double, ByRef dDistanceEnd As Double, _ ByVal index As Integer, cArrayReport() As String) Dim lCurveFitting As Long Dim l As Long Dim lReturn As Long Dim Reals(0 To 14) As Double Dim Text(0 To 14) As String Dim d As Double lCurveFitting = 1 cModelName = Trim(cModelName) ' ------------------------------------------------------ ' returns X, Y, Z, Chainage, Bearing, Radius, Distance ' Reals 0 1 2 3 4 5 6 ' ------------------------------------------------------ ' Start point on string ' lReturn = 0 ' lReturn = oMFWB.MFWPSMcNormal(cModelName, cStringName, cModelName, cStringName, lCurveFitting, _ ' dXRefStart, dYRefStart, Reals, lReturn) Err.Clear lReturn = 0 Call iMXFireMajor("REPORT", cModelName) Call iMXFireMinor("017", "CURV") Call iMXFireMinor("996", cStringName, "PLAN", , 1, dXRefStart, dYRefStart) Call iMXFire999 Call oMFWB.MFWGetData(1, Reals, Text) lReturn = CLng(Reals(14)) If lReturn > 0 Then Call oMFWB.MFWGetData(1, Reals, Text) ' if Reals array returns empty, skip to end point check If lReturn = -1 Then GoTo Skip_Start_Point_Check ' if the normal distance is less than the current distance, update the array values to the match the new point ' find an "E" (exponent) in the string, return "0.000" if found If InStr(1, Reals(0), "E", vbTextCompare) > 0 Then d = CDbl(0#) Else d = CDbl(Reals(0)) d = Format(d, "0.000") ' normal distance (3 decimals) If d < dDistanceStart Then cArrayReport(index, 2) = cStringName ' update Master String name cArrayReport(index, 3) = Format(Reals(5), "#.###") ' update chainage dDistanceStart = Format(d, "0.000") ' set the new minimum testing distance to the current normal distance End If Skip_Start_Point_Check: ' End point on string ' lReturn = 0 ' lReturn = oMFWB.MFWPSMcNormal(cModelName, cStringName, cModelName, cStringName, lCurveFitting, _ ' dXRefEnd, dYRefEnd, Reals) Err.Clear lReturn = 0 Call iMXFireMajor("REPORT", cModelName) Call iMXFireMinor("017", "CURV") Call iMXFireMinor("996", cStringName, "PLAN", , 1, dXRefEnd, dYRefEnd) Call iMXFire999 Call oMFWB.MFWGetData(1, Reals, Text) lReturn = CLng(Reals(14)) If lReturn > 0 Then Call oMFWB.MFWGetData(1, Reals, Text) ' if Reals array returns empty, skip to end of sub If lReturn = -1 Then GoTo Skip_End_Point_Check ' if the normal distance is less than the current distance, update the array values to the match the new point ' find an "E" (exponent) in the string, return "0.000" if found If InStr(1, Reals(0), "E", vbTextCompare) > 0 Then d = 0# Else d = Reals(0) d = Format(d, "0.000") ' normal distance (3 decimals) If d < dDistanceEnd Then cArrayReport(index, 4) = cStringName ' update Master String name cArrayReport(index, 5) = Format(Reals(5), "#.###") ' update chainage dDistanceEnd = Format(d, "0.000") ' set the new minimum testing distance to the current normal distance End If Skip_End_Point_Check: End Sub