Sub IntersectWith_Example()
' This example creates two lines and finds the points at
' which they intersect useing the .IntersectWith method
Dim myLine1 As AcadLine
Dim myLine2 As AcadLine
Dim Pt1(0 To 2) As Double
Dim Pt2(0 To 2) As Double
Pt1(0) = 4: Pt1(1) = 4: Pt1(2) = 0
Pt2(0) = 7: Pt2(1) = 1: Pt2(2) = 0
Set myLine1 = ThisDrawing.ModelSpace.AddLine(Pt1, Pt2)
myLine1.Update
Pt1(0) = 5: Pt1(1) = 2: Pt1(2) = 0
Pt2(0) = 8: Pt2(1) = 4: Pt2(2) = 0
Set myLine2 = ThisDrawing.ModelSpace.AddLine(Pt1, Pt2)
myLine2.Update
Dim intPoints As Variant
intPoints = myLine1.IntersectWith(myLine2, acExtendNone)
' Print all the intersection points
Dim i As Integer, j As Integer, k As Integer
Dim sBuf As String
If VarType(intPoints) <> vbEmpty Then
For i = LBound(intPoints) To UBound(intPoints)
sBuf = "Intersection Point[" & k & "] is: " & intPoints(j) & "," & intPoints(j + 1) & "," & intPoints(j + 2)
MsgBox sBuf, , "IntersectWith Example"
sBuf = vbNullString
i = i + 2
j = j + 3
k = k + 1
Next
End If
End Sub
Bricscad™ is commercialized by Bricsys NV. Bricsys NV and Vondle NV are fully owned subsidiaries of Menhirs NV. © 2001- Menhirs NV - All rights reserved. |