Ish Posted July 4, 2019 Posted July 4, 2019 (edited) DEAR SIR, I NEED A LISP PROGRAM (3 IN 1) FOR XYZ COORDINATES LABEL IN AUTOCAD WITH LEADER, THAT LISP MUST ASK THE CHOICE: EASTING+NORTHING, EASTING+NORTHING+Z, AND Z. SEE ATTACH IMAGE Edited July 4, 2019 by Ish MODIFY Quote
BIGAL Posted July 5, 2019 Posted July 5, 2019 (edited) The suggestion is good a couple of changes put the two getpoint into a while so you can repeat. ; pick a point and make a leader ; by Alan H July 2019 (defun C:cxy ( / pt1 pt2 ans txtx txty txtz oldlay) (command "-layer" "m" "Co-ordinates" "c" 1 "Co-ordinates" "") (setq oldlay (getvar 'clayer)) (setvar 'clayer "Co-ordinates") (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (setq ans (ah:butts but "V" '("Please choose" "E-N" "E-N-Z" "Z"))) (setvar "cmdecho" 0) (while (setq pt1 (getpoint "\nPick point for co-ordinate: ")) (setq pt2 (getpoint pt1 "\nPick point for text: ")) (if pt2 (progn (setq txtx (strcat "E= " (rtos (car pt1) 2 3) )) (setq txty (strcat "N= " (rtos (cadr pt1) 2 3) )) (setq txtz (strcat "Z= " (rtos (caddr pt1) 2 3) )) (princ "\n") (cond ((= ans "E-N")(command "leader" pt1 pt2 "Annotation" txtx txty "")) ((= ans "E-N-Z")(command "leader" pt1 pt2 "Annotation" txtx txty txtz "")) ((= ans "Z")(command "leader" pt1 pt2 "Annotation" txtz "")) ) ) ) ) (setvar 'clayer oldlay) (princ) ) (c:cxy) . Multi radio buttons.lsp Edited July 9, 2019 by BIGAL 1 Quote
Tharwat Posted July 5, 2019 Posted July 5, 2019 Hi, Give this a shot. (defun c:enz (/ key pnt dim a b c) ;; Tharwat - 5.Jul.2019 ;; (and (or (initget "EN ENZ Z") (setq key (cond ((getkword "\nPick your go [EASTING+NORTHING , EASTING+NORTHING+Z , Z] [EN ENZ Z] < EN > :" ) ) ("EN") ) ) ) (setq pnt (getpoint "\nSpecify base point : ")) (setq dim (getvar 'DIMZIN)) (setvar 'DIMZIN 0) (mapcar 'set '(a b c) (mapcar '(lambda (k p) (strcat k (rtos p 2 4))) '("E=" "N=" "Z=") pnt ) ) (setvar 'DIMZIN dim) (command "_.LEADER" "_none" pnt "\\" "" (nth (vl-position key '("EN" "ENZ" "Z")) (list (strcat a "\\P" b) (strcat a "\\P" b "\\P" c) c) ) "" ) ) (princ) ) 1 Quote
Ish Posted July 6, 2019 Author Posted July 6, 2019 On 7/5/2019 at 3:00 AM, BIGAL said: The suggestion is good a couple of changes put the two getpoint into a while so you can repeat. ; pick a point and make a leader ; by Alan H July 2019 (defun C:cxy () (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (setq ans (ah:butts but "V" '("Please choose" "E-N" "E-N-Z" "Z"))) (setvar "cmdecho" 0) (while (setq pt1 (getpoint "\nPick point for co-ordinate: ")) (setq pt2 (getpoint pt1 "\nPick point for text: ")) (if pt2 (progn (setq txtx (strcat "E= " (rtos (car pt1) 2 3) )) (setq txty (strcat "N= " (rtos (cadr pt1) 2 3) )) (setq txtz (strcat "Z= " (rtos (caddr pt1) 2 3) )) (princ "\n") (cond ((= ans "E-N")(command "leader" pt1 pt2 "Annotation" txtx txty "")) ((= ans "E-N-Z")(command "leader" pt1 pt2 "Annotation" txtx txty txtz "")) ((= ans "Z")(command "leader" pt1 pt2 "Annotation" txtz "")) ) ) ) ) (setvar "cmdecho" 1) (princ) ) (c:cxy) Thanks, it working smoothly That is good one, Plz Add a code for layer: in that lisp program, automatic create layer for leader and text. leader and text must be come in layer, Layer name "Coordinate" Multi radio buttons.lsp 2.47 kB · 5 downloads Quote
Ish Posted July 6, 2019 Author Posted July 6, 2019 17 hours ago, Tharwat said: Hi, Give this a shot. (defun c:enz (/ key pnt dim a b c) ;; Tharwat - 5.Jul.2019 ;; (and (or (initget "EN ENZ Z") (setq key (cond ((getkword "\nPick your go [EASTING+NORTHING , EASTING+NORTHING+Z , Z] [EN ENZ Z] < EN > :" ) ) ("EN") ) ) ) (setq pnt (getpoint "\nSpecify base point : ")) (setq dim (getvar 'DIMZIN)) (setvar 'DIMZIN 0) (mapcar 'set '(a b c) (mapcar '(lambda (k p) (strcat k (rtos p 2 4))) '("E=" "N=" "Z=") pnt ) ) (setvar 'DIMZIN dim) (command "_.LEADER" "_none" pnt "\\" "" (nth (vl-position key '("EN" "ENZ" "Z")) (list (strcat a "\\P" b) (strcat a "\\P" b "\\P" c) c) ) "" ) ) (princ) ) after upload i received msg. AP APPLOAD ENZ.lsp successfully loaded. Command: ; error: bad argument type: numberp: nil Quote
Tharwat Posted July 6, 2019 Posted July 6, 2019 You may need to read the codes that you copied and search if there is any question mark(s) or any other weired chars added automatically with the codes due to the software of this forum and this is happening a lot. 1 Quote
Ish Posted July 6, 2019 Author Posted July 6, 2019 (edited) NOW WORKING GOOD. Pick your go [EASTING+NORTHING , EASTING+NORTHING+Z , Z] [EN ENZ Z] < EN > BY DEFAULT <EN> IS GOOD. BUT FOR ENZ AND Z I NEED TO TYPE , IT IS POSSIBLE FOR ENZ AND Z JUST CLICK BY MOUSE ON ENZ AND Z AS WELL AS TYPE. *** NOTE - CONTINUOUSLY NOT GETTING VALUE, EVERY TIME NEED TO HIT ENTER, MAKE LOOP UNTILL ESCAPE BUTTON PRESS. AND BY LAYER CODE ALSO ADD IN PROGRAM. LAYER NAME "Coordinate" SEE 2nd image offset: asking option by click (through, erase, layer) THANKS Edited July 6, 2019 by Ish MODIFY COMMENTS Quote
BIGAL Posted July 8, 2019 Posted July 8, 2019 Tharwat your welcome to use the multi radio button lisp and replace initget so your code becomes a mouse pick could add a exit button. Happy for any comments back to me for improvements. Examples of how to use are in code. Lsh Re NOT GETTING VALUE as your using a getpoint its hard to not return just that co-ords of pick point, only way is to check that an object was found at that point, would need to be added. Quote
Tharwat Posted July 8, 2019 Posted July 8, 2019 Just hit the F12 to enable the Dynamic input (DYNMODE) then you can pick the option you want right from mouse click. Quote
tombu Posted July 8, 2019 Posted July 8, 2019 On 7/6/2019 at 8:54 AM, Ish said: NOW WORKING GOOD. Pick your go [EASTING+NORTHING , EASTING+NORTHING+Z , Z] [EN ENZ Z] < EN > BY DEFAULT <EN> IS GOOD. BUT FOR ENZ AND Z I NEED TO TYPE , IT IS POSSIBLE FOR ENZ AND Z JUST CLICK BY MOUSE ON ENZ AND Z AS WELL AS TYPE. *** NOTE - CONTINUOUSLY NOT GETTING VALUE, EVERY TIME NEED TO HIT ENTER, MAKE LOOP UNTIL ESCAPE BUTTON PRESS. AND BY LAYER CODE ALSO ADD IN PROGRAM. LAYER NAME "Coordinate" SEE 2nd image offset: asking option by click (through, erase, layer) THANKS The lisp function GETKWORD finds the first distinct matching Upper-case characters for the command line making [z] the only option since both of the other options start with E. Something like [NoZ All Z] should give you clickable options. Quote
BIGAL Posted July 9, 2019 Posted July 9, 2019 (edited) Ish I have updated the original code to include new layer. Tharwat did not know about Dynmode and initget handy to know. You never stop learning with Autocad. Edited July 9, 2019 by BIGAL 1 Quote
Ish Posted July 9, 2019 Author Posted July 9, 2019 2 hours ago, BIGAL said: Ish I have updated the original code to include new layer. THANK YOU SIR, Quote
Ish Posted July 9, 2019 Author Posted July 9, 2019 16 hours ago, tombu said: The lisp function GETKWORD finds the first distinct matching Upper-case characters for the command line making [z] the only option since both of the other options start with E. Something like [NoZ All Z] should give you clickable options. SIR PLZ UPLOAD AGAIN YOUR LISP AFTER MODIFY CLICK BASE [E] [ENZ] [Z] LAYER "COORDINATE" CONTIGUOUSLY GET VALUE THANKS Quote
Ish Posted July 9, 2019 Author Posted July 9, 2019 18 hours ago, Tharwat said: Just hit the F12 to enable the Dynamic input (DYNMODE) then you can pick the option you want right from mouse click. SIR PLZ UPLOAD AGAIN YOUR LISP AFTER MODIFY CLICK BASE [E] [ENZ] [Z] LAYER "COORDINATE" CONTIGUOUSLY GET VALUE THANKS Quote
tombu Posted July 9, 2019 Posted July 9, 2019 (edited) On 7/9/2019 at 12:30 AM, Ish said: SIR PLZ UPLOAD AGAIN YOUR LISP AFTER MODIFY CLICK BASE [E] [ENZ] [Z] LAYER "COORDINATE" CONTIGUOUSLY GET VALUE THANKS Tharwat's code with slight modifications in my later post. Edited July 10, 2019 by tombu Updated code below. 1 Quote
dlanorh Posted July 9, 2019 Posted July 9, 2019 Poor old "Z", always getting nozall'd. I'll get my coat. Quote
Ish Posted July 10, 2019 Author Posted July 10, 2019 (edited) 17 hours ago, tombu said: Tharwat's code with slight modification: (defun c:enz (/ key pnt dim a b c) ;; Tharwat - 5.Jul.2019 ;; (load "enz.lsp") enz ;; https://www.cadtutor.net/forum/topic/68126-require-lisp-3-in-1-for-xyz-coordinates-with-leader/?tab=comments#comment-552639 (and (or (initget "NoZ All Z") (setq key (cond ((getkword "\nPick your go [No Elevation , All Coordinates , Z coordinates only] [NoZ/All/Z] < NoZ > :" ) ) ("NoZ") ) ) ) (setq pnt (getpoint "\nSpecify base point : ")) (setq dim (getvar 'DIMZIN)) (setvar 'DIMZIN 0) (mapcar 'set '(a b c) (mapcar '(lambda (k p) (strcat k (rtos p 2 4))) '("E=" "N=" "Z=") pnt ) ) (setvar 'DIMZIN dim) (command "_.LEADER" "_none" pnt "\\" "" (nth (vl-position key '("NoZ" "All" "Z")) (list (strcat a "\\P" b) (strcat a "\\P" b "\\P" c) c) ) "" ) ) (princ) ) now working good, by click. please do small modify , every time i get coordinate , i must hit enter or click., if i need EN value only, until i press escape button that must give value . i get EN value than again hit enter for another EN value. if any option select, i need continuously value by pick until i press escape button. See image, after get EN value it stop, for second En value i need hit enter. thanks Edited July 10, 2019 by Ish MODIFY COMMENTS Quote
tombu Posted July 10, 2019 Posted July 10, 2019 (edited) 13 hours ago, Ish said: now working good, by click. please do small modify , every time i get coordinate , i must hit enter or click., if i need EN value only, until i press escape button that must give value . i get EN value than again hit enter for another EN value. if any option select, i need continuously value by pick until i press escape button. thanks Once you select an option this will continuously allow you to keep picking points until you hit Enter or Spacebar. (defun c:enz (/ clr key pnt a b c) ;; Tharwat - 5.Jul.2019 ;; (load "enz.lsp") enz ;; https://www.cadtutor.net/forum/topic/68126-require-lisp-3-in-1-for-xyz-coordinates-with-leader/?tab=comments#comment-552639 ;; Add Commas ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/1-000-comma-separator/m-p/1857166#M230806 ;; Code Source: John Uhden ;; This function pads a numeric string with commas. ;; Arguments: ;; num = any number, real or integer (>= 0) ;; # = precision, integer (>= 0) ;; (defun rtoc (num # / p#) (setq num (rtos num 2 #) # 1) (while (and (/= (substr num # 1) ".")(<= # (strlen num))) (setq # (1+ #)) ) (setq # (1- #) p# #) (if (= (setq # (rem # 3)) 0)(setq # 3)) (while (< # p#) (setq num (strcat (substr num 1 #) "," (substr num (1+ #))) # (+ 4 #) p# (1+ p#) ) ) num ) (setq clr (getvar 'clayer)) ; from dlanorh's code (cond ( (null (tblsearch "LAYER" "Coor Text")) (command "-layer" "_M" "Coor Text" "_C" 7 "" "")) (t (setvar 'clayer "Coor Text"))) (and (or (initget "NoZ All Z") (setq key (cond ((getkword "\nPick your go [No Elevation , All Coordinates , Z coordinates only] [NoZ/All/Z] < NoZ > :" ) ) ("NoZ") ) ) ) (setq pnt (getpoint "\nSpecify base point : ")) (setq dim (getvar 'DIMZIN)) (setvar 'DIMZIN 0) (while pnt (mapcar 'set '(a b c) (mapcar '(lambda (k p) (strcat k (rtoc p 4))) '("E=" "N=" "Z=") pnt ) ) (setvar 'DIMZIN dim) (command "_.LEADER" "_none" pnt "\\" "" (nth (vl-position key '("NoZ" "All" "Z")) (list (strcat a "\\P" b) (strcat a "\\P" b "\\P" c) c) ) "" ) (setq pnt (getpoint "\nSpecify base point : ")) ) ; while ) (setvar 'clayer clr) (princ) ) Edited July 10, 2019 by tombu Added comma separators for coordinate values and set "Coor Text" as current layer.et . 1 Quote
Ish Posted July 10, 2019 Author Posted July 10, 2019 1 hour ago, tombu said: Once you select an option this will continuously allow you to keep picking points until you hit Enter or Spacebar. (defun c:enz (/ key pnt dim a b c) ;; Tharwat - 5.Jul.2019 ;; (load "enz.lsp") enz ;; https://www.cadtutor.net/forum/topic/68126-require-lisp-3-in-1-for-xyz-coordinates-with-leader/?tab=comments#comment-552696 (and (or (initget "NoZ All Z") (setq key (cond ((getkword "\nPick your go [No Elevation , All Coordinates , Z coordinates only] [NoZ/All/Z] < NoZ > :" ) ) ("NoZ") ) ) ) (setq pnt (getpoint "\nSpecify base point : ")) (while pnt (setq dim (getvar 'DIMZIN)) (setvar 'DIMZIN 0) (mapcar 'set '(a b c) (mapcar '(lambda (k p) (strcat k (rtos p 2 4))) '("E=" "N=" "Z=") pnt ) ) (setvar 'DIMZIN dim) (command "_.LEADER" "_none" pnt "\\" "" (nth (vl-position key '("NoZ" "All" "Z")) (list (strcat a "\\P" b) (strcat a "\\P" b "\\P" c) c) ) "" ) (setq pnt (getpoint "\nSpecify base point : ")) ) ; while ) (princ) ) wonderful Sir, now working perfectly. Request To You just add code for layer, create Layer Automatic And All value must come in Layer layer Name "Coor Text" Thanks a Lot. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.