Hi, I wonder if there is a way to get an intersecting point coordinate of two polylines(lines) programmatically.
For example, like in the below sample picture, I need to get coordinates of the points in the red cycles.
Is there any method that I can easily use?
Could I get a sample code snippet that computes the coordinates? (in C# & ObjectARX 2010 if possible?)
I've looked up "Through the Interface" and this disscussion group. couldn't find any useful yet.
Please someone help me. =(
Thank you for your time.
Jake
Solved! Go to Solution.
Solved by Hallex. Go to Solution.
Check this out
[CommandMethod("checkinters")] public void CheckInterference() { Database db = HostApplicationServices.WorkingDatabase; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { try { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); PromptEntityOptions peo = new PromptEntityOptions("\nSelect a first polyline >>"); peo.SetRejectMessage("\nSelected object might be of type polyline only >>"); peo.AddAllowedClass(typeof(Polyline), false); PromptEntityResult res; res = ed.GetEntity(peo); if (res.Status != PromptStatus.OK) return; Entity ent = (Entity)tr.GetObject(res.ObjectId, OpenMode.ForRead); if (ent == null) return; Polyline poly = (Polyline)ent as Polyline; peo = new PromptEntityOptions("\nSelect second polyline >>"); peo.SetRejectMessage("\nSelected object might be of type polyline only >>"); peo.AddAllowedClass(typeof(Polyline), false); res = ed.GetEntity(peo); if (res.Status != PromptStatus.OK) return; ent = (Entity)tr.GetObject(res.ObjectId, OpenMode.ForRead); if (ent == null) return; Polyline poly2 = (Polyline)ent as Polyline; Point3dCollection pts = new Point3dCollection(); poly.IntersectWith(poly2, Intersect.OnBothOperands, pts, (int)IntPtr.Zero, (int)IntPtr.Zero); Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("Hint:\nNumber of Verices: {0}\nNumber of Intersections: {1}", poly.NumberOfVertices, pts.Count)); // test for visulization only foreach (Point3d pt in pts) { Circle circ = new Circle(pt,Vector3d.ZAxis,10 * db.Dimtxt); circ.ColorIndex = 1; btr.AppendEntity(circ); tr.AddNewlyCreatedDBObject(circ, true); } tr.Commit(); } catch (System.Exception ex) { ed.WriteMessage("\n{0}\n{1}", ex.Message, ex.StackTrace); } } }
~'J'~
Can you upload the piece of this drawing
for testing?
~'J'~
Hi, i need to get coordinates of an image in autocad for my final year project. I am a student of computer engineering so dont have autocad background. Any help will highly be appriciated, thankyou.
Hello,
After long time i am back to customization.
In this above code, rather than user selecting polylines, can't we use select all option to check interferece.
if yes what are the changes to be made to the above code.
Regards,
Amit