cadalyst
AEC

Make Mine a DWG, Part 2: Check Your Work

3 Jan, 2007 By: Scott MacKenzie

Tips to help you clean up AutoCAD drawings.


Untitled Document

In the last edition of AEC Tech News, I introduced a series about how to create DWG files from other CAD formats. Part 1 detailed how to translate your ArchiCAD files into AutoCAD files. In today’s edition, I’ll offer some tips to help you clean up those new DWG files once you create them.

If you use AutoCAD, you've probably received DWG files from consultants and other outside sources to use on a project. If these files are from someone who doesn't use AutoCAD, they're most likely a mess when you get them -- everything in the drawing is white, and/or the dashed linetypes are solid. If you've had to clean up these files, you've probably used a few four-letter words to describe your feelings. And if you've printed them, you have surely cursed the sender of these files, because you had to spend 20 minutes fixing the lineweights and linetypes in each drawing just to get it to print correctly.

The problem is, your consultants and clients who create DWG files from non-AutoCAD programs don't check their work. Why? Well, either they don't care, or they don't have software to check their work. There is no excuse for either. Anyone can download Autodesk TrueView for free. (True View is AutoCAD without any drawing or editing tools; it's great for viewing and printing DWG files.)

Let the Cleanup Begin

So how do you clean up these files after you receive them? I’ll offer several techniques -- some simple, some more advanced.

Purge and Audit. At the very least, you will want to run the PURGE and AUDIT commands. These commands will remove unused layer and block definitions and attempt to remove any file corruption.

Delete Layer Filters. If you receive AutoCAD files from someone who uses AutoCAD, you still should run the above commands and delete any layer filters that are present. Layer filters are like parasites: As they grow in number, they will increase your file size and slow down your drawing. Blocks inserted from outside your drawing will bring their layer filters along too, to stay like unwanted houseguests. You can delete these layer filters manually from the layer manager.

Or, download Cadalyst’s LISP code “Delete Layer Filters 1” (Tip 1886, DELFIL.LSP, July 2003), to delete all the layer filters in a drawing with one click. (I added it to my custom AutoCAD menu.)

In AutoCAD 2006 a system variable named LAYERFILTERALERT was added to help deal with this issue. It deletes excessive layer filters to improve performance. When a drawing has 100 or more layer filters, and the number of layer filters exceeds the number of layers, LAYERFILTERALERT provides a method for deleting layer filters to improve performance. There are four settings to this variable, as shown below.

0 - Off

1 - When the Layer Manager is opened, deletes all layer filters; no message is displayed

2 - When the Layer Manager is opened, displays a message that states the problem, recommends deleting all filters, and offers a choice: “Do you want to delete all layer filters now?”

3 - When the drawing is opened, displays a message that states the problem and offers to display a dialog box where you can choose which filters to delete

Layers and Colors. Renaming layers can be a big hassle. But generally speaking, you won't need to worry about this unless you are creating a submittal package for an especially picky client. The Layer Translator command, LAYTRANS, will help you convert layers to a particular standard. This includes control over linetype, color and lineweight.

Quick Fix for Plotting

If I need to quickly fix a drawing so it will plot properly per our in-house plot style, I change layer colors by clicking different drawing elements. I created a LISP routine that will change the layer color when you click on an item on that layer. For instance, click on a door, enter the color name or number, press Enter and you're done. Go over the rest of the drawing like this and you can have it ready to plot in 60 seconds.

;;;LCC.LSP  Scott H. MacKenzie 7/14/94
;;;Layer Color Change
;;;Change layer color by an object pick
(defun c:LCC (/ OBJ TLLE LAYN COL)
  (prompt "\nSelect something to change it's layer color: ")
  (setq OBJ (entsel))
  (setq OBJL (car OBJ))
  (setq LAYN (cdr (assoc '8 (entget OBJL))))
  (setq COL (getstring "\nEnter color name or number: "))
  (command "layer" "C" COL LAYN "")
)

Be Specific

What if the doors are on the wrong layer or the window tags need to be deleted? What if you have to fix the same thing on multiple files on a regular basis? Then I would suggest using LISP routines and script files. You can make them available in your custom menus and/or run them on multiple drawings with a batch script processor. I use Batch Script Processor by CAD fx ($90), and it's awesome. I can run a script file on dozens of files at once, which saves a huge amount of time.

Here's the code for a very simple script file. It changes all the layers to color 56 -- the color our engineers like to use for architectural backgrounds -- then saves the drawing. I run this script on all the background files exported from our ArchiCAD projects.

layer color 56 *

qsave

Using the layer command in script files can be tricky; you must keep a space after the asterisk and the next line blank to get this script to work properly. Next, take this script file and run it on multiple drawings using a batch script processor.

Be More Specific

The following is a LISP routine that will erase all continuous lines found on the Defpoints layer, erase all hatches found on the Defpoints layer, erase all blocks with the name "Block1," and move all blocks named with a prefix of "Metal_Shelves" to a specific layer.

(defun c:DELFIX ()

(command "-layer" "thaw" "*" "on" "*" "")

(setq DPLIN (ssget "X" '((0 . "LINE") (6 . "Continuous") (8 . "Defpoints"))))
 (if (= DPLIN nil)
  (princ "\n No lines on Defpoints layer found \n")
   (progn
    (command "erase" DPLIN "")
        (setq DPLIN nil)
   )  
  )

(setq HTCH (ssget "X" '((0 . "HATCH") (8 . "Defpoints"))))
 (if (= HTCH nil)
  (princ "\n No Hatches on Defpoints layer found \n")
   (progn
    (command "erase" HTCH "")
        (setq HTCH nil)
   )  
  )

(setq BLK1 (ssget "X" '((0 . "INSERT") (2 . "Block1*"))))
 (if (= BLK1 nil)
  (princ "\n No Block1 found \n")
   (progn
    (command "erase" BLK1 "")
        (setq BLK1 nil)
   )  
  )

(setq MS (ssget "X" '((2 . "METAL_SHELVES*"))))
 (if (= MS nil)
  (princ "\n No Metal_Shelving blocks found \n")
   (progn
    (command "layer" "m" "a-flor-case-n" "")
    (command "chprop" MS "" "LA" "a-flor-case-n" "")
    (setq MS nil)
   )  
  )

 

(princ)
)

This is just an example of a routine I use to fine-tune my AutoCAD drawings. You can duplicate the subsections of this code and change them to handle blocks with different names, or other entities on other layers. Create as many as you need. Then you can run this LISP routine from a script file and use a batch script processor. The script file code below will load and run the LISP file, purge and audit, and then save the file.

(load "DelFix.lsp")
DELFIX
audit y
-purge a  n
-purge a  n
-purge a  n
qsave

Tons of free LISP routines are readily available for your hacking pleasure; visit Cadalyst’sGet the Code! to get started.

Don't hesitate to take some extra time to figure this stuff out. You might have project managers breathing down your neck because the task is not "chargeable time." Tell them to chill out, or do it when they're not looking. (I know I have.) Your time spent on this will benefit them and the operation of your entire office because it will improve file consistency, accuracy and overall productivity. Good luck.
 
Good News for ArchiCAD Users

On the business side of software, Nemetschek AG recently announced plans to acquire Graphisoft (which owns ArchiCAD). Nemetschek is a software developer that makes VectorWorks, Allplan and Cinema 4D. This should turn out to be a very good thing for future versions of ArchiCAD. If ArchiCAD can assimilate certain technologies from these other products, it will be an extraordinary BIM package.

I'm specifically interested in Nemetschek’s multimedia visualization software, CINEMA 4D, and its capabilities. ArchiCAD could use a boost in the area of free-form modeling and high-end rendering. Having this kind of alliance and support will give Revit a run for its money. Look out, Autodesk!  


More News and Resources from Cadalyst Partners

For Mold Designers! Cadalyst has an area of our site focused on technologies and resources specific to the mold design professional. Sponsored by Siemens NX.  Visit the Equipped Mold Designer here!


For Architects! Cadalyst has an area of our site focused on technologies and resources specific to the building design professional. Sponsored by HP.  Visit the Equipped Architect here!