Jump to content

Greating a lisp to get a rectangle and impotting a block in it


CadFrank

Recommended Posts

Hi to all, I am new at lisp and i would like to kno how create box and inserte a block in it. for exemple a 2 x 4 stud and on top or it a of a 2 x 4

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • CadFrank

    11

  • paulmcz

    7

  • Tharwat

    3

  • irneb

    2

Top Posters In This Topic

Posted Images

What is the name of your block and where are you going to insert it ( insertion point ) ?

Edited by Tharwat
words correction
Link to comment
Share on other sites

Hi, well this is simple for some people but im new at autolisp.

 

I would need to create a lisp for the image ill be showing you.

 

i can create a lisp to make a box but i can't inserte the block in it.

 

picture.jpg

 

so if some1 can help me figure out the rest i would be gratefull.

 

thank you!

Link to comment
Share on other sites

Does the block already exist? How does it look like?

Where is the block you need to insert now? In the drawing? Is it a separate file?

Where is the block's base point, in relation to the block's geometry?

Link to comment
Share on other sites

Is the block in the drawing? Is it a separate file?

Post the picture of the block, show the exact location of the base point and dimension it in detail.

Or better yet, attach the block's drawing (dwg)

Link to comment
Share on other sites

Well i dont have the block with me

 

 

but if you give me the code i need i could fill in the blanks after unless you really need the block

Link to comment
Share on other sites

Since nobody knows the dimensions of your block, following code is good for inserting first of your blocks. For the second one, you need to calculate location of the second insertion point.

 

(command "_.insert" "path or block's name" point2 "x-scale" "y-scale" "rotation")

 

If the block is already in the drawing, skip the path

Link to comment
Share on other sites

OK, the second block will have to have the insertion point = p3 =>

(setq p3 (polar point2 (* pi 1.5) 38.0))

Edited by paulmcz
Link to comment
Share on other sites

So lets say this is the code i started

 

[font=Courier New](defun c:BOX ( / pt1 pt2 pt3 pt4 )(setq pt1 (getpoint "Pick first corner: "))(setq pt3 (getcorner pt1 "Pick opposite corner: "))(setq pt2 (list (car pt3) (cadr pt1)))(setq pt4 (list (car pt1) (cadr pt3)))(command "line" pt1 pt2 pt3 pt4 "c" )[/font](command "_.insert" "path or block's name" point2 "x-scale" "y-scale" "rotation")(setq p3 (polar point2 (* pi 1.5) 38.0))))

 

would this be ok!

Link to comment
Share on other sites

This would do it, if the block's name is "123", it resides in the drawing and you want to accept x-scale as 1.0, y-scale as 1.0 and rotation as 0.0.

 

(defun c:BOXX (/ osn pt1 pt2 p3)
 (setq osn (getvar "osmode"))
 (setvar "osmode" 0)
 (setq pt1 (getpoint "Pick first corner: "))
 (setq pt2 (getcorner pt1 "Pick opposite corner: "))
 (command "rectang" pt1 pt2)
 (command "_.insert" "123" pt2 "" "" "" )
 (setq p3 (polar pt2 (* pi 1.5) 38.0))
 (command "_.insert" "123" p3 "" "" "")
 (setvar "osmode" osn)
 (princ)
)

Edited by paulmcz
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...