.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Obtain Northing/Easting

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
cschildmeier
795 Views, 3 Replies

Obtain Northing/Easting

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.  

3 REPLIES 3
Message 2 of 4
rkmcswain
in reply to: cschildmeier

The end points should be in X,Y,Z format. 

 

Y = Northing and X = Easting

 

R.K. McSwain     | CADpanacea | on twitter
Message 3 of 4
cschildmeier
in reply to: rkmcswain

AcDb.Line.Endpoint.X/Y/Z

 

Just as simple as I expected it should be.

 

Thanks!

Message 4 of 4
Hallex
in reply to: cschildmeier

    
// 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

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost