Private Function DrawSideElbow(PDM As Double, PL As Double, PR As Double, FT As Double, FOD As Double, FID As Double, FTC As Double, Ang As Double, PB0 As Point, View As Integer)
'On Error Resume Next
Dim L As Double
'Dim R1 As Double
'Dim R2 As Double
Dim PLine As AcadPolyline
Dim P(1 To 4) As Point
Dim PB1 As Point
Dim Ang1 As Double
Dim Ang2 As Double
Dim X As Double
Select Case View
' Draw Side View
Case 0
'draw first elbow part
L = PL - (PR + FT)
'R1 = PR + PDM / 2
'R2 = PR - PDM / 2
PB1.X = PB0.X - L: PB1.y = PB0.y + L
P(1) = GetPoint(PB0, -90, (L + PR + PDM / 2))
P(2) = GetPoint(PB1, -90, (PR + PDM / 2))
P(3) = GetPoint(PB1, -180, (PR + PDM / 2))
P(4) = GetPoint(PB0, -180, (L + PR + PDM / 2))
Set PLine = DrawPolyLine(P())
PLine.SetBulge 1, Tan(90 / (22 / 7))
PLine.Layer = "BIO-PIPE1"
P(1) = GetPoint(PB0, -90, (L + PR - PDM / 2))
P(2) = GetPoint(PB1, -90, (PR - PDM / 2))
P(3) = GetPoint(PB1, -180, (PR - PDM / 2))
P(4) = GetPoint(PB0, -180, (L + PR - PDM / 2))
Set PLine = DrawPolyLine(P())
PLine.SetBulge 1, Tan(90 / (22 / 7))
PLine.Layer = "BIO-PIPE1"
'draw first flange
'PF.X = P0.X + L
'PF.y = P0.y
'DrawFlange FOD, FID, FT, FTC, Ang, PF, DegToRad(-90)
'draw second flange
'PF.X = P0.X - PR
'PF.y = P0.y - PR - L
'DrawFlange FOD, FID, FT, FTC, Ang, PF, -180
Case 1
Case 2
End Select
End Function
Public Function GetPoint(P As Point, Angle As Double, R As Double) As Point
'Dim X, Y As Double
GetPoint.y = P.y - (Sin(DegToRad(Angle)) * R)
GetPoint.X = P.X + (Cos(DegToRad(Angle)) * R)
End Function
Private Function DegToRad(Ang As Double) As Double
DegToRad = Ang * (22 / 7) / 180
End Function
Private Function RadToDeg(Ang As Double) As Double
RadToDeg = Ang * 180 / (22 / 7)
End Function
Public Function GetPoint(P As Point, Angle As Double, R As Double) As Point
'Dim X, Y As Double
GetPoint.y = P.y - (Sin(DegToRad(Angle)) * R)
GetPoint.X = P.X + (Cos(DegToRad(Angle)) * R)
End Function