Jump to content

Recommended Posts

Posted (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

 

COMBINE LISP.JPG

Edited by Ish
MODIFY
Posted (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)

.

 

image.png.22f0e0dc782f13a6e1a249c06fdb4688.png

Multi radio buttons.lsp

Edited by BIGAL
  • Like 1
Posted

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)
)

 

  • Like 1
Posted
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"

 

 

image.png.22f0e0dc782f13a6e1a249c06fdb4688.png

Multi radio buttons.lsp 2.47 kB · 5 downloads

 

Posted
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

Posted

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.

  • Like 1
Posted (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

click option.JPG

click option 2.JPG

Edited by Ish
MODIFY COMMENTS
Posted

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.

Posted

Just hit the F12 to enable the Dynamic input (DYNMODE) then you can pick the option you want right from mouse click.

Posted
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

click option.JPG

click option 2.JPG

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.

Posted (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 by BIGAL
  • Like 1
Posted
2 hours ago, BIGAL said:

Ish I have updated the original code to include new layer.

 

 

THANK YOU SIR,

Posted
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

Posted
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

Posted (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 by tombu
Updated code below.
  • Like 1
Posted

Poor old "Z", always getting nozall'd.

 

I'll get my coat.

Posted (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

one click.JPG

Edited by Ish
MODIFY COMMENTS
Posted (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 by tombu
Added comma separators for coordinate values and set "Coor Text" as current layer.et .
  • Like 1
Posted
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.

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...