• Home
  • Training Books
  • Subscribe to Our Email Newsletter
  • About
    • Contributors
    • Feedback
    • Contact
    • Privacy policy
    • Cookie Policy

CADnotes

CAD Tutorials and Best Practices for professionals and students

  • Featured
  • AutoCAD
    • AutoLISP
  • Revit
    • Revit Architecture Basic
    • Revit MEP Basic Tutorial
  • Inventor
  • MicroStation
    • MicroStation Basic Tutorial
  • CADnotes on YouTube
You are here: Home / AutoCAD / Using AutoLISP Program to label point coordinate

Using AutoLISP Program to label point coordinate

November 25, 2010 by Edwin Prakoso 26 Comments

label

I have posted an AutoCAD tip how you can create your own label coordinate in AutoCAD using block attributes. It is nice that you can create your own block, create your own block shapes, and customize it to look anything you want to.

But there is a limitation. It will only recognize the point position from global coordinate. If you move the UCS, it will still use global coordinate. It makes sense, because if we want to label our coordinate, then usually we do use global coordinate. But what if you want to label the coordinate from UCS?

Because I’m currently learning AutoLISP, then I decided to take it as a challenge to create a program to do that. You can download the file in link you’ll find below this post.

How to use the program?

  1. Download the LISP file
  2. Load the LISP program. There are several ways to load AutoLISP program, but this is the easiest way.
  3. I wrote the code to run when I type LB then [enter]. You should be able to use it after you load the program.
  4. You need to click twice: the point you want to label and label location.
  5. It will use leader command. So if it’s too large, too small, or you want to customize it, change your style.
  6. It is also use file UNITS settings. If you want to change the format to decimal or architecture format, change it in UNITS settings.
  7. The program will continue to ask you for points until you press [esc] or [enter]. I decide to make it this way because mostly we want to create several labels at once. So you don’t need to reactivate it after you have labeled one point.

If you are following AutoLISP tutorial in CAD Notes, be patience! We will get there. Here is the code.

; Automatic coordinate labeling
; Edwin Prakoso
; https://www.cad-notes.com
;
; Limitation
; ----------
; Will use current leader style and current units setting

 

(defun c:lb (/ p x y 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)))
(setq ptcoord (strcat x ", " y ", " z))
(command "_LEADER" p textloc "" ptcoord "")
)
)

And if you want to simply download and use it, download this file. There are two files in the zip file.

  1. LB.lsp is for Labeling Coordinate (X and Y only)
  2. LBZ.lsp is for Labeling Coordinate (X, Y, and Z)

Enjoy the LISP, and share it to your friends!

Notes: After I wrote this, I realize that Shawki abo zeed have published similar code in labeling coordinate tips. It looks it has more features. If this one doesn’t work fine, you may want to try his code too. Thank you to Shawki!

About Edwin Prakoso

I work as a Solution Consultant in Datech Solutions, Tech Data Indonesia. I've been using AutoCAD since R14 and Revit since Revit Building 9. I occasionally write for AUGIWorld magazine and I am also active in Autodesk discussion forum. I'm a member of Autodesk Expert Elite, an appreciation for individuals who give contributions to the Autodesk community.
Connect with me on twitter or LinkedIn. If you want to have my new articles sent to your email inbox, you can subscribe to the newsletter.

Filed Under: AutoCAD, AutoLISP Tagged With: automatic coordinate label

3 2 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

26 Comments
Inline Feedbacks
View all comments
jojo chu
jojo chu
5 years ago

Can you help me edit the LISP, set the default output without the leader arrow, and in a format with X coordinate on top of the Y coordinate?pls thanks

3
Reply
Trevor Glass
Trevor Glass
6 years ago

Hi All I was looking for a lisp file that will list cords for me something like this 1,1023.121,1145.345,56.676
the number at the start needs keep running with each point id
its also best if it puts a number beside point id the one I seen before does this and then you pick a point on the screen out to the side and each point you id it then puts them in order by number and coord
this is for me to then lift them and put them in a notepad file txt and then into a leica total station for setting out.

3
Reply
Robert Scragg
Robert Scragg
8 years ago

Is there a way of having different colors of text for the X,Y and Z coordinates ?

I have managed to get each of the coordinates on a different line of text by using a
control character (chr 10) but I am struggling to find anything for Color.

0
Reply
Magi
Magi
8 years ago

hello
Lisp yang dibuat banyak membantu sekali mas edwin, tapi hasil keluaran unit apa bisa dibuat round off seperti di modify dimension style

0
Reply
dosala narsinga rao
dosala narsinga rao
8 years ago

Edwin Prakoso Sir,

how to create your own label coordinate in AutoCAD 2014, using AutoLISP.

Please help .

narsinga rao dosala,

Hyderabad , Telangana , Hyderabad

3
Reply
« Previous 1 2
wpdiscuz   wpDiscuz
Join Our Free Email Newsletter
  Thank you for Signing Up
Please correct the marked field(s) below.
1,true,6,Contact Email,2 1,false,1,First Name,2 1,false,1,Last Name,2

Featured

AutoCAD customization: 5 articles to learn about CUI

AutoCAD CUI customization roundup. If you want to customize AutoCAD interface, here you can learn how you can create partial customization file, create command, working with ribbon, toolbar and menu, and more cool things!

Recent Articles

  • Revit 2024.1 Update is Released
  • What’s New in Revit 2024: Bending Detail
  • What’s New in Revit 2024: The Dark Theme

Advertisement

New on CADnotes

  • Revit 2024.1 Update is Released
  • What’s New in Revit 2024: Bending Detail
  • What’s New in Revit 2024: The Dark Theme
  • Autodesk Build: Using Assets for Progress Tracking
  • My Home on the ACC Unified Platform

Meet the Authors

avatar for
avatar for
avatar for
avatar for
avatar for
avatar for

Get Connected

CADnotes on FacebookCADnotes on InstagramCADnotes on TwitterCADnotes on YouTube

© 2009 – 2023 CADnotes · Feedback · Privacy Policy · Become an affiliate

wpDiscuz