Processing Multiple Files with CADLock

Preface

In this document, we cover how to automatically process multiple files with CADLock, using four common methods. Mention of a particular product in this document does not imply any endorsement or recommendation by CADLock, Inc. This information is provided as a service to our users.

Processing multiple drawings consists of several steps:

The rest of this document discusses how to perform these steps using various tools. All the methods start out the same way. Start by reading the "Step 1" section immediately following.

Step 1

Figure out the sequence of commands you need to issue to CADLock without dialog boxes. (See the prompt sequence listing on page 21 of the CADLock 3.1 manual). You can set FILEDIA and CMDDIA to zero temporarily to try it out on a test drawing. In the following discussion, the string of characters will be referred to as the "<CADLock command sequence>". A typical CADLock command sequence to lock only database modification and database output is:

R D L L U U U U U U A

Step 2

There are several ways to proceed, some of them costing a little money.

Jump to Command Prompt Window section
Jump to Hurricane section
Jump to Batch Script Processor section
Jump to 4DOS/4NT section

Method A: Using your Command Prompt window

This method is free. It can only process files in one directory, and it processes all the files in that directory. The method detailed below may seem more complex than necessary. The complexity is required in Windows NT 4.0 with Service Pack 5 or Service Pack 6, may be required on other systems, and should work on all systems.

Create a directory that contains all the files you want to process, and no other drawing files.

Use Notepad or any text editor to set up a six-line script file looking like:

FILEDIA 0
CMDDIA 0
_SAVE (STRCAT (SUBSTR (SETQ DNAME (GETVAR "DWGNAME")) 1 (1- (STRLEN DNAME))) "X") <CADLock command sequence>
FILEDIA 1
CMDDIA 1
_QUIT
_Y

(Note that the third line of the file may wrap into two or more lines in this document). Be sure to replace "<CADLock command sequence>" with the appropriate commands (as described in Step 1, above).

Note: If you do not have CADLock set to automatically load with every drawing, you should also put:

(load "C:\\Cadlock\\Cadlock.lsp") CLSTART

at the beginning of the script file. If you are not sure if CADLock is loaded automatically, it will do no harm to add the loading line to the script file.

Save this in the file "C:\CADLock.scr". Now use your text editor to create a batch file with the following two lines:

@echo off
for %%f in (*.dwg) do start /WAIT RunACAD.bat "%%f"

Save this file as CADLock.bat in the directory containing the files you want to process.

Again use your text editor to create a batch file containing the following three lines:

@echo off
"C:\AutoCAD R14\acad.exe" "%1" /b C:\CADLock.scr
exit

(Substitute the appropriate path for "C:\AutoCAD R14\".)

Save this file as RunACAD.bat in the directory containing the files you want to process.

Now open a command prompt ("DOS") window, change to the directory containing the files you want to process. Type:

cadlock

and press the Enter key. Unless someone has made a mistake, AutoCAD should open, process a drawing, close, and repeat for all files in the directory.

Return to Top

Method B: Using Hurricane Script Generator

Hurricane is available from 74mph. At the time this is being written, it costs US$59.00 and a demonstration can be downloaded for free. Hurricane can process files from multiple directories. The following method has been tested with Hurricane version 2.02 and version 2.21.

Start Hurricane. In the "Initialize" box, enter:

CMDDIA 0 FILEDIA 0

If you do not have CADLock set to automatically load with every drawing, you should also put:

(load "C:\\Cadlock\\Cadlock.lsp") CLSTART

in the "Initialize" box. If you are not sure if CADLock is loaded automatically, it will do no harm to add the loading line to the script file.

In the "Uninitialize" box, enter:

CMDDIA 1 FILEDIA 1

Check the "No QSAVE" box.

For AutoCAD R13 only:

In the "Command" box, enter:

_SAVE (STRCAT (SUBSTR (SETQ DNAME (GETVAR "DWGNAME")) 1 (1- (STRLEN DNAME))) "X") <CADLock command sequence>

(all on one line). Be sure to replace "<CADLock command sequence>" with the appropriate commands (as described in Step 1, above).

For AutoCAD R14 and later:

In the "Command" box, enter:

_SAVE (STRCAT (SUBSTR (GETVAR "DWGPREFIX") (SETQ DNAME (GETVAR "DWGNAME")) 1 (1- (STRLEN DNAME))) "X") <CADLock command sequence>

(all on one line). Be sure to replace "<CADLock command sequence>" with the appropriate commands (as described in Step 1, above).

For all Versions of AutoCAD:

Select the files you want to process in the left side of the dialog box, and pick the "Create Script File" button at the bottom of the dialog box.

Hurricane will generate a script to process all files you have selected. Warning: If you have CADLock 3.12 or earlier, you MUST edit this script file and change any the ".dwg" extensions to ".DWG". That is, the ".DWG" extensions in the script file must all be in upper case!

Start AutoCAD. Make sure that the drawing you are in has not been changed (in some systems, just opening a blank drawing results in a changed drawing).

At the AutoCAD "Command:" prompt, pick "Tools" from the top-line menu and pick "Run Script…". Select the script file that was created by Hurricane and pick the "Open" button. AutoCAD should process all the drawings.

Return to Top

Method C: Using Batch Script Processor

Batch Script Processor is available from CAD fx. At the time this is being written, it costs US$75 and a demonstration can be downloaded for free. Batch Script processor can process drawing files from multiple directories. The following method has been tested with Batch Script Processor version 2.34.

You must have CADLock version 3.13 or later to use Batch Script Processor to process multiple files with CADLock.

Batch Script Processor is an ARX application that runs inside AutoCAD. Load the ARX if necessary (the default is for Batch Script Processor to load itself in every drawing session) and, at the "Command:" prompt, type:

batchscr

In the window on the left, select the files you wish to process and transfer them to the window on the right with the "Add >>" button.

If this is the first time you have done batch processing with Batch Script Processor, pick the "New" button. Otherwise, select a script using the "Find" button and open it with the "Edit" button.

For AutoCAD R13 only:

Batch Script Processor does some things that require a very slightly more complex script file. The script should look like the following eight lines:

FILEDIA 0
CMDDIA 0
TEXTEVAL 1
_SAVE (STRCAT (SUBSTR (SETQ DNAME (GETVAR "DWGNAME")) 1 (1- (STRLEN DNAME))) "X") <CADLock command sequence>
CLRESET
TEXTEVAL 0
FILEDIA 1
CMDDIA 1

(Note that the third line may wrap into two or more lines in this document). Be sure to replace "<CADLock command sequence>" with the appropriate commands (as described in Step 1, above).

If you do not have CADLock set to automatically load with every drawing, you should also put:

(load "C:\\Cadlock\\Cadlock.lsp") CLSTART

at the beginning of the script file. If you are not sure if CADLock is loaded automatically, it will do no harm to add the loading line to the script file.

For AutoCAD R14 and later:

Batch Script Processor does some things that require a very slightly more complex script file. The script should look like the following eight lines:

FILEDIA 0
CMDDIA 0
TEXTEVAL 1
_SAVE (STRCAT (GETVAR "DWGPREFIX") (SUBSTR (SETQ DNAME (GETVAR "DWGNAME")) 1 (1- (STRLEN DNAME))) "X") <CADLock command sequence>
CLRESET
TEXTEVAL 0
FILEDIA 1
CMDDIA 1

(Note that the third line may wrap into two or more lines in this document). Be sure to replace "<CADLock command sequence>" with the appropriate commands (as described in Step 1, above).

If you do not have CADLock set to automatically load with every drawing, you should also put:

(load "C:\\Cadlock\\Cadlock.lsp") CLSTART

at the beginning of the script file. If you are not sure if CADLock is loaded automatically, it will do no harm to add the loading line to the script file.

For all Versions of AutoCAD:

Save the script. In the Batch Script Processor window, pick the "Run Script" button. AutoCAD should process all the drawings.

Return to Top

Method D: Using 4NT or 4DOS

These programs are enhanced command processors (they execute all the functions of COMMAND.COM or CMD.EXE). 4NT and 4DOS look like a command prompt window. This method is similar to method A but it can process drawing files from multiple directories.

These programs are available from JP Software. Any of the programs costs US$69.95 (at the time this is written), and evaluation versions of all the programs may be downloaded. JP Software also publishes Take Command, a GUI command processor that is supposed to work just like 4DOS and 4NT. Unfortunately, we have not figured out how to run CADLock on multiple files using Take Command. If you figure it out, please let us know.

In a 4DOS or 4NT window create a file containing the full pathnames of the files you want to process. For example, to create this file in C:\DRAWINGS.TXT:

dir /f/b *.dwg >c:\drawings.txt

and to add to an existing file:

dir /f/b *.dwg >>c:\drawings.txt

Edit the file as required to remove any drawings that you do not want to process.

Use Notepad or any text editor to set up a six-line script file looking like:

FILEDIA 0
CMDDIA 0
_SAVE (STRCAT (SUBSTR (SETQ DNAME (GETVAR "DWGNAME")) 1 (1- (STRLEN DNAME))) "X") <CADLock command sequence>
FILEDIA 1
CMDDIA 1
_QUIT
_Y

(Note that the third line of the file may wrap into two or more lines in this document). Be sure to replace "<CADLock command sequence>" with the appropriate commands (as described in Step 1, above).

Note: if you do not have CADLock set to automatically load with every drawing, you should also put:

(load "C:\\Cadlock\\Cadlock.lsp") CLSTART

at the beginning of the script file. If you are not sure if CADLock is loaded automatically, it will do no harm to add the loading line to the script file.

Save this in the file "C:\CADLock.scr". Now use your text editor to create a batch file with the following two lines:

@echo off
for %%f in (@c:\drawings.txt) do start /WAIT "C:\AutoCAD R14\acad.exe" %%f /b C:\CADLock.scr

(Substitute the appropriate path for "C:\AutoCAD R14\", and substitute the appropriate drawings list file for "c:\drawings.txt". Note that the second line may wrap into two or more lines in this document.)

Save this file as CADLock.bat.

In a 4DOS, 4NT, or Take Command window, change to the directory containing CADLock.bat. Type:

cadlock

and press the Enter key. Unless someone has made a mistake, AutoCAD should open, process a drawing, close, and repeat for all the files listed in the drawings.txt file.

Return to Top

 

Send comments about this site to the webmaster.

Copyright 2003 CADLock, Inc. All rights reserved.