PDA

View Full Version : Modifying blocks in multiple drawings



witsend
31st Jan 2007, 08:44 pm
If I have a group of blocks that I use within a drawing. And I changed all those blocks slightly (for me they are symbols used on a bunch of different maps). Is there a way for me to get those blocks to change in all of my drawings? Instead of having to go through and change each drawing individually?

I use AutoCAD LT 2007.

dbroada
31st Jan 2007, 09:23 pm
AFAIK, you will have to open each drawing.


You should WBLOCK the redefined symbols and then INSERT= from the command line or use the INSERT command and browse for the redefined symbol. You will be asked if you want to redefine blockname

witsend
31st Jan 2007, 09:31 pm
Thats what I was afraid of :(

That sucks. Oh well, here I come 100+ drawings :(

dbroada
31st Jan 2007, 10:41 pm
in that case you can script it. Do a search on script, we discused it about a week ago. The script will be something like...



insert
blockname=
0,0


zoom
e
erase
l

qsave


That will insert a block (redefined) at 0,0. You will have to get the correct number of blank lines for scale & rotation etc. Then erase the last object (the zoom extents as last is really last visible.

You can find a batch file to perform a script on every file in a folder.

Seann
1st Feb 2007, 12:28 am
Here is a batch code that will open all files in a specific folder.

FOR %%V IN (*.DWG) DO START /W "c" "C:\Program Files\Autodesk Architectural Desktop 2006\acad.exe" %%V /nologo /b "W:\TDC CAD STANDARDS\TDC Toolbars\Lisp\***.scr"
FOR %%V IN (*.BAK) DO DEL %%V

This is the path of where your AutoCAD is opening (copy from the icon you use to open AutoCAD)

This is the place were the script is located

This is the name of the script

Copy and paste this into notepad and save as a .bat file. Put this file in the folder were all the drawings are and double click the .bat. This will open AutoCAD run the script and close AutoCAD. Go to the next file and repeat.
If you use dbroda's started script and use this .bat this should do what you need in no time. I would also say do this during lunch or at night because your computer is useless while it runs. Do make sure it runs and does what it is intended to do before you just walk away though. Hope this was a help.:)

Go here for more info about his topic:
http://www.cadtutor.net/forum/showthread.php?t=10623

witsend
1st Feb 2007, 12:54 am
Ok, I'm not too good with this script writing stuff but I'll try.

One thing I'm a little concerned about is. I just went into one of the drawings and changed the blocks to what I needed (minor tweaking and changing some layer issues). So they're the same names as the blocks that are already in the drawing. How do I tell the script to pull the blocks from one particular drawing and put them into another?

Seann
1st Feb 2007, 01:06 am
scripting is easy. Image scripting as you doing the commands in Autocad but 1000 times faster. You could go into a drawing and change the block and write down the steps as you go in notepad with all the commands and enters. And the block insertion name should be controlled by the script and the insert command. Post your code when your done to have us look at it to make sure it is ok if you feel like you need help. Thats why we respond to threads we like to help.:geek:

witsend
1st Feb 2007, 01:15 am
scripting is easy. Image scripting as you doing the commands in Autocad but 1000 times faster. You could go into a drawing and change the block and write down the steps as you go in notepad with all the commands and enters. And the block insertion name should be controlled by the script and the insert command. Post your code when your done to have us look at it to make sure it is ok if you feel like you need help. Thats why we respond to threads we like to help.:geek:

Ok awesome! Yeah I'm making it and it sort of makes sense! You guys are awesome.

So I'm gonna go sort of a different route since the changes I made to the symbols were always very routine - so I'm just going to have the script open block edit for each of the blocks and change what I need it to.

And thats where i've run into a problem. I can't figure out what command to use to select all the objects in block edit - or how to change their layer once I do...

(ok so I didn't get very far :( ) but once I get that I'm pretty much done.

So any ideas??

I tried Select and then all. But that doesn't seem to work, and then I can't get to properties for the layer change (I usually click through those instead of typing commands)

EDIT: To be clearer - it does select the whole block like I want, but then I can't get out of the "select function" and I can't figure out how tell it to change the layer.

bedit
facp
select
all (RIGHT HERE IT DIES!)
properties
layer
fire layer
bsave
bclose
qsave

witsend
1st Feb 2007, 01:47 am
Ok, never mind my last post - I searched around here and found a better command for what i wanted!

You guys are incredible!

bedit
facp
_ai_selall
laymch
n
fire layer
bsave
bclose
qsave




Thats the script I've got, but I have to repeat it for all my blocks, then I'm gonna run it through using that batch code you gave me! Thanks again!!!

witsend
1st Feb 2007, 02:39 am
Here is a batch code that will open all files in a specific folder.

FOR %%V IN (*.DWG) DO START /W "c" "C:\Program Files\Autodesk Architectural Desktop 2006\acad.exe" %%V /nologo /b "W:\TDC CAD STANDARDS\TDC Toolbars\Lisp\***.scr"
FOR %%V IN (*.BAK) DO DEL %%V

This is the path of where your AutoCAD is opening (copy from the icon you use to open AutoCAD)

This is the place were the script is located

This is the name of the script

Copy and paste this into notepad and save as a .bat file. Put this file in the folder were all the drawings are and double click the .bat. This will open AutoCAD run the script and close AutoCAD. Go to the next file and repeat.
If you use dbroda's started script and use this .bat this should do what you need in no time. I would also say do this during lunch or at night because your computer is useless while it runs. Do make sure it runs and does what it is intended to do before you just walk away though. Hope this was a help.:)

Go here for more info about his topic:
http://www.cadtutor.net/forum/showthread.php?t=10623

I tried the .bat file. And all that happens is a DOS screen flashes up for an instance, then closes. And thats it :wink: I've checked the file location names twice and they're correct. So I can't figure out what I'm doing wrong.

dbroada
1st Feb 2007, 09:48 am
can you post the text of both the script and the batch file you have made please?

tip:
go to the "advanced" page of this board and use the "code" button (the # one) to surround your file text.


This is
what it
will look like

Dave1910
1st Feb 2007, 01:23 pm
Hi
There is a way to do this without usin script files
I reckon once youve got it set up it should take about 2 - 3 mins per drawing.

Basically, you open a blank drawing and insert the new (revised) block into it. Then delete it.

Go into one of the drawings with the old block. Freeze all layers except one the block is on.

Select everything (use Ctrl+A), right click and select cut from menu (or cut from edit menu at top of screen)

Go into the blank drawing you inserted the block into, then right click and select 'paste to original coordinates'.

The blocks will come in and reference themselves to the revised block, keeping alll orientation settings as well.

Go into old drawing and purge old block out (type 'PU' and 'purge all'. Keep clicking 'Purge all' until there is nothing left to purge)

Go back into other drawing, select all, cut, go into old drawing and paste to original coordinates.

Unfreeze all layers.
Done!

Sounds long winded, but you should be able to write a couple of simple macros do so the donkey work for you

I'd be glad to do them for you if you can tell me the name of the block and layer its on.

Hope this helps

Dave G

dbroada
1st Feb 2007, 01:34 pm
2-3 Minutes/drawing! That's far too long for over 100 drawings.

A script will probably do 100 drawings in about 5 minutes, possibly less (depending on the speed of your machine and the complexity of the script).

As an example we have some wiring diagrams that get created by a VB program. This produces 2 "half" drawings in DXF format. I start AutoCAD and run a script file that uses a VBA routine to join the 2 halves together and save them. I recently produced 293 drawings in 4 minutes.

dbroada
1st Feb 2007, 01:42 pm
Hi
There is a way to do this without usin script files
I reckon once youve got it set up it should take about 2 - 3 mins per drawing.

Basically, you open a blank drawing and insert the new (revised) block into it. Then delete it.

Go into one of the drawings with the old block. Freeze all layers except one the block is on.

Select everything (use Ctrl+A), right click and select cut from menu (or cut from edit menu at top of screen)

Go into the blank drawing you inserted the block into, then right click and select 'paste to original coordinates'.

The blocks will come in and reference themselves to the revised block, keeping alll orientation settings as well.

Go into old drawing and purge old block out (type 'PU' and 'purge all'. Keep clicking 'Purge all' until there is nothing left to purge)

Go back into other drawing, select all, cut, go into old drawing and paste to original coordinates.

Unfreeze all layers.
Done!

Sounds long winded, but you should be able to write a couple of simple macros do so the donkey work for you

I'd be glad to do them for you if you can tell me the name of the block and layer its on.

Hope this helps

Dave G
you don't really need to do any of that. Open the INSERT dialogue box, click browse to get to where the new file is stored and select it. You will be asked if you want to redefine it, answer Y and then escape the command. All your blocks have now been redefined. If the new block has different attributes you can type ATTSYNC to update those too.

If you want to script it you need to get the older insert command without the dialogue box which is what I was trying to explain earlier.

If you want to replace a set of old blocks with a set of new blocks with different names you can rename the old blocks to the new name first and then follow either of the above methods

OR

Insert OldName=NewName

Dave1910
1st Feb 2007, 02:35 pm
That is true, but not all versions of AutoCAD have the redefine block option.
The method I described will work no matter what version of AutoCAD is being used.

Dave G

dbroada
1st Feb 2007, 02:37 pm
???really, I've used it from version 10.

Dave1910
1st Feb 2007, 02:40 pm
Really.
I had to use this method when using LT (cant remember what version tho')

dbroada
1st Feb 2007, 02:43 pm
did you add a "=" after the block name? That's how it always used to work before dialogue boxes.



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>: Entery, entern, or pressENTER
If you choose to redefine the block, the existing block definitionis 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.

Dave1910
1st Feb 2007, 02:50 pm
Nah, 'fraid not.
I was fairly new to AutoCAD back then (only 5 years ago, but seems so much longer) and only knew how to perform the functions that had an icon!!
I had to come up with something that worked using my limited knowledge.
By the way, I knew about the 'redefine block' feature, but not the 'ATTSYNC' one, so thanks for that.

Dave G

dbroada
1st Feb 2007, 02:58 pm
If you look back a week you will find that I didn't know about it either

Seann
1st Feb 2007, 04:39 pm
Can you post both codes (.bat with locations and the script) so I can take a look at them? Thanks.

witsend
1st Feb 2007, 05:24 pm
Hey guys thanks so much for being so helpful.

Here is the script, I'm pretty much just changing the layer a bunch of my blocks are on. The layer I had them in was causing me problems and my boss decided he wanted them all in a sort of 'symbol' layer. I know the script works (whether I did it the best way or not I don't know) because I've run it on files manually and it went fine.


bedit
campus key box
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
cyber bollard
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
electricalshutoff
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
facp
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
fdc
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
fire dept access point
_ai_selall
laymch
n
fire layer
bsave
bclose
save
bedit
fire hydrant
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
fixed bollard
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
gamewell box
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
gasshutoff
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
floor split
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
knox box
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
northleft
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
northup
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
oms bollard
_ai_selall
laymch
n
fire layer
bsave
bclose
save
bedit
piv main control valve
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
standpipe hose connection
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
subfacp
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
watershutoff
_ai_selall
laymch
n
fire layer
bsave
bclose
bedit
zone control valve
_ai_selall
laymch
n
fire layer
bsave
bclose
qsave


Here is the .bat file. I have to admit - I don't really understand what this one says so I could have done something completely wrong to screw it up and wouldn't know it.


FOR %%V IN (*.DWG) DO START /W "c" "C:\Program Files\AutoCAD LT 2007\acadlt.exe" %%V /nologo /b "\\ehsfs.ehs.berkeley.edu\homes\!ehs-students\My Documents\Shannon\layer.src"
FOR %%V IN (*.BAK) DO DEL %%V

Seann
1st Feb 2007, 08:06 pm
Think I found the problem. Were you are running your script from is were I think it is getting confused. Can you keep the script in your C:\ root?
Just put the script at C:\layer.scr and try this .bat


FOR %%V IN (*.DWG) DO START /W "c" "C:\Program Files\AutoCAD LT 2007\acadlt.exe" %%V /nologo /b "C:\layer.scr"
FOR %%V IN (*.BAK) DO DEL %%V

dbroada
1st Feb 2007, 08:14 pm
and the script should be .scr NOT .src :wink:

Seann
1st Feb 2007, 08:31 pm
and the script should be .scr NOT .src :wink:
Yeah that might help also :D

witsend
1st Feb 2007, 08:49 pm
YAYYY!!! It works! This is soo cool! Thank you guys soo much you just saved me tons of time!

Yeah I had to move EVERYTHING to the C: drive which is hard to do because of the way they have our work computers set up (the desktop/my documents etc. is on the server while the programs are local on the C: drive).

Thanks again! You guys rock!