Jump to content

LISP Code To Insert Block To a Drawing Template


erickson19886
 Share

Recommended Posts

Hello everyone,

 

I'm Erick and I'm new in this forum.

Also, I'm a beginner in creating LISP.

I need your help to create a code that will do the following items.

1. Automatic insert of a block (this .DWG block can be found on the same directory as the drawing template) to an open drawing template.

2. During insert, LISP should put the block in fixed location (0, 0), then scale it to a fixed scale factor (i.e. 0.5, 0.5) and will have a fixed rotation (0 deg).

 

Thank you in advance.

Hoping you'll help me on this first project.

Block.dwg

DWG_Template.dwg

Edited by erickson19886
Add attachment
Link to comment
Share on other sites

Hi Erick, welcome to CADTutor.

 

Here is a start for you to test out and also you can use the command call "-insert" as well if you find the vla-* functions hard to deal with at the mean time.

(vla-insertblock
  (vla-get-modelspace
    (vla-get-activedocument (vlax-get-acad-object))
  )
  (vlax-3d-point '(0. 0. 0.))
  "C:\\Users\\Tharwat\\Desktop\\Drawing1.dwg"  ;; Replace this path of drawing with yours
  0.5
  0.5
  1.0
  0.
)
 
Edited by Tharwat
Link to comment
Share on other sites

Hi Erick, welcome to CADTutor.

 

Here is a start for you to test out and also you can use the command call "-insert" as well if you find the vla-* functions hard to deal with at the mean time.

(vla-insertblock
 (vla-get-modelspace
   (vla-get-activedocument (vlax-get-acad-object)))
 (vlax-3d-point '(0. 0. 0.))
 [color="magenta"]"C:\\Users\\Tharwat\\Desktop\\Drawing1.dwg"[/color] [color="olive"];; Replace this path of drawing with yours[/color]
 0.5
 0.5
 1.0
 0.)

 

Hi Tharwat,

Good day.

Thanks a lot for the helpful code that you just shared.

It really works the way I planned it to.

Also, this is a good start for me. I will just do some study to understand the code.

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

 Share

×
×
  • Create New...