Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

X, Y Lisp

Status
Not open for further replies.

cdl1701

Technical User
Dec 10, 2004
47
US
At one time I had a lisp rutine that let me specify the origin and then a point that would create a leader and put the X & Y coordinate in the text automaticly. Does anyone know where I can find this. I have looked at a few but none of them do what I need.

Here is what I need:
1. start the lisp and specify the origin only once.
2. pick the point I want dimensioned.
3. pick the location I want to place the text.
4. have the lisp automaticly place the leader and stack the X,
Y text.
5. Pick my next point to be dimensioned (start back at step 2)

Please help =)

Thanks,
Chris
 
Ok we can probably help..

Since you have specific requirements, let's be even more specific

-do you need an AutoCAD leader with an arrowhead, or a polyline will do. Use current leader settings?
-do you want the the text stacked over a horizontal line or beyond the line
-do you want the routine to distinguish when text is left of point to draw leader to left & left justify, same with right?
-do you want to use text or mtext (if mtext it may mask line unless separate mt entities)
-format for x & y -just the coordinates to 2? decimal places?



left justify
 
Hi CarlAK, thanks for your reply.

-I do need it to be a leader with an arrow head.
-Stacked beyond the line
-Yes I need to to justify left or right simular to if you use
the leader command (not dim >leader though)
-Would like MTEXT
-Format needs to be Feet and inches to 1/4"(example: 2'-4-1/4")
 
I know I've seen several lisps for labeling coordinates but this sounds different enough, and not too difficult to code, that we can write it. I have time to think about it a few minutes but not code it yet. May be a little tricky only if user picks a point for the text to the left of the point, but not far enough left for the text and leader to fit. i'm thinking the routine uses the current textsize, and the horiz part of the leader is about equal to this length. Other possible twist is depending on the leader settings the prompts are a little different (such as toggle prompt for text width). Should have some time this weekend....
 
That would be great!!
I used to have one that worked ok but my hard drive crapped out on me a few months ago and had to get a new one. I have not been able to find one that actually worked right since. Every one that I have found does not let me specify the origin and then goes through so many user promts that it would be quicker for me to just place a point, list the point for the coords and use the leader command and manually type the info in.

Thanks for your help CarlAK! =)
 
OK I saw Fatty's routine at Cadtutor and used it as a starting point. Give the following a try:

(defun C:xyl (/ pick1 pick2)
(setvar "cmdecho" 0)
(setq UserOS (getvar "OSMODE"))
(setvar "osmode" 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"
(rtos Delx 4 2)
(rtos Dely 4 2)
""
)
)
(setvar "osmode" UserOS)
(setvar "cmdecho" 1)
(princ)
)
 
That works great!! Is there a way to get it to put he X and Y lable?
Like this?

X= 1'-5 1/4"
Y= -2'-2
 
Yes....

(defun C:xyl (/ pick1 pick2)
(setvar "cmdecho" 0)
(setq UserOS (getvar "OSMODE"))
(setvar "osmode" 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 4 2))
(strcat Y= " (rtos Dely 4 2))
""
)
)
(setvar "osmode" UserOS)
(setvar "cmdecho" 1)
(princ)
)
 
Thanks Carl, What does the strcat do? I had fiddled with it for quite a while last night trying to figure that one out.
 
'strcat' function "concatenate strings" (I'm guessing that's how it was named).

example:
(strcat "d" "o" "g") >> "dog"

the (rtos Delx 4 2) converts the contents of the variable 'Delx' to a string, (which is the x coordinate) , the '4' specifies 'architectural and the '2' is the precision to display.
 
I really need to get back to learning my lisp.. It's been about 6 years since I have even looked at a programing book or tutorial.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top