Intersectwith without z-coordinate

Intersectwith without z-coordinate

stefanveurink68AXD
Advocate Advocate
320 Views
1 Reply
Message 1 of 2

Intersectwith without z-coordinate

stefanveurink68AXD
Advocate
Advocate

I know the .intersectwith method. 

 

Is there and easy way to find an 'appearent intersection'. So without considering the z-values? 

 

For example, There's a line from (1,1) tot (3,3) and a line form (1,3) to (3,1), they intersect at (2,2). (X,Y). 

But when there's a line form (1,1,2) to (3,3,2) and a line from (1,3,4) to (3,1,4) they only SEEM to intersect at (2,2), but really don't. However is there an easy way to still find (2,2) or should I project both the lines to the same plane?

0 Likes
Accepted solutions (1)
321 Views
1 Reply
Reply (1)
Message 2 of 2

_gile
Consultant
Consultant
Accepted solution

Hi,

You should use the IntersectWith overload which takes a projection plane as argument:

https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseSer...

using (var line1 = new Line(new Point3d(1, 1, 2), new Point3d(3, 3, 2)))
using (var line2 = new Line(new Point3d(1, 3, 4), new Point3d(3, 1, 4)))
{
    var points = new Point3dCollection();
    var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
    line1.IntersectWith(line2, Intersect.OnBothOperands, plane, points, IntPtr.Zero, IntPtr.Zero);
    var ed = Application.DocumentManager.MdiActiveDocument.Editor;
    foreach (Point3d point in points)
    {
        ed.WriteMessage($"\n{point}");
    }
}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub