Jump to content

Insert Block using Lisp...HELP!!!!!????!!!!!!!


Recommended Posts

Posted

Use the polar function (setq pt2 (polar pt1 ))

Are you using the AutoCAD visual lisp environment?

If so go the help menu and select visual lisp help then select the contents tab then click the + sign next to autolisp references. This will be your biggest teacher. Look up the polar function or any function you need. It has examples.

Look up

polar

angle

repeat

if

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

  • Chevy

    24

  • BlackBox

    9

  • JohnM

    7

  • The Buzzard

    6

Top Posters In This Topic

Posted Images

Posted

okay so i would start with something like

 

 
(defun c:str ()
(setq ris (getdist "\n Riser Height?="))
(setq pt1 (getpoint "\n Pick Starting tread.="))

 

 

 

and in between i would define my functions right?

 

 
 (command "_pline" "") 
 (princ)
 )

Posted

here's a quicky, maybe it will help you get started

(defun c:test ()
(setq hgt (getdist "\nEnter overall height: "); flr to flr distance
     stps (getint "\nEnter number of steps: ")
     rsr (/ hgt stps);riser height
     trd (getdist "\nEnter tread width: ")
     pt1 (getpoint "\nPick bottom start point: ")
     )
(repeat stps; repeat the pline command as many steps you have
 (command "pline" pt1 (setq pt2 (polar pt1(/ pi 2) rsr)) (setq pt3 (polar pt2 0 trd)) "")
 (setq pt1 pt3); new start point for pline
 )
)

Posted

Okay, I see how it works but when i try and make it draw the way i need it to i just screw it up and have to start over. This is very complicated trying to get it to draw the pans and angles and fill. Ill keep tring though

Posted
It helps to plan it out on paper first in plain words and write out any math equations that will be used.

 

Chevy, JohnM is exactly right.

 

What I often did when starting out. was (within the VLIDE) to open a new LISP file, and start writing what I want my program to do, using comments. Then when I feel I have a good 'work flow' for the code to follow, I begin writing my code.

 

 

For instance (using Lpseifert's example):

[font=Times New Roman][size=3][color=seagreen];;;  My test function[/color][/size][/font]
(defun c:TEST ()
 [color=seagreen];; Store variables for error checking[/color]
[color=seagreen] [/color]
[color=seagreen]  ;; Main Code[/color]
[color=seagreen]  ;; Enter overall height[/color]
[color=seagreen] [/color]
[color=seagreen]  ;; Enter number of steps[/color]
[color=seagreen] [/color]
[color=seagreen]  ;; Enter riser height[/color]
[color=seagreen] [/color]
[color=seagreen]  ;; Enter tread width[/color]
[color=seagreen] [/color]
[color=seagreen]  ;; Pick bottom start point[/color]
[color=seagreen] [/color]
[color=seagreen]  ;; Repeat the pline command[/color]
[color=seagreen] [/color]
[color=seagreen]  ;; Set new start point for pline[/color]

 (princ))

Posted

I understand, and for the most part i think im trying to see and do too much i just can figure out how to make it draw what i need. Like this point to this point and angle and keep this as a constant. I guess its just going to take alot of time. Wish the ran DSL out at my house. cant get much help with dial up.

Posted

Man, Chevy... I'm a spoiled brat...

 

I $#!% a brick (at home) when my 40 mbps Fiber Optic cable or Wireless N goes out for a second. lol :P

 

What about thumb drives? Can you print materials to PDF and take them home?

Posted (edited)

ok so this

(setq hgt (getdist "\nEnter overall height: "); flr to flr distance
     stps (getint "\nEnter number of steps: ")
     rsr (/ hgt stps);riser height
     trd (getdist "\nEnter tread width: ")
     pt1 (getpoint "\nPick bottom start point: ")
     )

 

I understand not what i cant figure out is the calculations to draw this

 

untitled.jpg

Edited by Chevy
Sorry, didnt know it would be that big.
Posted

Here is what I would do;

In AutoCAD draw one out completely top floor to bottom floor.

Now dimension it

Make note of what is variable and what is consistent

List all of the math I need to figure it out

List all of the questions to ask the user to input

Are these always steel stairs?

From your drawing looks like a zig-zag line with the tread pans below the line and the riser pans behind the line. Am I correct?

I looked at the drawing you posted and it would help if you post a real scenario of a complete top to bottom drawing.

In one of the post you said all treads are 11” and risers are between 7” – 6 3/8”

Is the back angle always the same?

If this is correct you should be able to write a formula to calculate all needed distances

Your last post is of one step. Is that all you need?

If not you need to first look at the whole picture and quit focusing on the one step.

If you do the math all the program should ask the user is:

Pick top floor

Pick bottom floor

Pick direction to draw

Then the program crunches the numbers

Posted

This could be accomplished with a dynamic block. Set a stretch parameter to the portions you need to change and set an array/copy parameter to the entire block.

Posted

A dynamic block will not work when you do a polar array you have to pick 2 points as the array distance. When you stretch the riser the number should change but it stays as the constant number you picked so without making 10 different visibility functions it will not work.

 

Now back to my sore thumb. I will go over it tonight and write down what i need. I think i know but i cant seem to understand how to make the formula with the numbers in the right syntax.

Posted

Your last post is of one step. Is that all you need?

 

This could be accomplished with a dynamic block. Set a stretch parameter to the portions you need to change and set an array/copy parameter to the entire block.

 

 

My thought, while belated, was the same. :wink:

Posted

I think you are wrong, but I don't claim to be a Dynamic block expert, so I'll leave it be.

Posted

How does one stair connect to the other?

Post an image/DWG of a completed staircase with at least 2 steps.

Posted

Assuming the angle from vertical of the riser is 15 degrees...(or 105 degrees)

the length of the riser would be (1/SIN 105 degrees) * riser height

 

this now includes an angle to the riser

(defun c:test ()
(setq hgt (getdist "\nEnter overall height: "); flr to flr distance
     stps (getint "\nEnter number of steps: ")
     rsr (/ hgt stps);riser height
     trd (getdist "\nEnter tread width: ")
     pt1 (getpoint "\nPick bottom start point: ")
     angr (dtr 105); returns 105 degrees in radians
     )
(repeat stps; repeat the pline command as many steps you have
 (command "pline" pt1 (setq pt2 (polar pt1 angr (* (/ 1 (sin angr)) rsr)))(setq pt3 (polar pt2 0 trd)) "")
 (setq pt1 pt3); new start point for pline
 )
)


(defun dtr (a) (* pi (/ a 180.0)));function to convert degrees to radians

of course this doesn't include the pans, but it should give you some ideas...

Posted

Based on Larry's work...

(defun c:TEst (/ _stairs _stairs2 _lwpline h s w p)

 ;;http://www.cadtutor.net/forum/showthread.php?52858-Insert-Block-using-Lisp...HELP!!!!!-!!!!!!!&p=358288#post358288

 (defun _stairs (p r w # / foo lst)
   ;; p - starting point
   ;; r - riser height (overall height over number of stairs) (/ h s)
   ;; w - width of tread
   ;; # - number of stairs
   (defun foo (p / b) (list p (setq b (polar p (/ pi 2.) r)) (polar b 0. w)))
   (repeat #
     (setq lst (append lst
                       (foo (cond ((car (reverse lst)))
                                  (p)
                            )
                       )
               )
     )
   )
 )

 (defun _stairs2 (p r w # a / foo lst)
   ;; p - starting point
   ;; r - riser height (overall height over number of stairs) (/ h s)
   ;; w - width of tread
   ;; # - number of stairs
   ;; a - angle for riser
   ;; eg: (_stairs2 (trans p 1 0) (/ h s) w s (* (/ 7. 12.) pi))
   (defun foo (p / b) (list p (setq b (polar p a (* (/ 1. (sin a)) r))) (polar b 0. w)))
   (repeat #
     (setq lst (append lst
                       (foo (cond ((car (reverse lst)))
                                  (p)
                            )
                       )
               )
     )
   )
 )

 (defun _lwpline (lst)
   (if (> (length lst) 1)
     (entmakex (append
                 (list '(0 . "LWPOLYLINE")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbPolyline")
                       (cons 90 (length lst))
                       (cons 70 (* (getvar 'plinegen) 128))
                 )
                 (mapcar (function (lambda (p) (list 10 (car p) (cadr p)))) lst)
               )
     )
   )
 )

 (if (and (setq h (getdist "\nHeight: "))
          (setq s (getint "\nNumber of steps: "))
          (setq w (getdist "\nWidth: "))
          (setq p (getpoint "\nSpecify start point: "))
     )
   ;;(_lwpline (_stairs (trans p 1 0) (/ h s) w s))
   (_lwpline (_stairs2 (trans p 1 0) (/ h s) w s (* (/ 7. 12.) pi)))
 )
 (princ)
)

 

I'm just fooling around.

Posted
A dynamic block will not work when you do a polar array you have to pick 2 points as the array distance. When you stretch the riser the number should change but it stays as the constant number you picked so without making 10 different visibility functions it will not work.

 

Now back to my sore thumb. I will go over it tonight and write down what i need. I think i know but i cant seem to understand how to make the formula with the numbers in the right syntax.

how about this? it is only 4 but 11 (your constant) is no problem.

 

kruuger

STAIRS.dwg

Posted

I found this lisp on CADalyst that does Steel & Concrete Stairs. I do not fully understand all the lingo it asks for, But give it a try.

 

This program made a step detail close to your sample drawing.

HTH2294.zip

Posted

Here is another one that makes the details with the Runner, Rails, Thread, & Riser. This one I found at CADCORNER

StairSec.zip

Posted

I allready have these two routines, I have worked and worked with them before but cant modify them to work . Thanks though Buzzard. Im just really frustrated with this thing. but, i guess thats how it goes.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...