Hi
Why do I get a message that my variables ru, lu, tu and Bog1 are not used, when I am using them?
Sub CalcAlignPoints()
Dim T3 As Double
Dim FL, i6 As Int
Dim Dl As Double, T1 As Double, T2, ru, lu, cu, tu As Double
Dim B1 As Double, B2 As Double, D1 As Double, D2 As Double
Dim SID As String
Dim Bog , Bog1 As Double
Dim tau1 As Double, tau2 As Double, YA As Double, XA As Double, YB As Double, XB As Double
Dim dr1 As Double, dr2 As Double, xm1 As Double, xm2 As Double, dt As Double', tu As Double, lu As Double
Dim CName(1000) As String, CStake(1000), CYCoord(1000), CXCoord(1000) As Double, i4, i8 As Int
Dim Y2, X2, Z2 As Double
'calc the aligment poCints
Msgbox2Async("Do You Want To Process The Alignment Points?", "Process Alignment", "Yes", "No", "", Null,False)
Wait For Msgbox_Result (Answ As Int)
If Answ = DialogResponse.POSITIVE Then
'Cursor.Current = Cursors.WaitCursor
CGlobals.SQL1.ExecNonQuery("DROP TABLE IF EXISTS Align")
Query = "CREATE TABLE IF NOT EXISTS Align (No Integer, StartSV Real, YCoord Real, XCoord Real, Radius Real, Length Real, Code Integer, Stake Real)"
CGlobals.SQL1.ExecNonQuery(Query)
'Horizontal PI's
i4 = 1
i6 = 0
i8 = 0
ResultSet.Close
ResultSet = CGlobals.SQL1.ExecQuery("SELECT No FROM HorPi")
Rec=0
Do While ResultSet.NextRow
Rec=Rec+1
Try
WorkItem = Rec
Query = "SELECT * FROM HorPi WHERE No = ?"
ResultSet = CGlobals.SQL1.ExecQuery2(Query, Array As String (WorkItem))
ResultSet.NextRow
HorStartSV.Text = NumberFormat2(ResultSet.GetString("StartSV"),1,3,3,False)
CGlobals.WK2(1, i4 + 4500) = NumberFormat2(ResultSet.GetString("PiYCoord"),1,3,3,False)
CGlobals.WK2(2, i4 + 4500) = NumberFormat2(ResultSet.GetString("PiXCoord"),1,3,3,False)
CGlobals.WK2(3, i4 + 4500) = NumberFormat2(ResultSet.GetString("Radius"),1,3,3,False)
CGlobals.WK2(4, i4 + 4500) = NumberFormat2(ResultSet.GetString("TransIn"),1,3,3,False)
CGlobals.WK2(5, i4 + 4500) = NumberFormat2(ResultSet.GetString("TransOut"),1,3,3,False)
'Msgbox(CGlobals.WK2(1,i4+4500) & " g " & CGlobals.WK2(2,i4+4500),"")
i4=i4+1
Catch
Log(LastException)
End Try
Loop
ResultSet.Close
GDesign.StartStake = HorStartSV.Text
i4 = i4-1
If i4>1 Then
If IsNumber(HorStartSV.Text) = True Then
GDesign.StartStake = HorStartSV.Text
Else
GDesign.StartStake = 0
End If
CGlobals.NumbPi = i4 - 1
i4 = 1 : i1 = 1 : T3 = 0
CGlobals.WK2(1, i1 + 3500) = CGlobals.WK2(1, i4 + 4500) : CGlobals.WK2(2, i1 + 3500) = CGlobals.WK2(2, i4 + 4500) : CGlobals.WK2(3, i1 + 3500) = 0 : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0 : CGlobals.WK2(6, i1 + 3500) = GDesign.StartStake
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), CGlobals.WK2(1, (i4 + 1) + 4500), CGlobals.WK2(2, (i4 + 1) + 4500), 1) : D2 = Engine.CD : B2 = Engine.CB
Save_CalcAlign
i6 = 1 : i8 = 1
CName(i8) = "Start" : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
For i4 = 2 To CGlobals.NumbPi - 1
'first calc the Join between the straights
Engine.Join_Polar(CGlobals.WK2(1, (i4 - 1) + 4500), CGlobals.WK2(2, (i4 - 1) + 4500), CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), 1) : D1 = Engine.CD : B1 = Engine.CB
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), CGlobals.WK2(1, (i4 + 1) + 4500), CGlobals.WK2(2, (i4 + 1) + 4500), 1) : D2 = Engine.CD : B2 = Engine.CB
Dl = B2 - B1
If Abs(Dl) > 180 And Dl < 0 Then Dl = Dl + 360
If Abs(Dl) > 180 Then Dl = Dl - 360
FL = 1 : SID = "Right"
If Dl < 0 Then
FL = -1 : SID = "Left"
End If
Dl = Abs(CGlobals.Rad * Dl)
If Dl = 0 Then CGlobals.WK2(3, i4 + 4500) = 0
If Dl = 0 Or CGlobals.WK2(3, i4 + 4500) = 0 Then
'straight line or bend
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = CGlobals.WK2(1, i4 + 4500) : CGlobals.WK2(2, i1 + 3500) = CGlobals.WK2(2, i4 + 4500)
CGlobals.WK2(3, i1 + 3500) = 0 : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + D1 - T3
T3 = 0
Save_CalcAlign
i6 = i4 - 1
i8 = i8 + 1
CName(i8) = "Bend " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
Else If CGlobals.WK2(3, i4 + 4500) > 0 And CGlobals.WK2(4, i4 + 4500) = 0 And CGlobals.WK2(5, i4 + 4500) = 0 Then
'circular curve only
T1 = CGlobals.WK2(3, i4 + 4500) * Tan(Dl / 2)
If (D1 - T1 - T3) < -0.005 Then
Msgbox2Async("Curve Overlaps At BCC " & i4, "Overlap", "OK", "", "", Null,False)
Wait For Msgbox_Result (Answ As Int)
If Answ = DialogResponse.POSITIVE Then
Return
End If
End If
'Calc BCC
i1 = i1 + 1
CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + (D1 - T1 - T3)
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), B1, -T1, 2)
CGlobals.WK2(1, i1 + 3500) = CGlobals.Y2 : CGlobals.WK2(2, i1 + 3500) = CGlobals.X2
CGlobals.WK2(3, i1 + 3500) = 0 : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0
Save_CalcAlign
i6 = i4 - 1
i8 = i8 + 1
CName(i8) = "BCC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
'Next calc ECC
i1 = i1 + 1
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), B2, T1, 2)
CGlobals.WK2(1, i1 + 3500) = CGlobals.Y2 : CGlobals.WK2(2, i1 + 3500) = CGlobals.X2
Bog = Dl * CGlobals.WK2(3, i4 + 4500)
CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + Bog
CGlobals.WK2(3, i1 + 3500) = CGlobals.WK2(3, i4 + 4500) * FL : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 2
Save_CalcAlign
i8 = i8 + 1
CName(i8) = "ECC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
T3 = T1
Else
'circular curve with transitions
tau1 = 0 : tau2 = 0 : YA = 0 : XA = 0 : YB = 0 : XB = 0
T1 = 0 : T2 = 0 : dr1 = 0 : dr2 = 0 : xm1 = 0 : xm2 = 0 : Bog = 0 : Bog1 = 0
If CGlobals.WK2(4, i4 + 4500) > 0 Then
'Tangent Length In
Engine.Transition_Constants(CGlobals.WK2(4, i4 + 4500), CGlobals.WK2(4, i4 + 4500), CGlobals.WK2(3, i4 + 4500), 1)
tau1 = Abs(CGlobals.Rad * (Engine.Mb)) : YA = Engine.Y * FL : XA = Engine.X : dr1 = Engine.Y + CGlobals.WK2(3, i4 + 4500) * Cos(tau1) - CGlobals.WK2(3, i4 + 4500)
xm1 = Engine.X - CGlobals.WK2(3, i4 + 4500) * Sin(tau1)
End If
If CGlobals.WK2(5, i4 + 4500) > 0 Then
'Tangent Length Out
Engine.Transition_Constants(CGlobals.WK2(5, i4 + 4500), CGlobals.WK2(5, i4 + 4500), CGlobals.WK2(3, i4 + 4500), 1)
tau2 = Abs(CGlobals.Rad * (Engine.Mb)) : YB = Engine.Y * FL : XB = Engine.X : dr2 = Engine.Y + CGlobals.WK2(3, i4 + 4500) * Cos(tau2) - CGlobals.WK2(3, i4 + 4500)
xm2 = Engine.X - CGlobals.WK2(3, i4 + 4500) * Sin(tau2)
End If
If CGlobals.WK2(4, i4 + 4500) <> CGlobals.WK2(5, i4 + 4500) Then
T1 = 0 : T2 = 0
dt = (dr2 - dr1) / Sin(Dl)
If CGlobals.WK2(4, i4 + 4500) > 0 Then
T1 = xm1 + dt + ((CGlobals.WK2(3, i4 + 4500) + dr1)) * Tan(Dl / 2)
Else
T1 = CGlobals.WK2(3, i4 + 4500) * Tan(Dl / 2) + dt
End If
If CGlobals.WK2(5, i4 + 4500) > 0 Then
T2 = xm2 - dt + ((CGlobals.WK2(3, i4 + 4500) + dr2)) * Tan(Dl / 2)
Else
T2 = CGlobals.WK2(3, i4 + 4500) * Tan(Dl / 2) - dt
End If
Else
Engine.CalcSpiralTangent(Dl, CGlobals.WK2(3, i4 + 4500), CGlobals.WK2(4, i4 + 4500)) : T1 = Engine.L6
Engine.CalcSpiralTangent(Dl, CGlobals.WK2(3, i4 + 4500), CGlobals.WK2(5, i4 + 4500)) : T2 = Engine.L6
End If
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), B1, -T1, 2)
'BTC....This is where the Transition starts
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = Engine.Y2 : CGlobals.WK2(2, i1 + 3500) = Engine.X2 : CGlobals.WK2(3, i1 + 3500) = 0
CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + (D1 - T1 - T3)
Save_CalcAlign
i6 = i4 - 1
i8 = i8 + 1
CName(i8) = "BTC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
Bog = D1 - T1 : ru = 0 : lu = 0 : cu = 0 : tu = T1
B1 = CGlobals.Rad * (B1) : B2 = CGlobals.Rad * (B2)
If CGlobals.WK2(4, i4 + 4500) > 0 Then 'Transition in where it ends and the Circular curve starts
XA = XA - T1
Engine.Alignment_Points(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), Sin(B1), Cos(B1), YA, XA, 0.0, 0.0, 1, 2)
Bog = CGlobals.WK2(4, i4 + 4500) : Y2 = Engine.Y : X2 = Engine.X : ru = CGlobals.WK2(3, i4 + 4500) * FL : lu = CGlobals.WK2(4, i4 + 4500) : cu = 1 : tu = T1
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = Y2 : CGlobals.WK2(2, i1 + 3500) = X2 : CGlobals.WK2(3, i1 + 3500) = 0
CGlobals.WK2(4, i1 + 3500) = CGlobals.WK2(4, i4 + 4500) : CGlobals.WK2(5, i1 + 3500) = 1 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + CGlobals.WK2(4, i4 + 4500)
Save_CalcAlign
i8 = i8 + 1
CName(i8) = "BCC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
End If
If CGlobals.WK2(3, i4 + 4500) > 0 Then 'This is where the Circular Curve stops
XB = T2 - XB
Engine.Alignment_Points(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), Sin(B2), Cos(B2), YB, XB, 0.0, 0.0, 1, 2)
Bog = (Dl - tau1 - tau2) * CGlobals.WK2(3, i4 + 4500) ':If Bog<.02 rvsv=Prvsv+Bog :Goto PRS7:: :ENDIF
Y2 = Engine.Y : X2 = Engine.X : ru = CGlobals.WK2(3, i4 + 4500) * FL : lu = 0 : cu = 0.1 : tu = T2 ':Cuv$="ECC "
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = Y2 : CGlobals.WK2(2, i1 + 3500) = X2 : CGlobals.WK2(3, i1 + 3500) = CGlobals.WK2(3, i4 + 4500) * FL
CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 2 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + Bog
Save_CalcAlign
i8 = i8 + 1
CName(i8) = "ECC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
End If
If CGlobals.WK2(5, i4 + 4500) > 0 Then 'Transition out where it stops
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), (CGlobals.Deg * (B2)), T2, 2)
' 'Engine.Y2 & " " & Engine.X2 = EC\ETC Coords
Bog = CGlobals.WK2(5, i4 + 4500) : ru = CGlobals.WK2(3, i4 + 4500) * FL : lu = CGlobals.WK2(5, i4 + 4500) : cu = 2 : tu = T2 ':Cuv$="ETC "
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = Engine.Y2 : CGlobals.WK2(2, i1 + 3500) = Engine.X2 : CGlobals.WK2(3, i1 + 3500) = 0
CGlobals.WK2(4, i1 + 3500) = CGlobals.WK2(5, i4 + 4500) : CGlobals.WK2(5, i1 + 3500) = 3 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + CGlobals.WK2(5, i4 + 4500)
Save_CalcAlign
i8 = i8 + 1
CName(i8) = "ETC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
End If
T3 = T2
End If
Next
End If
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = CGlobals.WK2(1, CGlobals.NumbPi + 4500) : CGlobals.WK2(2, i1 + 3500) = CGlobals.WK2(2, CGlobals.NumbPi + 4500) : CGlobals.WK2(3, i1 + 3500) = 0 : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + D2 - T3
Save_CalcAlign
i6 = i6 + 1
i8 = i8 + 1
CName(i8) = "END" : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
'' i5 = Msgbox("Do You Want To Save Points To The Local Coord File?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Save")
'' If i5 = 6 Then
'' Cursor.Current = Cursors.WaitCursor
'' 'Now we save the Points in the Local File
'' Try
'' Con.Close()
'' Catch ex As Exception
''
'' End Try
'' Coords.OpenCoords(0)
'' For i7 = 1 To i8
'' AddCoords.Pnt_Name.Text = CName(i7)
'' AddCoords.YCoord.Text = CYCoord(i7)
'' AddCoords.XCoord.Text = CXCoord(i7)
'' AddCoords.ZCoord.Text = 0
'' AddCoords.Pnt_Description.Text = "SV " & CStake(i7)
'' Coords.SaveCoords(1, 0)
'' Next
'' End If
End If
End Sub
Thanks
Michael
Why do I get a message that my variables ru, lu, tu and Bog1 are not used, when I am using them?
B4X:
Dim T3 As Double
Dim FL, i6 As Int
Dim Dl As Double, T1 As Double, T2, ru, lu, cu, tu As Double
Dim B1 As Double, B2 As Double, D1 As Double, D2 As Double
Dim SID As String
Dim Bog , Bog1 As Double
Dim tau1 As Double, tau2 As Double, YA As Double, XA As Double, YB As Double, XB As Double
Dim dr1 As Double, dr2 As Double, xm1 As Double, xm2 As Double, dt As Double', tu As Double, lu As Double
Dim CName(1000) As String, CStake(1000), CYCoord(1000), CXCoord(1000) As Double, i4, i8 As Int
Dim Y2, X2, Z2 As Double
'calc the aligment poCints
Msgbox2Async("Do You Want To Process The Alignment Points?", "Process Alignment", "Yes", "No", "", Null,False)
Wait For Msgbox_Result (Answ As Int)
If Answ = DialogResponse.POSITIVE Then
'Cursor.Current = Cursors.WaitCursor
CGlobals.SQL1.ExecNonQuery("DROP TABLE IF EXISTS Align")
Query = "CREATE TABLE IF NOT EXISTS Align (No Integer, StartSV Real, YCoord Real, XCoord Real, Radius Real, Length Real, Code Integer, Stake Real)"
CGlobals.SQL1.ExecNonQuery(Query)
'Horizontal PI's
i4 = 1
i6 = 0
i8 = 0
ResultSet.Close
ResultSet = CGlobals.SQL1.ExecQuery("SELECT No FROM HorPi")
Rec=0
Do While ResultSet.NextRow
Rec=Rec+1
Try
WorkItem = Rec
Query = "SELECT * FROM HorPi WHERE No = ?"
ResultSet = CGlobals.SQL1.ExecQuery2(Query, Array As String (WorkItem))
ResultSet.NextRow
HorStartSV.Text = NumberFormat2(ResultSet.GetString("StartSV"),1,3,3,False)
CGlobals.WK2(1, i4 + 4500) = NumberFormat2(ResultSet.GetString("PiYCoord"),1,3,3,False)
CGlobals.WK2(2, i4 + 4500) = NumberFormat2(ResultSet.GetString("PiXCoord"),1,3,3,False)
CGlobals.WK2(3, i4 + 4500) = NumberFormat2(ResultSet.GetString("Radius"),1,3,3,False)
CGlobals.WK2(4, i4 + 4500) = NumberFormat2(ResultSet.GetString("TransIn"),1,3,3,False)
CGlobals.WK2(5, i4 + 4500) = NumberFormat2(ResultSet.GetString("TransOut"),1,3,3,False)
'Msgbox(CGlobals.WK2(1,i4+4500) & " g " & CGlobals.WK2(2,i4+4500),"")
i4=i4+1
Catch
Log(LastException)
End Try
Loop
ResultSet.Close
GDesign.StartStake = HorStartSV.Text
i4 = i4-1
If i4>1 Then
If IsNumber(HorStartSV.Text) = True Then
GDesign.StartStake = HorStartSV.Text
Else
GDesign.StartStake = 0
End If
CGlobals.NumbPi = i4 - 1
i4 = 1 : i1 = 1 : T3 = 0
CGlobals.WK2(1, i1 + 3500) = CGlobals.WK2(1, i4 + 4500) : CGlobals.WK2(2, i1 + 3500) = CGlobals.WK2(2, i4 + 4500) : CGlobals.WK2(3, i1 + 3500) = 0 : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0 : CGlobals.WK2(6, i1 + 3500) = GDesign.StartStake
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), CGlobals.WK2(1, (i4 + 1) + 4500), CGlobals.WK2(2, (i4 + 1) + 4500), 1) : D2 = Engine.CD : B2 = Engine.CB
Save_CalcAlign
i6 = 1 : i8 = 1
CName(i8) = "Start" : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
For i4 = 2 To CGlobals.NumbPi - 1
'first calc the Join between the straights
Engine.Join_Polar(CGlobals.WK2(1, (i4 - 1) + 4500), CGlobals.WK2(2, (i4 - 1) + 4500), CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), 1) : D1 = Engine.CD : B1 = Engine.CB
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), CGlobals.WK2(1, (i4 + 1) + 4500), CGlobals.WK2(2, (i4 + 1) + 4500), 1) : D2 = Engine.CD : B2 = Engine.CB
Dl = B2 - B1
If Abs(Dl) > 180 And Dl < 0 Then Dl = Dl + 360
If Abs(Dl) > 180 Then Dl = Dl - 360
FL = 1 : SID = "Right"
If Dl < 0 Then
FL = -1 : SID = "Left"
End If
Dl = Abs(CGlobals.Rad * Dl)
If Dl = 0 Then CGlobals.WK2(3, i4 + 4500) = 0
If Dl = 0 Or CGlobals.WK2(3, i4 + 4500) = 0 Then
'straight line or bend
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = CGlobals.WK2(1, i4 + 4500) : CGlobals.WK2(2, i1 + 3500) = CGlobals.WK2(2, i4 + 4500)
CGlobals.WK2(3, i1 + 3500) = 0 : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + D1 - T3
T3 = 0
Save_CalcAlign
i6 = i4 - 1
i8 = i8 + 1
CName(i8) = "Bend " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
Else If CGlobals.WK2(3, i4 + 4500) > 0 And CGlobals.WK2(4, i4 + 4500) = 0 And CGlobals.WK2(5, i4 + 4500) = 0 Then
'circular curve only
T1 = CGlobals.WK2(3, i4 + 4500) * Tan(Dl / 2)
If (D1 - T1 - T3) < -0.005 Then
Msgbox2Async("Curve Overlaps At BCC " & i4, "Overlap", "OK", "", "", Null,False)
Wait For Msgbox_Result (Answ As Int)
If Answ = DialogResponse.POSITIVE Then
Return
End If
End If
'Calc BCC
i1 = i1 + 1
CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + (D1 - T1 - T3)
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), B1, -T1, 2)
CGlobals.WK2(1, i1 + 3500) = CGlobals.Y2 : CGlobals.WK2(2, i1 + 3500) = CGlobals.X2
CGlobals.WK2(3, i1 + 3500) = 0 : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0
Save_CalcAlign
i6 = i4 - 1
i8 = i8 + 1
CName(i8) = "BCC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
'Next calc ECC
i1 = i1 + 1
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), B2, T1, 2)
CGlobals.WK2(1, i1 + 3500) = CGlobals.Y2 : CGlobals.WK2(2, i1 + 3500) = CGlobals.X2
Bog = Dl * CGlobals.WK2(3, i4 + 4500)
CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + Bog
CGlobals.WK2(3, i1 + 3500) = CGlobals.WK2(3, i4 + 4500) * FL : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 2
Save_CalcAlign
i8 = i8 + 1
CName(i8) = "ECC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
T3 = T1
Else
'circular curve with transitions
tau1 = 0 : tau2 = 0 : YA = 0 : XA = 0 : YB = 0 : XB = 0
T1 = 0 : T2 = 0 : dr1 = 0 : dr2 = 0 : xm1 = 0 : xm2 = 0 : Bog = 0 : Bog1 = 0
If CGlobals.WK2(4, i4 + 4500) > 0 Then
'Tangent Length In
Engine.Transition_Constants(CGlobals.WK2(4, i4 + 4500), CGlobals.WK2(4, i4 + 4500), CGlobals.WK2(3, i4 + 4500), 1)
tau1 = Abs(CGlobals.Rad * (Engine.Mb)) : YA = Engine.Y * FL : XA = Engine.X : dr1 = Engine.Y + CGlobals.WK2(3, i4 + 4500) * Cos(tau1) - CGlobals.WK2(3, i4 + 4500)
xm1 = Engine.X - CGlobals.WK2(3, i4 + 4500) * Sin(tau1)
End If
If CGlobals.WK2(5, i4 + 4500) > 0 Then
'Tangent Length Out
Engine.Transition_Constants(CGlobals.WK2(5, i4 + 4500), CGlobals.WK2(5, i4 + 4500), CGlobals.WK2(3, i4 + 4500), 1)
tau2 = Abs(CGlobals.Rad * (Engine.Mb)) : YB = Engine.Y * FL : XB = Engine.X : dr2 = Engine.Y + CGlobals.WK2(3, i4 + 4500) * Cos(tau2) - CGlobals.WK2(3, i4 + 4500)
xm2 = Engine.X - CGlobals.WK2(3, i4 + 4500) * Sin(tau2)
End If
If CGlobals.WK2(4, i4 + 4500) <> CGlobals.WK2(5, i4 + 4500) Then
T1 = 0 : T2 = 0
dt = (dr2 - dr1) / Sin(Dl)
If CGlobals.WK2(4, i4 + 4500) > 0 Then
T1 = xm1 + dt + ((CGlobals.WK2(3, i4 + 4500) + dr1)) * Tan(Dl / 2)
Else
T1 = CGlobals.WK2(3, i4 + 4500) * Tan(Dl / 2) + dt
End If
If CGlobals.WK2(5, i4 + 4500) > 0 Then
T2 = xm2 - dt + ((CGlobals.WK2(3, i4 + 4500) + dr2)) * Tan(Dl / 2)
Else
T2 = CGlobals.WK2(3, i4 + 4500) * Tan(Dl / 2) - dt
End If
Else
Engine.CalcSpiralTangent(Dl, CGlobals.WK2(3, i4 + 4500), CGlobals.WK2(4, i4 + 4500)) : T1 = Engine.L6
Engine.CalcSpiralTangent(Dl, CGlobals.WK2(3, i4 + 4500), CGlobals.WK2(5, i4 + 4500)) : T2 = Engine.L6
End If
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), B1, -T1, 2)
'BTC....This is where the Transition starts
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = Engine.Y2 : CGlobals.WK2(2, i1 + 3500) = Engine.X2 : CGlobals.WK2(3, i1 + 3500) = 0
CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + (D1 - T1 - T3)
Save_CalcAlign
i6 = i4 - 1
i8 = i8 + 1
CName(i8) = "BTC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
Bog = D1 - T1 : ru = 0 : lu = 0 : cu = 0 : tu = T1
B1 = CGlobals.Rad * (B1) : B2 = CGlobals.Rad * (B2)
If CGlobals.WK2(4, i4 + 4500) > 0 Then 'Transition in where it ends and the Circular curve starts
XA = XA - T1
Engine.Alignment_Points(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), Sin(B1), Cos(B1), YA, XA, 0.0, 0.0, 1, 2)
Bog = CGlobals.WK2(4, i4 + 4500) : Y2 = Engine.Y : X2 = Engine.X : ru = CGlobals.WK2(3, i4 + 4500) * FL : lu = CGlobals.WK2(4, i4 + 4500) : cu = 1 : tu = T1
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = Y2 : CGlobals.WK2(2, i1 + 3500) = X2 : CGlobals.WK2(3, i1 + 3500) = 0
CGlobals.WK2(4, i1 + 3500) = CGlobals.WK2(4, i4 + 4500) : CGlobals.WK2(5, i1 + 3500) = 1 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + CGlobals.WK2(4, i4 + 4500)
Save_CalcAlign
i8 = i8 + 1
CName(i8) = "BCC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
End If
If CGlobals.WK2(3, i4 + 4500) > 0 Then 'This is where the Circular Curve stops
XB = T2 - XB
Engine.Alignment_Points(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), Sin(B2), Cos(B2), YB, XB, 0.0, 0.0, 1, 2)
Bog = (Dl - tau1 - tau2) * CGlobals.WK2(3, i4 + 4500) ':If Bog<.02 rvsv=Prvsv+Bog :Goto PRS7:: :ENDIF
Y2 = Engine.Y : X2 = Engine.X : ru = CGlobals.WK2(3, i4 + 4500) * FL : lu = 0 : cu = 0.1 : tu = T2 ':Cuv$="ECC "
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = Y2 : CGlobals.WK2(2, i1 + 3500) = X2 : CGlobals.WK2(3, i1 + 3500) = CGlobals.WK2(3, i4 + 4500) * FL
CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 2 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + Bog
Save_CalcAlign
i8 = i8 + 1
CName(i8) = "ECC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
End If
If CGlobals.WK2(5, i4 + 4500) > 0 Then 'Transition out where it stops
Engine.Join_Polar(CGlobals.WK2(1, i4 + 4500), CGlobals.WK2(2, i4 + 4500), (CGlobals.Deg * (B2)), T2, 2)
' 'Engine.Y2 & " " & Engine.X2 = EC\ETC Coords
Bog = CGlobals.WK2(5, i4 + 4500) : ru = CGlobals.WK2(3, i4 + 4500) * FL : lu = CGlobals.WK2(5, i4 + 4500) : cu = 2 : tu = T2 ':Cuv$="ETC "
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = Engine.Y2 : CGlobals.WK2(2, i1 + 3500) = Engine.X2 : CGlobals.WK2(3, i1 + 3500) = 0
CGlobals.WK2(4, i1 + 3500) = CGlobals.WK2(5, i4 + 4500) : CGlobals.WK2(5, i1 + 3500) = 3 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + CGlobals.WK2(5, i4 + 4500)
Save_CalcAlign
i8 = i8 + 1
CName(i8) = "ETC " & i6 : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
End If
T3 = T2
End If
Next
End If
i1 = i1 + 1
CGlobals.WK2(1, i1 + 3500) = CGlobals.WK2(1, CGlobals.NumbPi + 4500) : CGlobals.WK2(2, i1 + 3500) = CGlobals.WK2(2, CGlobals.NumbPi + 4500) : CGlobals.WK2(3, i1 + 3500) = 0 : CGlobals.WK2(4, i1 + 3500) = 0 : CGlobals.WK2(5, i1 + 3500) = 0 : CGlobals.WK2(6, i1 + 3500) = CGlobals.WK2(6, (i1 - 1) + 3500) + D2 - T3
Save_CalcAlign
i6 = i6 + 1
i8 = i8 + 1
CName(i8) = "END" : CStake(i8) = NumberFormat2(CGlobals.WK2(6, i1 + 3500),1,3,3,False) : CYCoord(i8) = CGlobals.WK2(1, i1 + 3500) : CXCoord(i8) = CGlobals.WK2(2, i1 + 3500)
'' i5 = Msgbox("Do You Want To Save Points To The Local Coord File?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Save")
'' If i5 = 6 Then
'' Cursor.Current = Cursors.WaitCursor
'' 'Now we save the Points in the Local File
'' Try
'' Con.Close()
'' Catch ex As Exception
''
'' End Try
'' Coords.OpenCoords(0)
'' For i7 = 1 To i8
'' AddCoords.Pnt_Name.Text = CName(i7)
'' AddCoords.YCoord.Text = CYCoord(i7)
'' AddCoords.XCoord.Text = CXCoord(i7)
'' AddCoords.ZCoord.Text = 0
'' AddCoords.Pnt_Description.Text = "SV " & CStake(i7)
'' Coords.SaveCoords(1, 0)
'' Next
'' End If
End If
End Sub
B4X:
Thanks
Michael