This could be done in VBA too, do you really want to use .lsp?

Registered forum members do not see this ad.
Does anyone know or have a lisp, that when you use the id command will display the co-ordinates of that point as text next to it?
It would be great if I could format the co-ordinate to 2 decimal places.
I'm using AutoCAD 2007.


This could be done in VBA too, do you really want to use .lsp?

VBA would be fine, although i'm not familiar with them, is it as easy as loading a lsp?




Here's a real simple one I did that may be all you need. Your text style height should be 0.0 or the "text" command will blow a gasket:
Code:(princ "\nType LBLPT to start") (defun c:lblpt () (setq precis 2);;set decimal places here (while (setq pt (getpoint "\nSelect point to label: ")) (setq Xval (car pt) Yval (cadr pt)) (setq Xtxt (rtos Xval 2 precis)) (setq Ytxt (rtos Yval 2 precis)) (command "text" pt "" "0" Xtxt) (command "text" "" ytxt) );while (princ) )
what the HELL does that mean? seriously... if i gotta learn all that crap, then i have a LOOOOOOONG way to go in AutoCAD. and i thought i was half-ass decent. lolOriginally Posted by CarlB
Tannar Frampton | Facilities Engineering | Revit 2013
Personal Projects | Fender Squier Stratocaster | Custom Smoker | Concrete Patio

this seems to return a zero value for the X co-ord, any ideas?
i loaded this as a lsp (is that correct?)




Yes, paste text to a ".lsp" file and load as a lisp file. Or you could paste the code into the command line for a one-time use.
Probable reason for 0.0 as x coordinate, if not this I don't know.
-your text height is set to a fixed value (I warned about this in my initial post) so the text command does not prompt for height, the "0" meant for rotation is getting entered as the x value.
Try using a style with height=0.0

Thanks, this works brilliantly.
Would it be possible format the co-ordinate so there is a bracket at the start and end and a "," to separate x & y.
I've tried putting these into the lsp myself but with no joy, so i'd be really interested to see how this could be done. Can anyone recomend any UK based training for lsp or VBA?
many thanks.




Registered forum members do not see this ad.
daiharv,
Here's your requested mods:
Code:(princ "\nType LBLPT to start") (defun c:lblpt () (setq precis 2);;set decimal places here (while (setq pt (getpoint "\nSelect point to label: ")) (setq Xval (car pt) Yval (cadr pt)) (setq Xtxt (rtos Xval 2 precis)) (setq Ytxt (rtos Yval 2 precis)) (setq TxtString (strcat "[" Xtxt ", " Ytxt "]")) (command "text" pt "" "0" TxtStringXtxt) );while (princ) )
Bookmarks