TheSwamp

CAD Forums => CAD General => Topic started by: Skeeps on December 15, 2008, 07:13:58 AM

Title: Replacing one block with another
Post by: Skeeps on December 15, 2008, 07:13:58 AM
I have a titleblock that I created. I then updated loads of drawings with it. Bit later on I had to change the logo and now I have to exchange all these drawings with the new titleblock. I don't want to lose the  attributes information I've already creatd for these drawings so I tried Importing the new titleblock in,  however it says 'duplicate definition of A0 Sheet ignored' or something to that effect and the new imported titleblock looks like the old one. anything I can do here?
Title: Re: Replacing one block with another
Post by: mjfarrell on December 15, 2008, 07:18:56 AM
You will want to use the old -Insert Block Name=Block Name trick to insert/replace the old one with the new one.

From Help File



Updating a Block Path: If you enter a block name without a path name, INSERT searches the current drawing data for an existing block definition by that name. If no such block definition exists in the current drawing, INSERT searches the library path. If a file is found, the file name is used for the block name upon insertion of the block definition. The same block definition is used for subsequent insertions of that block. You can replace an existing block definition with an external file by entering the following at the Enter Block Name prompt:
block name=file name

Updating a Block Definition: If you make changes to a block file that is inserted in your drawing and you want to change the existing block definition without creating a new block insertion, enter the following at the Specify Insertion Point prompt (following the Enter Block Name prompt):
block name=

If you enter = after the block name, the following prompt is displayed:

Block "current" already exists. Redefine it? [Yes/No] <No>: Enter y, enter n, or press ENTER

If you choose to redefine the block, the existing block definition is replaced with the new block definition. The drawing is regenerated, and the new definition is applied to all existing insertions of the block definition. Press ESC when prompted for the insertion point if you do not want to insert a new block into the drawing.

Title: Re: Replacing one block with another
Post by: quamper on December 15, 2008, 09:17:40 AM
If the block is on a tool palette, just right click on it and select redefine. I do that all the time.. even for temporary blocks just drag them on to a palette and them delete them off when no longer needed.
Title: Re: Replacing one block with another
Post by: Skeeps on December 15, 2008, 09:26:20 AM
Mjfarrell I am following your post I want to exchange my block called A1 SHEET that lies within my drawing for one that is in an external file, I've put it within the same folder as the drawing. this is what I get back

Command: -insert Enter block name or [?]: A1 SHEET=WBS
Block "A1 SHEET" already exists. Redefine it? [Yes/No] <N>: Y
Block A1 SHEET references itself
Regenerating layout.
Regenerating model.
*Invalid*


umm confused.
Title: Re: Replacing one block with another
Post by: M-dub on December 15, 2008, 09:40:23 AM
Why not reinsert the updated block, redefining the definition, then use BATTMAN to sync up the attributes?
Title: Re: Replacing one block with another
Post by: Skeeps on December 15, 2008, 09:47:09 AM
could I keep the attribute values that I've already filled out doing that?
Title: Re: Replacing one block with another
Post by: M-dub on December 15, 2008, 09:55:49 AM
Yepper!  :)

(Test it out first)
Title: Re: Replacing one block with another
Post by: Skeeps on December 15, 2008, 10:05:54 AM
maybe that would work. But I think the problem is the blocks are named the same thing. So I have to delete the old titleblock and purge the drawing ( killing the attributes) before I can insert the new block.
Both are named A1 SHEET.
Title: Re: Replacing one block with another
Post by: M-dub on December 15, 2008, 10:10:05 AM
Try the command, DDINSERT and when it asks you if you want to redifine it, say yes.  It should keep the attributes that are already there.  (You don't actually have to insert the block a second time... as soon as you hit 'Yes' to redefine, you can cancel the command and should get the same result)
After that, you can use BATTMAN or ATTSYNC to add the new attribute definitions to the existing block.
Title: Re: Replacing one block with another
Post by: M-dub on December 15, 2008, 10:18:16 AM
When you're using the DDINSERT command, remember to go and browse out to the location of the blocks dwg file instead of just using the definition of the block that already exists in the drawing.
Title: Re: Replacing one block with another
Post by: Skeeps on December 15, 2008, 11:17:43 AM
Yeah okay but I still get this and can't see anything asking me where to redefine it.



Thankyou for your help on this..I'm sorry maybe I'm being a dumbass.
Title: Re: Replacing one block with another
Post by: ronjonp on December 15, 2008, 11:22:22 AM
You need to do something like this:

(command ".-insert" "nameofblock=full\\path\\nameofblock.dwg" '(0 0 0) (command))
Title: Re: Replacing one block with another
Post by: Skeeps on December 15, 2008, 11:35:25 AM
awww...I tell you what my brain is fried.
Perhaps it's something to do with how I set up the blocks themselves.

Title: Re: Replacing one block with another
Post by: M-dub on December 15, 2008, 11:36:20 AM
Give this macro a try.  You'll have to change it up a bit to suit the block you're using.

Code: [Select]
^C^C-insert;drawing1=C:/drawing1.dwg;\;;;[color=red];;;[/color]^CATTSYNC;N;DRAWING1;
a) replace DRAWING1 with the name of your block
b) replace C:/ with the path TO your block
c) count how many attributes your block contains and put that many semicolons in place of where you see the three red ones.

(hope that makes sense...)
Title: Re: Replacing one block with another
Post by: M-dub on December 15, 2008, 11:37:16 AM
Just a stab in the dark here, but it looks like you could have a definition of that block inside itself.
Title: Re: Replacing one block with another
Post by: ronjonp on December 15, 2008, 11:47:58 AM
Just a stab in the dark here, but it looks like you could have a definition of that block inside itself.

Bingo!
Title: Re: Replacing one block with another
Post by: Skeeps on December 15, 2008, 11:51:06 AM
Yeah I think you maybe right.
Not sure I created all these blocks. But I'm not sure how to rectify it.
Title: Re: Replacing one block with another
Post by: ronjonp on December 15, 2008, 11:53:03 AM
Can you post your block?
Title: Re: Replacing one block with another
Post by: M-dub on December 15, 2008, 12:04:19 PM
Yeah, if you can post the block, we can fix it for you, but if not you should be able to do it.  Before you modify your block, save a backup copy then get to work on it.

Open the block file, use QUICKSELECT to find the Block Reference with the Name property matching your block name (filename).  See what happens when you delete it.
Then try purging everything out of the drawing and save it.

Go back into the drawing you want to update and try Ron's suggestion or my macro and see what happens.

EDIT:  Too late... there's the block.  :)
Title: Re: Replacing one block with another
Post by: quamper on December 15, 2008, 12:04:31 PM
I stuck the block on a tool palette.. Then inserted it into a new drawing. Populated the atrributes. Switched back to the original drawing with the block made some geometry changes inside. Flipped back to new drawing. Hit re-define on my tool palette and boom updated block with no attributes changed.
Title: Re: Replacing one block with another
Post by: Skeeps on December 15, 2008, 12:08:49 PM
oh thanks guys, I got so far with the macro, but to be honest..It's pretty new to me and alot of stuff ended up in red. I have to leave now to go and pick up my kiddiewinkles.  I'll have a bash at this tomorrow and let you know.


Thanks once again, you've been very patient. :mrgreen:
Title: Re: Replacing one block with another
Post by: ronjonp on December 15, 2008, 12:09:27 PM
If you are going to update using -insert this is how i would approach it (one drawing per titleblock).

Here's a little snippet you could add to startup to automagically update them :)

Code: [Select]
(defun c:updatetitleblocks (/ path)
  (setq path "c:\\your\\path\\here\\")
  (foreach name '("a0 portrait" "a0 sheet" "a1 portrait" "a1 sheet" "a2 portrait" "a2 sheet"
  "a3 sheet")
    (if (and (tblobjname "block" name)
     (ssget "_x" (list (cons 2 name)))
)
      (command ".-INSERT"
       (strcat name "=" path name ".dwg")
       '(0 0 0)
       (command)
      )
    )
  )
  (princ)
)
Title: Re: Replacing one block with another
Post by: Kate M on December 15, 2008, 01:30:08 PM
What about Express Tools' Block Replace?
Title: Re: Replacing one block with another
Post by: quamper on December 15, 2008, 01:35:36 PM
What about Express Tools' Block Replace?

Doesn't that only works with blocks already in the drawing that are named two different things?

I think in this situation, my solution is the absolute simplest. I tested with his actual block and it worked so I'm not sure what the problem is  :|

Unless there are alot of drawings and you're trying to automate it.. but if you're opening up the drawings anyway I think it's the simplest solution
Title: Re: Replacing one block with another
Post by: Kate M on December 15, 2008, 02:12:09 PM
What about Express Tools' Block Replace?

Doesn't that only works with blocks already in the drawing that are named two different things?
Ah yes, you are correct. I was thinking that you could browse for the replacement block, but I guess not.
Title: Re: Replacing one block with another
Post by: Skeeps on December 16, 2008, 04:05:39 AM
morning chaps. I've got a small job to do then I'll give your suggestion a go Quamper.

Title: Re: Replacing one block with another
Post by: Skeeps on December 16, 2008, 05:45:35 AM
ok because I have absolutly loads of these drawings to update I'm going to try just renaming the block. A0 SHEET will be called A0SHEET
If that doesn't work then I'll use your way Quamper.


Title: Re: Replacing one block with another
Post by: Skeeps on December 16, 2008, 06:13:56 AM
It Worked! Party time!
just renaming the blocks now I can use insert then express tools to replace the block.
A right mix of everything.


Thankyou all so much for your help. X
Title: Re: Replacing one block with another
Post by: M-dub on December 16, 2008, 07:56:56 AM
Glad you got it figured out, Skeeps!  :)
Title: Re: Replacing one block with another
Post by: quamper on December 16, 2008, 08:17:52 AM
Great glad it worked!