June 19, 2013

Labeling Coordinate with Easting and Northing in AutoCAD

0 Flares 0 Flares ×

After I provided AutoLISP program to label coordinate automatically, I had some questions if it can show N, E, and elevation instead of just the coordinate text. So I made minor adjustment to the code.

This automatic labeling will create three lines of texts instead of just one line of xyz coordinate.

NE_labeling

You can open notepad, copy and paste the code below, then save it as “lb.lsp” (type it with double quote when saving in notepad). If you want to show only Easting and Northing, you can delete the marked lines. Or replace East with E or X=, and so on.

You can read our tip on how to load AutoLISP program.

I hope this is useful.

; Automatic coordinate labeling
; Edwin Prakoso
; http://cad-notes.com
;
; Limitation
; ----------
; Will use current leader style and current units setting
; If you don't want to show elevation, then modify lines marked *

 

(defun c:lb (/ p x y z ptcoord textloc)
(while
(setq p (getpoint "
Pick Point: "))
(setq textloc (getpoint "
Pick Label Location: "))
(setq x (rtos (car p)))
(setq y (rtos (cadr p)))
(setq z (rtos (caddr p))) ;*you may delete this line
(setq x (strcat "East " x))
(setq y (strcat "North " y))
(setq z (strcat "Elev. " z)) ;*you may delete this line
(command "_LEADER" p textloc "" x y z "") ;*you may delete z
)
)

Want to create this program by your own? You can also adjust it to your needs. Try this AutoLISP exercise to create labeling coordinate program here.

Advertisement



You might also interested to

About Edwin Prakoso

Edwin works as an Application Engineer in Jakarta, Indonesia. He has 4 years experience in building industry, then start to work for Autodesk reseller.
He is certified as Revit Architecture 2010 certified professional and AutoCAD 2013 certified professional.
He loves sharing his experience and starts to blog on CAD notes. Now using CAD is more to a lifestyle for him than working.
You can reach him on twitter @CADnotes. You can also connect with him on LinkedIn. If you prefer email, reach him at edwin.prakoso@cad-notes.com.

  • djmayehem

    Hi,
    I really like the three different lines feature of this code.

    I am trying to have the coordinates appear in N,E,Z format instead of E,N,Z. I have tried rearranging the code but it seems to not work for me.

    Also when I change the command to anything but ‘lb’ it loads fine but does not work once loaded in AutoCAD (even when I change it back to lb, it seems any changes to the command make it not work properly).

    Any ideas here?

    • http://cad-notes.com Edwin Prakoso

      Have you tried to reload the LISP program? You need to save it and reload it after you make changes.
      If you have, email me your code so I can take a look.

  • djmayehem

    Yes I am saving and reloading after every change. I will send you the file, it would be great if you could figure out what the issue is.

    Thank you

  • Al Bdour

    hi why does this routine show nil after existing ??

    (defun c:lpo (/ a p yvalue p1 )
      (setq a 0.0)
      (setq p (getpoint”n New Origin Point: “))
      (setq yvalue (getreal”n New Yvalue: “))
      (command “_.ucs” “o” p )
      (setq p1 (list a (* -1 yvalue) a ))
      (command “_.ucs” “o” p1 )
      princ()
    )

    • http://cad-notes.com Edwin Prakoso

      You should use (princ) not princ() at the last line.
      Try to change it and reload the AutoLISP. It should fix it.

  • Saqib

    Hi Edwin Prakoso,
             How are you, this was a useful lisp,  but I need a lisp which labels texts of offset and elevation of different points of a polyline and should ask the point to  where text will be labeled. If you have such a lisp please provide.Thanks…

    • http://cad-notes.com Edwin Prakoso

      Can you describe what you want to achieve? A sample drawing perhaps? This LISP should do similar thing, only need minor adjustment.

  • http://www.facebook.com/prasanna.hemantha.9 Prasanna Hemantha

    hello im a beginner to lisp ,campus student.this is what i need.i need a lisp code (program) to get every coordinate of points in specific layer to a notepad.i know it can be done but my knowledge is at very basic .So pls send me a code with comments that explain complex codes. im requirement is to learn that kind of lisp program not only to use it.So if U can please help me with this

  • http://www.facebook.com/artur.araujo.58 Artur Araujo

    Amigo, muito obrigado, salvaste meu dia!!!! Feliz Natal!!!!

0 Flares Twitter 0 Facebook 0 LinkedIn 0 Google+ 0 Email 0 Email to a friend 0 Flares ×