Mleader Coordinates LISP

Mleader Coordinates LISP

Anonymous
Not applicable
5,237 Views
9 Replies
Message 1 of 10

Mleader Coordinates LISP

Anonymous
Not applicable

Hi guyz,

 

I want to make LISP using Mleader to show Easting and Northing. However, my LISP outcome was shown Easting only. Anyone can help me? my attempt is in below. Thanks.

 

I want like this:

E=0.000

N=0.000

 

 

Regards,

Ardz

 

5,238 Views
9 Replies
Replies (9)
Message 2 of 10

imadHabash
Mentor
Mentor

Hi and Welcome to AutoDesk Forum,

 

>> I want to make LISP using Mleader to show Easting and Northing <<

we call this Text Field value NOT a lisp.i suggest to follow this VIDEO to learn how to make it.

 

Good Luck..

 

 

Imad Habash

EESignature

0 Likes
Message 3 of 10

ВeekeeCZ
Consultant
Consultant

Try it like this...

 

(defun C:XY (/ PNT1 P1X P1Y STDY DY PTXT )
  (setq PNT1 (getpoint "\nPick coordinate point: "))
  (setq P1X (car pnt1)) ;x coord
  (setq P1Y (cadr pnt1)) ;y coord
  (setq STDX (rtos P1X 2 3))
  (setq STDY (rtos P1Y 2 3))
  (setq COORD (strcat "E=" STDX "\nN=" STDY))
  (setq PTXT (getpoint "\nPick text location: "))
  (command "mleader" PNT1 PTXT COORD)
  (princ)) ; end

 

And little shorter version. The leader shows dynamically while the creation. It works under UCS as well.

(defun C:XY (/ pnt coord)
  (if (and (setq pnt (getpoint "\nPick coordinate point: "))
           (setq pnt (trans pnt 1 0))
           (setq coord (strcat "E="   (rtos (car pnt) 2 3)
                               "\nN=" (rtos (cadr pnt) 2 3)))
           )
    (command "_.mleader" "_none" pnt PAUSE coord))
  (princ))
Message 4 of 10

TourajM
Enthusiast
Enthusiast
Hi, will you please add a Z value to the lisp?
E=
N=
H=
0 Likes
Message 5 of 10

Sea-Haven
Mentor
Mentor

If you study the code the answer was in front of you.

 

(defun C:XYZ (/ pnt coord)
  (while (setq pnt (getpoint "\nPick coordinate point Enter to exit : "))
  (progn
      (setq pnt (trans pnt 1 0))
      (setq coord (strcat "E="   (rtos (car pnt) 2 3)
                          "\nN=" (rtos (cadr pnt) 2 3)
		     	          "\nZ=" (rtos (caddr pnt) 2 3))
       )
       (command "_.mleader" "_none" pnt PAUSE coord)
	)
	)
  (princ)
)

 

Look at the car, cadr & caddr functions.

 

0 Likes
Message 6 of 10

TourajM
Enthusiast
Enthusiast
Thanks,
I figured it out that much, but I got the
Pick coordinate point Enter to exit : ; error: too few arguments
0 Likes
Message 7 of 10

Sea-Haven
Mentor
Mentor

Works for me, check lispsys = 1. Not sure otherwise. You could remove the progn not really needed.

0 Likes
Message 8 of 10

TourajM
Enthusiast
Enthusiast
Doesn't work. Is only added Z to this because working fine.
(defun C:XY (/ PNT1 P1X P1Y STDY DY PTXT )
(setq PNT1 (getpoint "\nPick coordinate point: "))
(setq P1X (car pnt1)) ;x coord
(setq P1Y (cadr pnt1)) ;y coord
(setq STDX (rtos P1X 2 3))
(setq STDY (rtos P1Y 2 3))
(setq COORD (strcat "E=" STDX "\nN=" STDY))
(setq PTXT (getpoint "\nPick text location: "))
(command "mleader" PNT1 PTXT COORD)
(princ)) ; end
0 Likes
Message 9 of 10

Sea-Haven
Mentor
Mentor

Version 2, added line from pnt.

 

(defun C:XYZ (/ pnt coord)
  (while (setq pnt (getpoint "\nPick coordinate point Enter to exit : "))
  (progn
      (setq pnt (trans pnt 1 0))
      (setq coord (strcat "E="   (rtos (car pnt) 2 3)
                          "\nN=" (rtos (cadr pnt) 2 3)
		     	          "\nZ=" (rtos (caddr pnt) 2 3))
       )
       (command "_.mleader" "_none" pnt (getpoint pnt "\npick point for text ") coord)
	)
	)
  (princ)
)
0 Likes
Message 10 of 10

TourajM
Enthusiast
Enthusiast
Yes, This is working. Thanks.
0 Likes