Jump to content

How to get a certain block from external DWG?


Recommended Posts

Posted

I did some searches before posting this, but I can't find something that can solve my curiosity.

I want to insert block that is defined inside another file using LISP.

For example, I have DWG library (let's say anno.dwg) that has several annotation symbols. I want to load elevation symbol block and insert to an active file. The idea is to keep the dynamic block behavior. Because if I save each block as a file separately, I will loose the dynamic functionality.

 

Can you guys guide me, how to do it. I'm new with LISP, so please be gentle with me :oops:

 

Thanks ;)

Posted

Desgin Center (Ctrl+2) :) in conjunction with Tool palettes, (Ctrl+3) theres no other native autocad function that can deliver what you want done with blocks

Posted

I'm aware with design center and tool palettes.

I just hope that we can do that with LISP. Another way around is load all the blocks required to my templates. But it will make it too big if I have many blocks... or I need to have several templates :(

Posted
I'm aware with design center and tool palettes.

 

I see, okeedokee, How are you planning to accomplish this? questions for you:

1. Knowing what block to retrieve from the external drawing? (are we talking about XREF here? :unsure:) without knowing which file the particular block resides.

(browse a folder i suppose)

2. There are local blocks (blocks that exist only on that particular file) and there are BLOCKS (e.i. DWG Library).. are these "symbol blocks" a part of your library?, bear in mind that are instances that blocks are redefined from one drawing to another. (you'll be surprise how often that happens)

3. is the External drawing currently open? (guess thats how you fiugre out that when you cut and paste it looses its Dynamic Behavior.)

Gathering info on a non active or close drawing can be done thru ObjectDBX (but not sure about grabbing the blocks is possible if its not part of your DWG library, (i mean local blocks)

capturing the block name is easy and re-inserting it on your active drawing, but recreatinbg them will take a lot of work

 

 

just laying out your options buddy, I still think Design Center is the way to go :)

Posted

What I'd "really" like is to be able to redefine blocks from another DWG into the current. That doesn't seem to easy, even through ObjectDBX.

Posted
What I'd "really" like is to be able to redefine blocks from another DWG into the current. That doesn't seem to easy, even through ObjectDBX.

 

I'm not sure I follow you - what do you mean 'redefine' blocks from another drawing?

Posted

Thank you Lee. Nice one. I need to do similar thing but have the function as part of my own program. I'll examine the program. Still a long way to go, because I just get to AutoLISP basic. :oops:

Posted
I'm not sure I follow you - what do you mean 'redefine' blocks from another drawing?
Say you have 2 DWG files. Let's call them A and B. Inside each are blocks named X, Y & Z. You have A currently open in ACad. You want to update the block definitions of X, Y & Z inside A to match that of the definitions inside B. As you can do one at a time through DC, by Right-click --> Redefine only. But you want to do this to multiple blocks in one step.

 

This is something which ACad's never had. Which is a standard with something like BricsCAD. E.g. when you insert a DWG as a block - ACad checks if that DWG's filename is the same as an already defined block in the current drawing. If so it asks you if you want to redefine. But no matter what you answer to this, if the inserted drawing contains nested blocks with same names as those you already have ... all you get is a message of: Duplicate definition of block ###### ignored.

 

In BricsCAD you get an additional message to ask if you want that/those block(s) to be redefined as well: Yes / No / Yes to All / No to All. (irrespective of your answer to the possible 1st question) It's as if ACad just assumes you will always answer No to All.

Posted
Say you have 2 DWG files. Let's call them A and B. Inside each are blocks named X, Y & Z. You have A currently open in ACad. You want to update the block definitions of X, Y & Z inside A to match that of the definitions inside B. As you can do one at a time through DC, by Right-click --> Redefine only. But you want to do this to multiple blocks in one step.

 

Good point - I can't immediately think of a way to accomplish this without effectively purging the existing definiton and using CopyObjects from an ObjectDBX Document of the external drawing to copy the block definition - but this would mean rebuilding all the references... Unless you copied it with another name, renamed all the references to take on this new name (and hence use that definition), then purge out the old defintion, and go through the renaming again... :geek:

 

Unless I'm misundertstanding it, difficult one.

Posted
:o Well... I'll be a monkeys uncle, there is a way to do it thru lisp

 

Nothing is impossible my friend :D

Posted

Would it be possible to generate a temporary file containing the block (as if you did a WBlock on the ODBX-opened-DWG). I know you can't send commands through ODBX, but can you create a new blank DWG, then populate its *MODEL_SPACE block by CopyObjects from each item in the block to it. Then you can use Insert to redefine that temporary DWG file into the current DWG. Delete the file, and continue with the next block.

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