I am trying to make my own lisp, I mean without cut / paste other routines into my own. This
one is an example wich I will "expand" as far as I have ideas.
Function of routine: draw a box with specified side length. Insertion point box must be
offset a certain distance from the actual insertion point. At last it should be rotate-able.
This is what I have got so far:
Code:
(defun c:box1 (/ len leng dist pt1 pt2 pt3 pt4 pt5 pt6)
(setq len (getint "\nLength1: "))
(setq leng (getint "\nLength2: "))
(setq dist (getdist "\nDistance: "))
(setq pt1 (getpoint "\nInsertion: "))
(setq pt2 (polar pt1 (* pi 0.5) dist))
(setq pt3 (polar pt2 (* 2 (* pi 0.5)) (* len 0.5)))
(setq pt4 (polar pt3 (* pi 0.5) leng))
(setq pt5 (polar pt4 0.0 len))
(setq pt6 (polar pt3 0.0 len))
(command "pline" pt3 pt4 pt5 pt6 pt3 "")
(command "rotate" "l" "" pt1 pause)
(princ)
)
My questions / probs:
Code:
(defun c:box1 (/ len leng dist pt1 pt2 pt3 pt4 pt5 pt6)
No questions, given variables after the "/" are cleared after my routine ends.
Code:
(setq len (getint "\nLength1: "))
(setq leng (getint "\nLength2: "))
I had len1 and len2 but then it got stuck, I figured len1 can not be used in combination with the (polar ...) thingy below. Thats why I took the len and leng variable.
Code:
(setq dist (getdist "\nDistance: "))
No probs...
Code:
(setq pt1 (getpoint "\nInsertion: "))
No probs...
Calculations, with tears in my eyes:
Code:
(setq pt2 (polar pt1 (* pi 0.5) dist))
Polar is meant for an angle, am I correct?
-> (* pi 0.5) is 90 degrees I figured.
So: calculate point 2, it is "polared" to point 1, angle 90 degrees with a distance called "dist".
Code:
(setq pt3 (polar pt2 (* 2 (* pi 0.5)) (* len 0.5)))
(setq pt4 (polar pt3 (* pi 0.5) leng))
(setq pt5 (polar pt4 0.0 len))
(setq pt6 (polar pt3 0.0 len))
THese above must contain errors / faults for it does not work properly.
Code:
(command "pline" pt3 pt4 pt5 pt6 pt3 "")
(command "rotate" "l" "" pt1 pause)
(princ)
)
Okay...
In short terms:
Can someone help me understand calculating this?
Do not give me the solution at once, let me struggle.
Bookmarks