Use EDMSCHK to Automate CAD Standards Checking (From the Trenches AutoCAD Tutorial)

31 Oct, 2007 By: Robert (Bob) Zipprich

These variations on the basic engineering document-management code can help you maintain control of your drawings.

To help our CAD department carry out the needed quality control, I created EDMSCHK, a compilation of several AutoLISP program modules for AutoCAD that can be used as stand-alone functions or mixed and matched into one program (as in this case) to suit your needs. I've combined all modules here to carry out some last-minute fixes to CAD drawings and to finish up the CAD standards checking we are doing before issuing drawings to the client. Download EDMSCHK now.

EDMSCHK is short for Engineering Document Management Systems Check. Here, however, I'm not checking the EDMS system itself, but rather the CAD drawings that are managed by the system. My EDMSCHK modules, or functions, also can be called by other LISP programs. They return a text string that is either a report message or a name of an object such as an xref or image file name, or attributes from a block, but first things first:

Getting Started
To begin using EDMSCHK, put the two files EDMSCHK.TXT and EDMSCHK.XLS in the directory D:\CAD\. Put the other EDMS*.LSP files in one of the directories in the AutoCAD Support File Search Path set (Options/Files/Support File Search Path). I suggest D:\Custom\. Type: (load "EDMSCHK") at the AutoCAD Command line to launch the series of checks performed by each module. EDMSCHK works on only one drawing at a time, but can be combined with Publish or Batch Plot to check multiple drawing sets. With a text editor now open the file D:\CAD\EDMSCHK,TXT and view the results. You should see something like this:

Drawing1.dwg	NO BORDER FOUND

Don't worry. Nothing happened. The program probably crashed because we haven't given it anything intelligent to work with yet. Before we do some setup let's discuss some things about our report file.

When you have finished running the EDMSCHK program in a drawing, it will have written report data to EDMSCHK.TXT in a tab-delimited format. I like to copy/paste the entire contents from the text file to Excel file EDMSCHK.XLS and where the columns can be formatted. The text file and the Excel file are already formatted for my titleblock, but with a little trial and error can be modified for your own use.

The following are descriptions of the EDMSCHK modules, in the order that they are processed. They can be used as single functions or combined. For the purpose of this article they are assumed to be combined into one function called EDMSCHK.LSP.

EDMS Check
Let's assume I want to run this program in batch mode. I first set my AutoCAD options to load ACAD.LSP each time a drawing is opened. From the Autocad main menu select Tools > Options > System and select the button for loading Acad.lsp with each drawing. Using Notepad or another text editor, I add the following line to the ACAD.LSP file LISP code so EDMSCHK runs every time I open a drawing:

	(load "EDMSCHK")

While I'm drafting and not doing a final check, I comment out the line using the standard LISP semicolon:

	; (load "EDMSCHK")

Then, when I'm ready, I do a quick bit of text editing and am back in business for the final review.

Before I'm finished with a set of drawings for issue, I first check the report file for final clean-up. The report lists each file name along with an ATTRIBUTE DATA, ERROR message, FILE/PATH message, or an OK message, depending on the results of the different modules being run. Because we're running all the modules as one to start with, our results may vary, but if I've done a good job following the CAD standards while doing my drafting, there will be lots of OKs in many of the different columns in the report.

Using File > Publish from the Autocad main menu, open a batch plot session and plot the whole drawing issue set. EDMSCHK will run each time Publish opens a drawing and will search the drawing titleblocks and write their attribute content to a report file (D:/CAD/EDMSCHK.TXT) with the name of each drawing file. Also EDMSCHK will save its changes (Purge, Ltscale, Viewres, etc.) and silently goes its way.

For those who would like to see some indication that the program is running, I've added a prompt dialog box to the code, which in the code is currently commented out, but with a little LISP lingo on your part you can incorporate an onscreen notification (EDMSCHK.DCL).

Later I can peruse the report file in Microsoft Excel, sort it for viewing, and check for errors and omissions, duplicate titleblocks, spelling errors, etc. I like to print the report out on our plotter about 36" x 60" so I can see the results of the whole drawing issue set. A plot of the report is a good visual aid for the whole CAD department.

EDMSCHK is defaulted to look for CORP*-named titleblocks (line 33), and the code specifies the location of the report file as D:\CAD\EDMSCHK.TXT (line 35), but with a little text editing you can use your own names and locations. When a drawing titleblock is missing, EDMSCHK still writes the drawing name to the report file and indicates NO TBLK FOUND. EDMSCHK will also find multiple titleblocks within the same drawing, so multiple layouts are not a problem.

Returns text string:  123456.001.DWG  CORP-D
                      (followed by tab-delimited list)
or                    123456.001.DWG  NO BORDER FOUND

The following files are loaded and run by the EDMSCHK program:

EDMS Document and Discipline Check
EDMSCHK calls on EDMSDDCHK.LSP to compare two of the titleblock attributes with a standard set of drawing titles and disciplines. If your clients use file management software to upload files to their servers, it likely rejects drawings for one reason or another. The one I am familiar with rejects drawings whose titleblock attributes for TITLE and DISCIPLINE do not match a standard set. Checking for agreement with these sets, EDMSDDCHK writes error messages to the report file when one or both violate the standard sets.

Returns text string:  DISPOK       DOCCHKOK    D&DCHKOK
or                    DISPCHKERR   DOCCHKERR   D&DERR

EDMS Delete Dictionary
I borrowed some code found in an AutoCAD discussion group (thank you, Joe Burke) to make EDMSDELDICT.LSP. The code sifts the drawing file database for dictionary elements "AcStStandard" and deletes them. The LISP code removes the AutoCAD element containing any CAD standards link to (*.DWS) files. Why delete them? Why bug the client with his own CAD standards violations?

Returns:  T

EDMS Dimension Check
EDMSCHK then calls on EDMSDIMCHK.LSP to check for any existing dimensions that use the standard Dimstyle. One of our clients uses dimension styles named for the drawing plot scale, so with a quick check, dimensions using the standard style get reported. This doesn't fix the dimensions but reports them if it finds any.

Returns text string:  STDDIMCHK-OK
or                    STDDIMCHK-ERR

EDMS Image Check
Then EDMSIMAGECHK.LSP writes to the report file any image files found in the drawing. Unresolved images are not reported. For multiple images, the names are string concatenated. Once the report is complete, it will be obvious whether the drafter attached them with paths saved or not. If you have ever encountered xrefs or images saved from nonexistent drives or servers, you can appreciate why we check for this.

Returns text string:  " "
or                    114281.006.TIF
or                    O:\Client\ReferenceSubs\123456.001.TIF

EDMS Xref Path Check
EDMSXREFPATHCHK.LSP basically does the same thing as the image check, except with xrefs in a drawing. The paths/names of xref drawings are concatenated and written to D:/CAD/EDMSCHK.TXT. Xref names (with or without saved paths) are written in the report.

Returns text string:  NONE
or                    114281.006.TIF
or                    O:\Client\ReferenceSubs\123456.001.TIF

EDMS Viewport Check
EDMSVPORTCHK.LSP finds all viewports, including paper space, and determines whether they are polygonal (that is, attached to a polyline) or simply rectangular. This may be a little nitpicky, but we have a client who doesn't want polygonal viewports. C'est la vie. The report tells all.

Returns text string:  VP-OK
or                    VP-POLY

EDMS Standard Blocks Check
EDMSSTDBLKCHK.LSP verifies that standard blocks, xrefs, and viewports reside on their specific named layers (usually "0"). In this bit of code is where I like to add/subtract/customize the laundry list of CAD ideas for my clients and projects. CAD standards are always changing, and sometimes a global fix is easier than going into each drawing and doing the same function again and again. I still use the Script command and write scripts to do a lot of tasks. Repetition invites boredom, and boredom invites errors, and errors may get caught, but a good script is a thing of beauty.

CAD Standards
Autodesk has supplied us with a tool to help head off the train wreck that will invariably happen if we don't follow standards: the CAD Standards Checker. As CAD coordinator, I've attached client-specific standards check files (DWS) to each of our company template files (DWT) that AutoCAD uses to create new drawings. This means all layers (and their associated colors and/or linetypes), linetypes, text styles, and dimension styles are screened by the CAD standards check file. The drawing system variable (setvar) STANDARDSVIOLATION can be set to display a warning to the user when his or her drafting styles conflict with those of the company or client.

Summing Up
I have included a few additional files to help get you started: ACAD.LSP, a sample drawing file, and a Power Point file, along with the Lisp files that do the work.

I hope you'll find my batch of routines helpful in your effort to check and clean up AutoCAD drawings before they leave your department.

As the Phantom Drafter would say, It's not an error until it goes out the door.