[Search tip detail and code files using keywords, tip number, author name, etc ]
WBlock Macro
Tip# 3819 By Mike O'Flaherty On 06-Feb-2012
Rated By 0 users
Categories : Saving Files
Software type : AutoCAD 2012
Rename File To : No Files to download.
Use Cadalyst CAD Tip No. 3376 more easily.

Designer Mike O'Flaherty created this AutoCAD macro to help users execute a tip he shared in 2010: Minimize 3D File Size with WBlock

"I’d submitted a tip a while ago to reduce a completed drawing file to the bare minimum size using the WBlock command. One thing I found about the technique was that my coworkers sometimes were distracted and ended up saving an empty drawing over their newly cleaned block. To prevent the ensuing whining, I created a menu macro to do the thinking for them. I call it Atomic WBlock Purge. It seems to work fine in AutoCAD versions from 2008 to 2012.

"The following is entered into a toolbar/ribbon button or drop-down menu command as one continuous line of text:

^C^Cqsave;qsave;(setq or_tm (getvar"tilemode"))(princ);(setvar"tilemode" 1)(princ);(command".ucs" "W" "zoom" "e")(princ);(command "wblock" (strcat(getvar"dwgprefix")(getvar"dwgname")) "Y" "" "non" "0,0" "w" (getvar"vsmin") (getvar"vsmax") "")(princ);(command"zoom" "E");(command"delay" 1000);(setvar"tilemode"or_tm)(princ);(command "close" "yes");

"One click will issue two QSave commands, WBlock the contents to the same file location and file name, and close the open drawing without saving it. Why run QSave twice? So a backup of the original, unaltered file is created in case the operator issues the command by mistake. The user can rename the BAK to DWG to restore the drawing to its original (cluttered) condition.

"Understand that this command removes everything that is not being used in a drawing: unused layers, dimension and text styles, blocks, baubles and trinkets, etc. If you want to pick and choose which unused items to keep, don’t use this macro — that’s what the Purge command is for."

Notes from Cadalyst Tip Reviewer Brian Benton:
Using the WBlock command in AutoCAD to remove unwanted items is a great trick. This macro is very straightforward once implemented. Open the CUI (command user interface) and go to the Command window (at the bottom left). Click the star icon to make a new command. Paste the code provided above into the Macro field on the right. Add this command to any toolbar, panel, or tool palette.

When you click the command, your file is WBlocked out and overwrites the existing file. I was able to restore the previous version of the file from the BAK file that was generated, but be careful, just in case.


Average Rating:

User comments

Log In