Community
Am I just not looking in the right spot or do I need to do maths to figure it out? There are common things that are obviously easy to grab out of Autodesk.AutoCAD.DatabaseServices.Line(length/start point etc) but northing/easting aren't in there.
Solved! Go to Solution.
Solved by rkmcswain. Go to Solution.
The end points should be in X,Y,Z format.
Y = Northing and X = Easting
AcDb.Line.Endpoint.X/Y/Z
Just as simple as I expected it should be.
Thanks!
// place some points on screen, set 'pdmode' to 34 (optional) // then select all points // not sure about formatting, probably it's need to remove space // between char and number, so let me know about [CommandMethod("lx")] public static void PointLabeling() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; Matrix3d ucs = ed.CurrentUserCoordinateSystem; TypedValue[] filter = { new TypedValue((int)DxfCode.Start, "POINT") }; SelectionFilter filterSset = new SelectionFilter(filter); PromptSelectionOptions pso = new PromptSelectionOptions(); // pso.SingleOnly = true;//comment this if you want to label multiple polylines pso.MessageForAdding = "Select points to label >> "; PromptSelectionResult psr = ed.GetSelection(pso, filterSset); if (psr.Status != PromptStatus.OK) return; PromptDoubleOptions pdo = new PromptDoubleOptions("\nEnter text size: "); pdo.AllowZero = true; pdo.AllowNone = true; pdo.UseDefaultValue = true; pdo.DefaultValue = db.Textsize; PromptDoubleResult res; res = ed.GetDouble(pdo); if (res.Status != PromptStatus.OK) return; double theight = res.Value; if (theight == 0) theight = 0.2; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { try { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); ObjectId[] ids = psr.Value.GetObjectIds(); for (int i = 0; i < ids.Length; i++) { DBPoint dpt = tr.GetObject(ids[i], OpenMode.ForRead) as DBPoint; Point3d lp = dpt.Position; string strLab= string.Format(" E {0:f3}\n N {1:f3}",lp.X,lp.Y); // create mtext MText mtxt = new MText(); mtxt.SetDatabaseDefaults(); mtxt.Attachment = AttachmentPoint.MiddleLeft; mtxt.Location = lp; mtxt.TextHeight = theight; mtxt.Width = 0.0; mtxt.Contents = strLab; mtxt.Layer = "0"; mtxt.ColorIndex = 5; mtxt.TransformBy(ucs); // add mtext to database and transaction btr.AppendEntity(mtxt); tr.AddNewlyCreatedDBObject(mtxt, true); tr.TransactionManager.QueueForGraphicsFlush(); } doc.TransactionManager.FlushGraphics(); tr.Commit(); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format( "Error:\n{0}\nTrace:\n{1}", ex.Message, ex.StackTrace)); } } }
Chris, see if this helps