tendai1
Structural
- Mar 29, 2003
- 24
I am a beginner in LISP. I wrote a short lisp routine which does not produce results consistently. The routine is supposed to draw a line in any quadrant and place text at the mid point of the line. I tried to simplify the routine as a biginner. Could you please test my routine (listed below) and tell me whats wrong with it? I didn't use any AutoCAD System variables, could you please refer me to some documentation (other than AutoCAD Guides) that may help me to understand which system variables to use & when to use them in LISP.
;| Eddies' Routine. This program draws a line between 2 points, then insert text
on top of the line.
ROUTINE
|;
(Defun c:st ()
(setq pt1 (getpoint "First Point:")
(setq pt2 (getpoint "Second Point:")
(setq ang1 (angle pt1 pt2))
(setq pt3 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2)))
(if (<= ang1 1.570796327) (setq ang2 (+ ang1 1.570796327))
(if (<= ang1 3.14159) (setq ang2 (- ang1 1.570796327))
(if (<= ang1 4.71238898) (setq ang2 (- ang1 1.570796327))
(if (<= ang1 6.283185307) (setq ang2 (+ ang1 1.570796327)) (setq ang2 0)))))
(if (<= ang1 1.570796327) (setq ang3 ang1)
(if (<= ang1 3.14159) (setq ang3 (+ 3.14159 ang1))
(if (<= ang1 4.71238898) (setq ang3 (- ang1 3.14159))
(if (<= ang1 6.283185307) (setq ang3 ang1) (setq ang2 ang1)))))
(setq pt4 (polar pt3 ang2 200))
(setq ang2 (* 57.29577951 ang2))
(setq ang3 (* 57.29577951 ang3))
(command ".line" pt1 pt2 ""
(command ".text" pt4 250 Ang3 "Eddie")
;| Eddies' Routine. This program draws a line between 2 points, then insert text
on top of the line.
ROUTINE
|;
(Defun c:st ()
(setq pt1 (getpoint "First Point:")
(setq pt2 (getpoint "Second Point:")
(setq ang1 (angle pt1 pt2))
(setq pt3 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2)))
(if (<= ang1 1.570796327) (setq ang2 (+ ang1 1.570796327))
(if (<= ang1 3.14159) (setq ang2 (- ang1 1.570796327))
(if (<= ang1 4.71238898) (setq ang2 (- ang1 1.570796327))
(if (<= ang1 6.283185307) (setq ang2 (+ ang1 1.570796327)) (setq ang2 0)))))
(if (<= ang1 1.570796327) (setq ang3 ang1)
(if (<= ang1 3.14159) (setq ang3 (+ 3.14159 ang1))
(if (<= ang1 4.71238898) (setq ang3 (- ang1 3.14159))
(if (<= ang1 6.283185307) (setq ang3 ang1) (setq ang2 ang1)))))
(setq pt4 (polar pt3 ang2 200))
(setq ang2 (* 57.29577951 ang2))
(setq ang3 (* 57.29577951 ang3))
(command ".line" pt1 pt2 ""
(command ".text" pt4 250 Ang3 "Eddie")