XY Coordinate Lisp Leader Altering

XY Coordinate Lisp Leader Altering

Anonymous
Not applicable
10,250 Views
5 Replies
Message 1 of 6

XY Coordinate Lisp Leader Altering

Anonymous
Not applicable

Hello,

 

I'm new to the group, and have been having an issue altering my code for my lisp to display x and y coordinates.

 

I currently am using this;

 

(defun c:xyz (/ pick1 pick2)

    (setvar "cmdecho" 0)

    (setq Origin (getpoint "\nPick Origin for labels: "))

    (while

        (setq pick1 (getpoint "\nPick point to label <Enter to stop> :"))

        (setq pick2 (getpoint pick1 "\nPick leader end point :"))

        (setq Delx (- (car Pick1) (car Origin)))

        (setq Dely (- (cadr Pick1) (cadr Origin)))

        (command "._LEADER" pick1 pick2

            "_Annotation"

            (strcat "X= " (rtos Delx 2 3))

            (strcat "Y= " (rtos Dely 2 3)) "" ) )

    (setvar "osmode" UserOS)

    (setvar "cmdecho" 1)

    (princ) )

 

Everything works perfectly, except I'd like the leader to not have an arrow at the end of it.

Is there any way to alter the leader in the code above, or will i have to manually do it after?

 

Thanks,

Accepted solutions (2)
10,251 Views
5 Replies
Replies (5)
Message 2 of 6

Luís Augusto
Advocate
Advocate
Accepted solution

I hope this helps you.

Let us know if it worked for you.

Best regards, Luís Augusto

 

(defun c:xyz (/ pick1 pick2 *error*)

(defun *error* (msg)
(setvar "osmode" UserOS)
(setvar "cmdecho" 1)
(princ)
)

(setq UserOS (getvar "osmode"))
(setvar "osmode" 1);put the osmode of your choice

(setvar "cmdecho" 0)

(setq Origin (getpoint "\nPick Origin for labels: "))

(while
(setq pick1 (getpoint "\nPick point to label <Enter to stop> :"))
(setq pick2 (getpoint pick1 "\nPick leader end point :"))
(setq Delx (- (car Pick1) (car Origin)))
(setq Dely (- (cadr Pick1) (cadr Origin)))
(command "._LEADER"
pick1
pick2
"_f"
"_n"
"_Annotation"
(strcat "X= " (rtos Delx 2 3))
(strcat "Y= " (rtos Dely 2 3))
""
)
)

(setvar "osmode" UserOS)
(setvar "cmdecho" 1)
(princ)
)

 

Message 3 of 6

Anonymous
Not applicable

Luis,

 

That worked perfectly.  I had to alter the code slightly to remove the Osnap command at the beginning.  It was setting all of my snaps to off, which was causing an issue.  Nonetheless, everything else was perfect.  I do have one more question though, if you've possibly got a solution?

 

The output is currently reading stacked as such:

X = 3.593

y = 4.569

 

Is there any way to get these on the same line to read as:

X,Y = 3.593, 4.569

 

This would be ideal for my application. 

 

Thanks,

Andrew

0 Likes
Message 4 of 6

dbhunia
Advisor
Advisor
Accepted solution

Just change this...in @Luís Augusto code

 

   (command "._LEADER"
     pick1
     pick2
     "_f"
     "_n"
     "_Annotation"
     (strcat "X,Y= " (rtos Delx 2 3) "," (rtos Dely 2 3))
     ""
   )

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 5 of 6

Anonymous
Not applicable

Luis,

 

Scratch that, after some tinkering, I figured it out.

But thank you again for all your help!!

0 Likes
Message 6 of 6

Anonymous
Not applicable

Dbhunia,

 

I actually figured it out and replied prior to seeing your comment.

 

Nonetheless, thanks for the speedy response and solution.

I did exactly what you suggested.

 

Cheers!

0 Likes