Jump to content

LISP Code To Insert Block To a Drawing Template


Recommended Posts

Posted (edited)

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
Posted (edited)

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

Posted

You may want to look at tool palettes if your going to do this for lots of blocks, maybe something like this older method via menu's.

Screen Shot 03-29-16 at 01.29 PM.PNG

Posted

The OP needs codes to use and to learn from it and that's why they posted in AutoLISP forum.

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