# AutoLisp program



## georges (Feb 6, 2007)

I need an AutoLisp program that finds the nodes of a grid (x,y) and shows the coordinates (x,y).


----------



## srig (Jun 19, 2009)

georges said:


> I need an AutoLisp program that finds the nodes of a grid (x,y) and shows the coordinates (x,y).


hi buddy


copy and paste this prog in notepad and saveas les.lsp

N load in to acad and enjoy
:wave:


;|LEC.Lsp
Draws automatic leaders with the coordinates of the picked point
Either X & Y (2) or X, Y, & Z (3) coordinates.

Note: Don't forget to change lines 36-40 to your custom settings.

(setq RM 2)
(setq RP 0)	; RP = rtos precision (amount of decimal places)
(setq IN "N")	; IN = in units that show inches <RP = 3 or 4>, do you want the inches to be removed?
(setq FT "N")	; FT = in decimal units <RP = 2>, do you want to show a "'" <foot> mark?
(setq DV "N")	; DV = do you want to divide by 12?
;------------------------------------------------------------------------

(defun C:LEC ()
(setvar "cmdecho" 0)
(command "._undo" "be")
(setq #ORMOD (getvar "orthomode"))
(setvar "orthomode" 0)
(cond
((= RM 1)(princ "\nRoutine is formatted for Scientific Units."))
((= RM 2)(princ "\nRoutine is formatted for Decimal Units."))
((= RM 3)(princ "\nRoutine is formatted for Engineering Units."))
((= RM 4)(princ "\nRoutine is formatted for Architectural Units."))
((= RM 5)(princ "\nRoutine is formatted for Fractional Units."))
(T 
(progn
(princ "\nUnits is not set correctly. Check Lisp routine for incorrect unit value. \nExiting Routine.")
(exit)
)
)
)
(initget "2 3")
(if (= 2OR3 nil)
(progn
(setq 2OR3 (getkword "\nHow many coordinates? (2 or 3) <2>: "))
(if (= 2OR3 nil)(setq 2OR3 "2")) 
)
(progn
(setq 2OR3o 2OR3)
(setq 2OR3 (getkword (strcat "\nHow many coordinates? (2 or 3) <" 2OR3 ">: ")))
(if (= 2OR3 nil)(setq 2OR3 2OR3o)) 
)
)
(setq STPT (getpoint "\nPick Station Point: "))
(if (= (strcase DV) "N")
(progn
(setq STT1 (rtos (car STPT) RM RP))
(setq STT2 (rtos (cadr STPT) RM RP))
(setq STT3 (rtos (caddr STPT) RM RP))
)
(progn
(setq STT1 (rtos (/ (car STPT) 12) RM RP))
(setq STT2 (rtos (/ (cadr STPT) 12) RM RP))
(setq STT3 (rtos (/ (caddr STPT) 12) RM RP))
)
)
(if (and (or (= RP 3)(= RP 4))(= (strcase IN) "Y"))
(progn
(setq STT1 (substr STT1 1 (1- (strlen STT1))))
(setq STT2 (substr STT2 1 (1- (strlen STT2))))
(setq STT3 (substr STT3 1 (1- (strlen STT3))))
)
)
(if (= (strcase FT) "Y")
(progn
(if (= 2OR3 "2")
(setq STTX (strcat STT1 "', " STT2 "'"))
(setq STTX (strcat STT1 "', " STT2 "', " STT3 "'"))
)
)
(progn
(if (= 2OR3 "2")
(setq STTX (strcat STT1 ", " STT2))
(setq STTX (strcat STT1 ", " STT2 ", " STT3))
)
)
)
(princ "\nPick End of leader...")
(command "._leader" STPT pause "" STTX "")
(princ "done!")
(setvar "orthomode" #ORMOD)
(command "._undo" "e")
(setvar "cmdecho" 1)
(princ)
) 
(prompt "\n(c) Copyright TIPPIT 1999
\nType LEC to run.\tVersion 1.6 ")
(princ)


----------

