Help with simple stair plan lisp

Help with simple stair plan lisp

DC-MWA
Collaborator Collaborator
2,211 Views
2 Replies
Message 1 of 3

Help with simple stair plan lisp

DC-MWA
Collaborator
Collaborator

I have (with the help of you all) assembled parts to do stair calcs, draw profile, and now I'm trying to do the plan portion.

I have been playing with array, copy, etc... I'm not getting very far.

Wondering if someone has already done this and has something similar or if someone can help me achieve this.

I want to ask:

1. startpoint

2. width

3. tread depth (will be answered with calc portion later)

4.# of treads (will be answered with calc portion later)

5. direction

And draw the stair plan based on that input'

Something like this...

As always, I appreciate input and assistance!

0 Likes
Accepted solutions (1)
2,212 Views
2 Replies
Replies (2)
Message 2 of 3

Moshe-A
Mentor
Mentor
Accepted solution

@DC-MWA hi,

 

this will get you started

 

note the call to (draw_treads) function:

(setq stair_geometry^ (draw_treads 10 30.0))

it has 2 arguments:

first is number treads  (e.g 10)

second is treads width (e.g 30)

 

you need to calculate these arguments according your design

 

enjoy

moshe

 

(defun c:pstairs (/ draw_stairs ; local function
		    stair_width stair_dir p0 stair_geometry^)
  
 (defun draw_treads (treads tread_width / t0 t1 t2 ll lr ul ur)

  (setq i -1)
  (repeat (1+ treads) 
   (setq t0 (polar p0 stair_dir (* tread_width (setq i (1+ i)))))
   (setq t1 (polar t0 (- stair_dir (/ pi 2)) (/ stair_width 2)))
   (setq t2 (polar t0 (+ stair_dir (/ pi 2)) (/ stair_width 2)))

   (cond
    ((= i 0)
     (setq ll t1 lr t2)
    )
    ((= i (1- treads))
     (setq ul t1 ur t2)
    )
    ( t
     nil
    ) 
   ); cond
    
   (command "._line" t1 t2 "") 
  ); repeat
  
  (list (list ll lr t2 t1) (list ul t0 ur)) 
 ); draw_treads


 (setvar "cmdecho" 1)
 (command "._undo" "begin")
 
 (if (and
       (setq stair_width (getdist "\nStair width: "))
       (setq p0 (getpoint "\nStair start point: "))
       (setq stair_dir (getangle p0 "\nDirection: ")) 
     )
  (if (setq stair_geometry^ (draw_treads 10 30.0))
   (progn
    ; draw stair boundary
    (command "._pline" (car (car stair_geometry^)) (cadr (car stair_geometry^))
	               (caddr (car stair_geometry^)) (cadddr (car stair_geometry^))  "_close")
    ; draw stair arrow
    (command "._donut" 0 10 p0 "") 
    (command "._pline" (car (cadr stair_geometry^)) (cadr (cadr stair_geometry^))
	               (caddr (cadr stair_geometry^)) (cadr (cadr stair_geometry^)) p0 "")
   ); progn
  ); if
 ); if
  
 (command "._undo" "end")
 (setvar "cmdecho" 1) 
 (princ)
)
Message 3 of 3

DC-MWA
Collaborator
Collaborator

This is beyond perfect my friend.  I was able to modify the code to use the calcs gathered from users for treads and tread width...

Added layer creation and layer return, removed the osnaps during execution and BOOM!!

Awesome!

Thanks for your time and input.

0 Likes