.NET

Reply
Contributor
GStevens
Posts: 19
Registered: ‎04-20-2006
Message 1 of 6 (309 Views)

Polyline3d intersect

309 Views, 5 Replies
05-11-2006 07:49 PM
Hello everyone,

1. How to get the intersection of 2 Polyline3d in different plane?
I tried using IntersectWith() but it return no intersection because the polylines lies in different plane.
2. How about Aparent Intersect? Is there anyone who can teach me how to implement this in my C# code?

Thank you.

GS
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 2 of 6 (309 Views)

Re: Polyline3d intersect

05-12-2006 06:08 AM in reply to: GStevens
What about create projections of those Polyline3d on single plan (with help of Polyline3d.GetProjectedCurve method)?
After than you can do IntersectWith() with projections.
Contributor
GStevens
Posts: 19
Registered: ‎04-20-2006
Message 3 of 6 (309 Views)

Re: Polyline3d intersect

05-12-2006 11:35 PM in reply to: GStevens
Dear Alexander Rivilis,

I'll do that. Thank you.

GS
Contributor
GStevens
Posts: 19
Registered: ‎04-20-2006
Message 4 of 6 (309 Views)

Re: Polyline3d intersect

05-12-2006 11:46 PM in reply to: GStevens
Dear Alexander Rivilis,

I'll appreciate if you can show me a snippet code how to do it.
Thank you in advance.

GS
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 5 of 6 (309 Views)

Re: Polyline3d intersect

05-13-2006 01:55 AM in reply to: GStevens
[code]
using System ;
using System.Collections;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.ApplicationServices;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: CommandClass(typeof(ClassLibrary.Class))]

namespace ClassLibrary
{
public class Class
{
[CommandMethod("IntPoly3d")]
static public void IntPoly3d()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Polyline3d pl1 = SelectPoly3d("\nSelect first Polyline3d: ");
if (pl1 == null) return;
Polyline3d pl2 = SelectPoly3d("\nSelect second Polyline3d: ");
if (pl2 == null) return;
// We can project our plines in direction of Z axis of WCS,
// but you can use another project plane
Vector3d dir = new Vector3d(0,0,1);
Point3d orig = new Point3d (0,0,0);
// Plane of WCS
Plane planeWCS = new Plane(orig, dir);
Curve pl1_prj = pl1.GetProjectedCurve(planeWCS,dir); pl1.Dispose();
Curve pl2_prj = pl2.GetProjectedCurve(planeWCS,dir); pl2.Dispose();
Point3dCollection pts = new Point3dCollection();
pl1_prj.IntersectWith(pl2_prj,Intersect.OnBothOperands,pts,0,0);
if (pts.Count > 0)
{
ed.WriteMessage("\nNumber of intersection: {0}",pts.Count);
foreach (Point3d pt in pts) ed.WriteMessage("\n Point: {0}",pt);
}
else
{
ed.WriteMessage("\nNo intersection!");
}
pl1_prj.Dispose(); pl2_prj.Dispose();
}
static private Polyline3d SelectPoly3d(string str)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
PromptEntityResult rs = ed.GetEntity(str);
if (rs.Status == PromptStatus.OK)
{
Transaction trans = db.TransactionManager.StartTransaction();
Entity ent = (Entity)trans.GetObject(rs.ObjectId, OpenMode.ForRead);
Polyline3d pl = ent as Polyline3d;
trans.Commit();
if (pl == null) ed.WriteMessage("\nIt is not Polyline3d!");
return pl;
}
return null;
}
}
}
[/code]
Contributor
GStevens
Posts: 19
Registered: ‎04-20-2006
Message 6 of 6 (309 Views)

Re: Polyline3d intersect

05-14-2006 09:36 PM in reply to: GStevens
Dear Alexander Rivilis,
Thank you so much to your help it helps me a lot however its my mistake that I was not able to inform you that I need also the value of Z coordinate. What should I do so that I get also get it like Apparent Intersect does?
Once again thank you.

GS

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community