PDA

View Full Version : Stair Routine



tflaherty
2005-05-03, 03:44 PM
I'm working on a stair routine and I'm trying to figure out how to get AutoCAD to draw a line perpendicular to a user supplied rotation angle. This is what I've got so far, but I keep getting the error message listed below.


defun straight (/ sp rt)
(setq sp (getpoint "\nSelect point of 1st riser: "))
(setq rt (getangle "\nSelect rotation of stairs: "))
(setq ws (getdist "\nWidth of stairs: "))
(command "line" sp (strcat "@" (rtos ws) "<" (+ (angtos rt) 90)) "")
(princ)
)


error: bad argument type: numberp: "90"

lance.81922
2005-05-03, 04:06 PM
I think this is what you want:

(defun straight (/ sp rt)
(setq sp (getpoint "\nSelect point of 1st riser: "))
(setq rt (getangle "\nSelect rotation of stairs: "))
(setq ws (getdist "\nWidth of stairs: "))
(command "line"
sp
(strcat "@" (rtos ws) "<" (angtos(+ rt (/ PI 2))))
""
)
(princ)
)

You need to do your angle arithmetic before you call ANGTOS, and you need to use radians when you do angle calculations in AutoLISP (2 PI radians=360 degrees).

tflaherty
2005-05-03, 04:21 PM
That didn't help. I still get the same error message except now it says "180" instead of "90".


Thanks anyway

lance.81922
2005-05-03, 04:23 PM
That's interesting. Did you copy what I sent? It worked fine on my system once I changed the ANGTOS part.

tflaherty
2005-05-03, 04:54 PM
I cut & pasted it wrong and had an extra (+ in my code. It works fine now, thanks a lot.