Jump to content

Scripts to insert specific block from another drawing?


vernonlee

Recommended Posts

Script to insert specific block (base on name) to drawing from a template drawing with many blocks

 

Is that possible?

 

What would the code be written as?

 

I intend to use as a macro & attached it to a button icon.

 

Thanks

Edited by vernonlee
Link to comment
Share on other sites

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • vernonlee

    17

  • SEANT

    9

  • ReMark

    4

  • tombu

    3

Top Posters In This Topic

Isn't that the purpose of the Design center?

 

As an alternative put the block on a custom tool palette.

 

Not every single task requires a lisp or a macro.

Link to comment
Share on other sites

The ADCNAVIGATE command can open Design Center with a specific drawing.

http://cadtips.cadalyst.com/misc-palettes/open-design-center-specific-folders

 

Thanks. Will look into that. Unless it's faster than using tool palettes.

 

The long time favorite Steal.lsp by Lee-mac. Does more than blocks.

 

Hi BIGAL. I do use that but for other purposes.

 

For blocks specifically, my daily work routine requires inserting titleblocks which there are 8 different types of titleblock (all in 1 file) depending on the situitation.

 

Current setup is through tool palettes. Which I normally have it closed to maximize screen space.

 

So when I need a titleblock I would have to press ctrl+3 for tool palettes to popout first

 

So I was thinking of having it as an icon with a text script instead. So just press icon, poof! Titleblock will appear.

 

That is what I am planning.

 

Basically I try to arrange all my commands, wherever possible, in a form of an icon or keystroke shortcut since they are the fastest method of execution

 

barring a wormhole

 

"the shortest distance between two points is a straight line"

Edited by vernonlee
Link to comment
Share on other sites

Basically I try to arrange all my commands, wherever possible, in a form of an icon or keystroke shortcut since they are the fastest method of execution

 

I hope this does not comes across the wrong way but i do like to state that:-

 

Contary to popular belief, I do not always favour LISP nor search or asked here without going through general autocad commands or method first.

 

It does not matter what it is called. Efficiency has always been my deciding factor

 

So hope this dispel any such myth about me.

 

Thanks. :)

Edited by vernonlee
Link to comment
Share on other sites

On to the topic at hand, many months back, if i am not mistaken, I THINK ( I carn't confirm) I ever came across on how the scripts is to be writen but for the life of me i could not find it. :unsure:

Edited by vernonlee
Link to comment
Share on other sites

The long time favorite Steal.lsp by Lee-mac. Does more than blocks.

 

Ranked as one of my top 5 downloads ever! One of the drop-downs in my Ribbon that uses it is for adding layouts from a template.

Link to comment
Share on other sites

Script to insert specific block (base on name) to drawing from a template drawing with many blocks

 

Is that possible?

 

What would the code be written as?

 

I intend to use as a macro & attached it to a button icon.

 

Thanks

 

This could be done in an AutoCAD LT compatible manner. For example, this command macro (InsertC):

 

^C^C_insert;"BlocksABCD";0,0,0;;;;_erase;last;;-insert;"C";\;;;

 

Could be used if the container file “BlocksABCD.dwg” resides in one of the Support File Search Paths.

BlocksABCD.dwg

Link to comment
Share on other sites

You must be the most efficient CAD tech in the world then.

 

ReMark. Haha. I would not say that.

I am just a slow guy trying his best on how to be faster when his supervisor gives her occasional "are you done yet glare" & not get fired. That's all.

Link to comment
Share on other sites

Given the amount of time and effort you expend trying to come up with these macros and lisp routines what is the payback? Do you create dozens of new drawings every day wherein a different size title block and border is required to be inserted? Why not have a template file already set up for each of the eight different sizes? Wouldn't that be more efficient? Or, include all of them in one drawing as layouts and delete the ones you know need.

Link to comment
Share on other sites

Given the amount of time and effort you expend trying to come up with these macros and lisp routines what is the payback? Do you create dozens of new drawings every day wherein a different size title block and border is required to be inserted? Why not have a template file already set up for each of the eight different sizes? Wouldn't that be more efficient? Or, include all of them in one drawing as layouts and delete the ones you know need.

 

I only work with existing drawings.

 

My daily routine is to create part print of those drawings. There are about close to a thousand dwg files.

Everyday i will be asked to do part print of ONLY certain specific drawings.

 

Part print basically means for me to cloud the changes & do a part view of the drawing instead of the original whole drawings.

So since it is now a smaller view, I will also need an apporiate size title block to go with it. Depending on the size of the part view, it can be A1, A2,A3 or A4.

All this thousands of drawings do not come with this different sizes of titleblock. They only come in only A0 size.

 

So that is why i need to insert different sizes of titleblock.

 

So the fastest way for me is to insert this title block as blocks.

 

Talking about template. I do have a template. This template contain all this 8 no. of title blocks (they are 2 types hence 2 x 4 = 8 ) as individual block names.

 

So inserting this title block to the existing drawing is the most obivous & direct way I know in this current work situition.

 

Briefly now knowing a little of my work situition, if you do have a faster alternative way, please pray tell. I always keep an open mind.

Edited by vernonlee
Link to comment
Share on other sites

This could be done in an AutoCAD LT compatible manner. For example, this command macro (InsertC):

 

^C^C_insert;"BlocksABCD";0,0,0;;;;_erase;last;;-insert;"C";\;;;

Could be used if the container file “BlocksABCD.dwg” resides in one of the Support File Search Paths.

 

Hi SEANT. Appreciate the reply.

 

I totally understand what you mean. Did a couple of searches before & I got similar response.

The issue is I am not inserting a whole drawing (WBLOCK) as a block.

 

The block I am inserting from is just a block within a drawing file.

 

Example:-

2 drawing files

1) Template.dwg contains A1 block, A2 block, A3 block & A4 block

2) Existing.dwg

 

I require a script that will insert ONLY A3 block from Template.dwg into Existing.dwg.

 

Hope you have an answer for that

 

Also, if anyone is still reading, at this point of time, I am only keen in using scripts to insert this blocks.

UNLESS someone can confirm & tell me THAT cannot be done. THEN will give that up & I consider LISP & tie it to a icon shortcut.

 

Thanks

Edited by vernonlee
Link to comment
Share on other sites

That's what that command macro does.

 

Bear in mind, it is a crude example.

 

The file BlocksABCD.dwg contains four block - A, B, C, and D. The macro first inserts the drawing as a block, but immediately deletes it. What that does, though, is load the current drawing with the definitions for that, plus the 4 nested blocks. One of the nested blocks (C, in my example) is then inserted into the drawing.

Link to comment
Share on other sites

Granted, the current file will contain definitions that may never be needed, but those can always be eliminated with a call to the Purge command.

Link to comment
Share on other sites

I suppose if you preferred to keep the Block Table tidy, the purge could happen within the macro, for example:

 

^C^C_insert;"BlocksABCD";0,0,0;;;;_erase;last;;-insert;"C";\;;;-purge;b;"BlocksABCD";n;;b;"A";n;;b;"B";n;;b;"D";n;

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