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?
- Download the LISP file
- Load the LISP program. There are several ways to load AutoLISP program, but this is the easiest way.
- I wrote the code to run when I type LB then [enter]. You should be able to use it after you load the program.
- You need to click twice: the point you want to label and label location.
- It will use leader command. So if it’s too large, too small, or you want to customize it, change your style.
- It is also use file UNITS settings. If you want to change the format to decimal or architecture format, change it in UNITS settings.
- 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
; Will use current leader style and current units setting
(defun c:lb (/ p x y ptcoord textloc)
(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.
- LB.lsp is for Labeling Coordinate (X and Y only)
- 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!