Jump to content

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


Chevy

Recommended Posts

Hello,

 

I have been out of the cad life for a little while and i use to do lisp all the time. Now i cant even seem to do 1 routine. I have a Block (steel stair tread and riser) that i want to insert using lisp. I am trying to insert it and based on user input, change the riser height and then array it between a selected floor to floor height. Can anyone or will anyone take a little time to help? Thanks

Link to comment
Share on other sites

  • 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

This is a piece together code from similar threads below and somethings i still remember I would like to make it where it copies from two points on the block (insertion, copy to point) but the biggest thing if any i would like help with is setting up user input to change the riser height (by changing the block reference i guess) and then insert and copy.

 

(defun c:str (/ bNme i ss ent)
(command "divide" (entsel"\ Select slope=")(getint "\How many treads??="))
(command "point" (getpoint "\ Pick starting point="))
 (setq bNme (getstring 1 "\nRiser Height=")) ;; << Block Name
 (and (setq i -1 ss (ssget "_X" '((0 . "POINT"))))
      (while (setq ent (ssname ss (setq i (1+ i))))
        (entmake (list (cons 0 "INSERT")
                      (cons 100 "AcDbEntity")
                       (cons 100 "AcDbBlockReference")
                       (cons 2 bNme)
                     (assoc 10 (entget ent))))))
 (princ))

Link to comment
Share on other sites

:: What I understand ::

 

You want to insert a block at a point, and perhaps modify said block based on user input.

 

Then you want a dynamic block, as modifying a non-dynamic block reference changes *all* instances of said block. Unless by modify you mean change attribute values?

 

:: What I do not understand ::

 

What entity type is selected using entsel, a line perhaps?

 

How many points are in the drawing, as (ssget "_x" '((0 . "POINT"))) selects *all* points, when you've only created one.

 

So the riser height is the name of the block?

 

Why insert a point entity at (getpoint) if you're going to (assoc 10 (entget ent))?

Are you leaving the point created in the drawing? Instead, why not simply store the point to a variable (setq pt (getpoint)), and (cons 10 pt)?

Link to comment
Share on other sites

It seems like you are trying to divide a specified block along a selected line. Divide already has this functionality.

eg.

Command: DIV
DIVIDE
Select object to divide:
Enter the number of segments or [block]: B

Enter name of block to insert: P6

Align block with object? [Yes/No] <Y>:

Enter the number of segments: 5

Link to comment
Share on other sites

Hello,

 

I have been out of the cad life for a little while and i use to do lisp all the time. Now i cant even seem to do 1 routine. I have a Block (steel stair tread and riser) that i want to insert using lisp. I am trying to insert it and based on user input, change the riser height and then array it between a selected floor to floor height. Can anyone or will anyone take a little time to help? Thanks

 

I am not sure if this will be helpful, But this program by Dan E. Thomas is very cool.

Command Syntax: STAIRS

Stairs.Lsp

Link to comment
Share on other sites

Okay let me start over. I would really like for the routine to draw the tread and riser itself, but I think its way out of my league. I would like to pick 2 points, the floor to landing points. Then it change the riser height and draw the treads and risers from point to point. thats the principal but how? Where do i begin? The routine would need to have the riser height vary between 7" max and 6-3/8" min while keeping the 11" tread as a constant. I can do routines to manipulate commands but creating them myself, im still very very green. any thoughts?

 

I like that routine Buzzard, the principal is right, just not the drawing.

 

trd.dwg

Link to comment
Share on other sites

Okay let me start over. I would really like for the routine to draw the tread and riser itself, but I think its way out of my league. I would like to pick 2 points, the floor to landing points. Then it change the riser height and draw the treads and risers from point to point. thats the principal but how? Where do i begin? The routine would need to have the riser height vary between 7" max and 6-3/8" min while keeping the 11" tread as a constant. I can do routines to manipulate commands but creating them myself, im still very very green. any thoughts?

 

I like that routine Buzzard, the principal is right, just not the drawing.

 

 

[ATTACH]23396[/ATTACH]

 

 

Sorry about that, It seems it may need to be custom written no matter what.

I hope you find or get what you need. I will continue to look and see what available if its available.

Link to comment
Share on other sites

Actually this sounds like a good project for you to learn with. If you can draw it and you know the math involved that’s half the battle.

Could you post a drawing of what a finished drawing would look like?

Link to comment
Share on other sites

Its attached on my last posting. Labeled trd.dwg. I thought it would be easy. But this has been my sore wound for a while. Since before i got laid off last time.

Link to comment
Share on other sites

So if i want to get it to draw automatically then will i have to use vla functions? Well lets start of simple. I am guessing i will have to utilize the entmake function correct?

Link to comment
Share on other sites

So if i want to get it to draw automatically then will i have to use vla functions? Well lets start of simple. I am guessing i will have to utilize the entmake function correct?

 

 

That is not necessarily true.

 

You can absolutely start out with a routine using AutoCAD commands (._line, for example), and just feed those commands the criteria they need (i.e., start and end points for my previous example). Like JohnM says, you know how to draw what you want and the math needed... now just write the code (I know, easier said then done).

 

I'm out of the office today, but I'll check back to see if I can help shortly. Hopefully someone else will be able to pitch in too.

 

 

Good luck!

Link to comment
Share on other sites

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

I would use the pline command.

Functions to look at:

Polar

Repeat

Angle

If

Also be aware of turning the snaps on and off so when the program draws it will not snap to any points.

Look at the undo command so if its not correct one undo erases everything that was just drawn.

Link to comment
Share on other sites

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...