01-14-2018
06:56 AM
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
01-14-2018
06:56 AM
I've edited your program to include a z coordinate and output all three coordinates on the same line.
(defun C:LP(/ PNT1 P1X P1Y STDY DY COORDN COORDE PTXT) (setq PNT1 (getpoint "\nPick coordinate point: ")) (setq P1X (car pnt1)) ;x coord (setq P1Y (cadr pnt1)) ;y coord (setq P1Z (caddr pnt1)) ;z coord <-- (setq STDX (rtos P1X 2 2)) (setq STDY (rtos P1Y 2 2)) (setq STDZ (rtos P1Z 2 2)) ;;;(setq COORDE (strcat "X " STDX )) <-- remove ;;;(setq COORDN (strcat "Y " STDY )) <-- remove (setq msg (strcat "X " STDX ", Y " STDY ", Z " STDZ)) (setq PTXT (getpoint "\nPick text location: ")) (command "LEADER" PNT1 PTXT "" msg "") (princ) )
To automatically load the program when you start up AutoCAD go here.
The program will work in 2D or 3D but will always output a Z coordinate.
To delete trailing zeros you may need to write a custom vlisp program that examines the text string of the coordinate from the last character backwards and deletes it if it is a zero and until the first non-zero number or the decimal point has been encountered. Perhaps there is such a routine already available that you can find via a web search.
BTW, are you familiar with the coordinates command? If not, try it out!
lee.minardi