IntersectWith method for 2 AcadLines

IntersectWith method for 2 AcadLines

Anonymous
Not applicable
1,621 Views
2 Replies
Message 1 of 3

IntersectWith method for 2 AcadLines

Anonymous
Not applicable

Hi, I am kind of confused using the IntersectWith method. It is working just like I thought, if my 2 AcadLines cross. But if they overlie (look at coords) it doesn't detect it as I wish. So I wanna know if it's about the IntersectWith method or more likely my code. I am thankful for any help or ideas to solve my issue.

 

Sub Intersection()

Dim line(9) As AcadLine
Dim startp(2) As Double
Dim endp(2) As Double

startp(0) = 0
startp(1) = 0
endp(0) = 30
endp(1) = 0
Set line(0) = ThisDrawing.ModelSpace.AddLine(startp, endp)

startp(0) = 20
startp(1) = 0
endp(0) = 50
endp(1) = 0

Set line(1) = ThisDrawing.ModelSpace.AddLine(startp, endp)


Dim intPoints As Variant
intPoints = line(1).IntersectWith(line(0), acExtendNone)
If UBound(intPoints) = -1  Then
Debug.Print "intersection point not existing"
                                               Else
Debug.Print "intersection point existing"
End If


End Sub

 

0 Likes
Accepted solutions (1)
1,622 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor
Accepted solution

Intersection of 2 lines means there is/are certain/limited points where the 2 lines meet. In your case, the 2 lines are parallel with offset being 0. So, can you tell how many points the 2 line meet/share? If you can tell, then the 2 lines intersect. Obviously, there are unlimited/countless points the 2 lines share, thus they do not intersect, at least in the sense of the IntersectWith() method.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

Anonymous
Not applicable

That was just what I worried about.

0 Likes