PDA

View Full Version : Stairs Lisp


BCrouse
2005-06-08, 01:15 AM
I am looking for a lisp that will draw the profile of stairs. The lisp should ask for the start pt from Top of Floor and you select the Bottom Floor below Attached to this thread you will see a sample picture. The Top Tread is 2" to nose and the Tread 11" to nose. So the distance from nose to nose is 10". The Riser is an unknown variable do to different ceiling hgts.

Thanks

Opie
2005-06-08, 03:46 AM
I am looking for a lisp that will draw the profile of stairs. The lisp should ask for the start pt from Top of Floor and you select the Bottom Floor below Attached to this thread you will see a sample picture. The Top Tread is 2" to nose and the Tread 11" to nose. So the distance from nose to nose is 10". The Riser is an unknown variable do to different ceiling hgts.

Thanks
Is there any minimum or maximum riser heights?

The following code is a rough start for you.
(defun C:STAIRPROFILE (/ ANG CNT
ELEVDIFF LOWER LOWERFLOOR
LOWERFLOORPICK OSM
PNTARRAY RISERHEIGHT STARTPNT
UPPER UPPERFLOOR UPPERFLOORPICK
PROBLEM
)
(setq OSM (getvar "OSMODE"))
(setvar "osmode" 0)
(defun ASC (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY)))
;;; retrieve assoc data from entity
(defun DTR (A) (* pi (/ A 180.0)))
;;; utility to convert decimal degrees to radians
(setq LOWERFLOOR
(entsel "\nSelect lower floor: ")
LOWERFLOORPICK
(car (cdr LOWERFLOOR))
LOWERFLOOR
(entget (car LOWERFLOOR))
UPPERFLOOR
(entsel "\nSelect upper floor: ")
UPPERFLOORPICK
(car (cdr UPPERFLOOR))
UPPERFLOOR
(entget (car UPPERFLOOR))
PROBLEM 0
)
(if (= (ASC 0 LOWERFLOOR) "LINE")
(if (= (cadr (ASC 10 LOWERFLOOR)) (cadr (ASC 11 LOWERFLOOR)))
(setq LOWER (cadr (ASC 10 LOWERFLOOR)))
(setq PROBLEM 1)
)
(setq PROBLEM 2)
)
(if (= (ASC 0 UPPERFLOOR) "LINE")
(if (= (cadr (ASC 10 UPPERFLOOR)) (cadr (ASC 11 UPPERFLOOR)))
(setq UPPER (cadr (ASC 10 UPPERFLOOR)))
(setq PROBLEM 3)
)
(setq PROBLEM 4)
)
(if (and (/= UPPER NIL) (/= LOWER NIL) (/= PROBLEM 1))
(progn
(if (> UPPER LOWER)
(progn
(setq ELEVDIFF (- UPPER LOWER))
)
(progn (setq ELEVDIFF (- LOWER UPPER)))
)
(setq RISERHEIGHT (/ ELEVDIFF (fix (/ ELEVDIFF 7)))
STARTPNT (inters (ASC 10 LOWERFLOOR)
(ASC 11 LOWERFLOOR)
LOWERFLOORPICK
(polar LOWERFLOORPICK (DTR 90.0) 1.0)
NIL
)
)
(if (> (car UPPERFLOORPICK) (car STARTPNT))
(setq ANG (DTR 0.0))
(setq ANG (DTR 180.0))
)
(setq PNTARRAY NIL)
(repeat (fix (/ ELEVDIFF RISERHEIGHT))
(if (not PNTARRAY)
(setq PNTARRAY
(list (polar (polar STARTPNT (DTR 90.0) RISERHEIGHT)
ANG
10.0
)
)
)
(setq PNTARRAY
(append
(list (polar (polar (car PNTARRAY) (DTR 90.0) RISERHEIGHT)
ANG
10.0
)
)
PNTARRAY
)
)
)
)
(setq PNTARRAY (append (list STARTPNT) (reverse PNTARRAY)))

(setq CNT 0)
(repeat (1- (length PNTARRAY))
(CREATETREAD (nth CNT PNTARRAY) RISERHEIGHT ANG)
(setq CNT (1+ CNT))
)
)
(progn (cond
((= PROBLEM 1)
(setq MSG "Lower elevation not level.")
)
((= PROBLEM 2)
(setq MSG (strcat "Lower level not of type "
(chr 34)
"LINE"
(chr 34)
"."
)
)
)
((= PROBLEM 3)
(setq MSG "Upper elevation not level.")
)
((= PROBLEM 4)
(setq MSG (strcat "Upper level not of type "
(chr 34)
"LINE"
(chr 34)
"."
)
)
)
)
(alert MSG)
)
)
(setvar "osmode" OSM)
)
(defun CREATETREAD (N HEIGHT ANG /)
(setq TREADWIDTH 11.0
TREADHEIGHT 1.0
NOSEWIDTH 1.0
)
(setq TREADPNTS (list (polar N (DTR 90.0) (- HEIGHT TREADHEIGHT)))
TREADPNTS (append
(list
(polar (car TREADPNTS) (+ (DTR 180.0) ANG) NOSEWIDTH)
)
TREADPNTS
)
TREADPNTS (append
(list (polar (car TREADPNTS) (DTR 90.0) TREADHEIGHT))
TREADPNTS
)
TREADPNTS (append (list (polar (car TREADPNTS) ANG TREADWIDTH))
TREADPNTS
)
TREADPNTS (reverse TREADPNTS)
)

(command "line"
N
(nth 0 TREADPNTS)
(nth 1 TREADPNTS)
(nth 2 TREADPNTS)
(nth 3 TREADPNTS)
""
)
)

tflaherty
2005-06-08, 05:03 PM
Try this. You may need to adjust the dimensions and I don't recall if it inserts on the current layer or if it changes to another one. I'm working on some changes that won't require the user to input the # of risers, it will figure it out base on floor to clg hgt and max riser hgt. If you want I can send you the updated one when complete.

Tyler A
2009-11-10, 05:42 PM
I'm working on some changes that won't require the user to input the # of risers, it will figure it out base on floor to clg hgt and max riser hgt.

Like this?

TimSpangler
2009-11-10, 06:30 PM
WTH!! This thread was from 2005.....

Tyler A
2009-11-10, 07:26 PM
WTH!! This thread was from 2005.....

I found it useful.