Community
Hi
I am trying to get point on polyline at given distance from point i choose. Synce GetPointAtDist only uses polyline start point I tryed to brake polyline so startpoint to be at start point of measurement but I get eNotin database? Anyone have idea what I am doint wrong??
Here's my code:
[CommandMethod("stacpoly", CommandFlags.Modal)] public void stacpoly() // This method can have any name { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database db = doc.Database; ObjectId pid = funkcije.odaberi_polyline("Od poly"); Point3d t = funkcije.pp("Odaberi tocku"); Point3d t1=default(Point3d); Point3d t2 = default(Point3d); using (Transaction tr = db.TransactionManager.StartTransaction()) { Polyline pline = (Polyline)tr.GetObject(pid, OpenMode.ForWrite); if (pline.EndPoint.X<pline.StartPoint.X) { try { pline.ReverseCurve(); } catch( Autodesk.AutoCAD.Runtime.Exception ex) { ed.WriteMessage(ex.Message); } } t = pline.GetClosestPointTo(t,false); Point3dCollection tpoly = new Point3dCollection(); tpoly.Add(pline.StartPoint); tpoly.Add(t); tpoly.Add(t); tpoly.Add(pline.EndPoint); DBObjectCollection plines = pline.GetSplitCurves(tpoly); if (plines.Count==2) { Polyline p1; Polyline p2; DBObject dbo1 = plines[0]; try { p1 = (Polyline)dbo1; tr.AddNewlyCreatedDBObject(dbo1, true); p1.ReverseCurve(); DBObject dbo2 = plines[1]; p2 = (Polyline)dbo2; tr.AddNewlyCreatedDBObject(p2, true); t1 = p1.GetPointAtDist(200); t2 = p2.GetPointAtDist(200); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { ed.WriteMessage(ex.Message); } } tpoly.Dispose(); plines.Dispose(); pline.Erase(); tr.Commit(); } Line l1 = new Line(new Point3d(0, 0, 0), t1); Line l2 = new Line(new Point3d(0, 0, 0), t2); }
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.