get intersection point problem

get intersection point problem

Anonymous
Not applicable
703 Views
4 Replies
Message 1 of 5

get intersection point problem

Anonymous
Not applicable

hi, i'm having problem with the intersectwith function

 

It maybe a simple problem for you guys, but I can't find the answer for this problem

 

I tried to keep the intersection point of two lines in a variable of point2d named poinintersection as shown below

 

dim pointintersection as point2d

pointintersection = lineseg1.IntersectWith(lineseg2)

 

but then it resulted error

Value of type '1-dimensional array of Autodesk.AutoCAD.Geometry.Point2d' cannot be converted to 'Autodesk.AutoCAD.Geometry.Point2d'.


so, what should i do to get the intersection point using intersectwithfunction ?

 

thank you

 

 

 

 

0 Likes
704 Views
4 Replies
Replies (4)
Message 2 of 5

Marat.Mirgaleev
Alumni
Alumni

Hi,

 

   The IntersectWith() method returns an array of intersection points. You simply need to declare your pointintersection as an array:

dim pointintersection as point2d()  ' Note the parenthesis here

 



Marat Mirgaleev
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 5

Anonymous
Not applicable

I don't understand, why it returns an array of intersection points ? Is it possible that two lines have more than one intersection point ?

 

and then, now the intersectwith method results (Nan,Nan)

do you know what probably wrong ?

 

thanks for your help

 

0 Likes
Message 4 of 5

Marat.Mirgaleev
Alumni
Alumni

It's because Line is derived from Curve.

Two curves in general may have many points of intersection.

You need to iterate through the returned array of points.

Why it's (Nan, Nan) - please, double check that the line segments really do intersect 🙂



Marat Mirgaleev
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 5 of 5

Anonymous
Not applicable

problem solved, thank you for your help !

0 Likes