Jump to content

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


Recommended Posts

Posted

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

  • 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

Posted (edited)

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

Edited by Tharwat
words correction
Posted

The name of my block could be 2" x 4" and it will be located at the top of my rectangle

Posted

The name of you block is not correct and it can not be named with quotation marks at all .

Posted

Oh sry just name it 123

Posted

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!

Posted

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?

Posted

Well it is at the same place as the getpoint 2 and the block already exist

Posted

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)

Posted

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

Posted

picture.jpg

 

here is the block with demension

Posted

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

Posted (edited)

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

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

Edited by paulmcz
Posted

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!

Posted (edited)

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
Posted

The "BOX" is the autocad's command, so you can't use it as a defun's call code!

Posted

Could you perhaps make a sample drawing and attach it here so we can see what it needs?

Posted

Well thank you it works.!

Posted

I have merged your threads. Please you only need one thread per question. Creating Multiple threads only confuses.

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