'=================================================================== ' LineToPointSnap '=================================================================== Public Sub LineToPointSnap() Const Snap_Tolerance = 5 Dim Valve As IPoint Dim LineP1 As IPoint Dim LineP2 As IPoint Dim Length As Double Dim d1 As Double Dim d2 As Double Dim text Set Valve = New Point Set LineP1 = New Point Set LineP2 = New Point Valve.x = 30 ' Valve Valve.y = 30 LineP1.x = 32 ' Main Line LineP1.y = 32 LineP2.x = 100 LineP2.y = 50 text = "Valve = " & Valve.x & " " & Valve.y text = text & vbCrLf & "Original Line " & LineP1.x & " " & LineP1.y & " " & LineP2.x & " " & LineP2.y d1 = g.Length(Valve, LineP1) d2 = g.Length(Valve, LineP2) text = text & vbCrLf & "Distance to End Points of Line: d1 = " & g.R(d1) & " d2 = " & g.R(d2) If (g.Min(d1, d2) < Snap_Tolerance) Then If (d1 <= d2) Then LineP1.x = Valve.x LineP1.y = Valve.y text = text & vbCrLf & " Point 1 Snapped" Else LineP2.x = Valve.x LineP2.y = Valve.y text = text & vbCrLf & " Point 2 Snapped" End If Else text = text & vbCrLf & " NOT SNAPPED" End If text = text & vbCrLf & "New Line " & LineP1.x & " " & LineP1.y & " " & LineP2.x & " " & LineP2.y MsgBox (text) End Sub '=================================================================== ' LineToLine '=================================================================== Public Sub LineToLine() Dim base1 As IPoint Dim base2 As IPoint Dim ref1 As IPoint Dim ref2 As IPoint Dim Length As Double Set base1 = New Point Set base2 = New Point Set ref1 = New Point Set ref2 = New Point Dim Angle As Double Dim text base1.x = 30 ' base line base2.y = 30 base2.x = 100 base2.y = 100 ref1.x = 50 ' Reference line ref2.y = 50 ref2.x = 100 ref2.y = 50 Angle = g.Angle(base1, base2) Length = g.Length(base1, base2) text = "Angle (Base Point1 to Point2) = " & g.Degree(Angle) & " Length of Base = " & g.R(Length) text = text & vbCrLf & "Original Line " & ref1.x & " " & ref1.y & " " & ref2.x & " " & ref2.y g.MovePointToOrigin ref1, base1 g.MovePointToOrigin ref2, base1 text = text & vbCrLf & "Moved to Origin " & ref1.x & " " & ref1.y & " " & ref2.x & " " & ref2.y g.RotatePoint ref1, -Angle g.RotatePoint ref2, -Angle text = text & vbCrLf & "Rotated Line " & g.R(ref1.x) & " " & g.R(ref1.y) & " " & g.R(ref2.x) & " " & g.R(ref2.y) MsgBox (text) End Sub