Jump to content
erickson19886

LISP Code To Insert Block To a Drawing Template

Recommended Posts

erickson19886

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

Share this post


Link to post
Share on other sites
Tharwat

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

Share this post


Link to post
Share on other sites
erickson19886
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.

Share this post


Link to post
Share on other sites
Tharwat

Good luck and happy coding. :)

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
Tharwat

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×