Monday, October 13, 2014

Creating a Batch Script for AutoCAD with CadTempo

Have you ever found yourself with a large number of AutoCAD drawings that you need to make changes to? It can be a very tedious and time consuming task.

AutoCAD comes equipped with a number of tools that can address this situation. The most simple of these is the script file - which also works with AutoCAD LT. I've used this method many times in the past to process hundreds of drawings at a time. When left to its own devices, the editing time that CadTempo had captured for those drawings was lost. In order to eliminate that problem a script generator was added to CadTempo. This article describes how to create a batch script within CadTempo and reclaim that logged time.

First, we need to enable and display the script maker. Open the CadTempo viewer and navigate to Options, then the Setting tab. Check the checkbox labeled Show Script Maker as shown in the image. *If you operate a different CAD program this will not be enabled. If your CAD program has scripting available please let us know and we will investigate adding its functioning.*

The AutoCAD Script Maker will now be visible when you return to the Files window and you can begin creating your AutoCAD script template.

CadTempo populates the script edit box with a basic script template. You can modify this script to suit your needs, or load a previously saved template. You'll notice there is a placeholder named Filename. When the batch script is created this will be replaced with the drawing names that you select for processing. Once you have determined the script template is functioning properly in AutoCAD you can save the template for future use.

Select the Drawing Files

If you already have multiple folders checked for other viewing or reporting purposes, you can save the current check list for later reloading. From the main menu bar go to File>>Save Check List. Now you can click the Clear Checked button. The button label will change to "Oops..." to immediately restore the checkbox state if needed.

Select the AutoCAD drawing files to be processed by placing a check next to the desired files in the list box. To process all the files in the folder you can place a check in the folder tree. If you wish you can restrict the files to be included in the batch script to a single folder by checking the "This Folder Only" checkbox.

Create the Batch Script

When you click the Create... button you will see a dialog box that displays the list of files that will be included in the batch script.

If you determine the list is incorrect the Cancel button will return you to the Files window and allow you to modify the selected files. Optionally you can add or remove files in the list, however care must be taken to insure each line entry is a valid drawing file name. When you are satisfied with your selection, press OK to create and save the batch script. After saving you will see a message reminding you to keep the CadTempo viewer open during the batch run. The Restore Logged Data button will be enabled.

If you wish to make a final examination before running the script open the saved .scr file. This is the result from the example.

After running the script in AutoCAD (or AutoCAD LT) click the Restore Logged Data button.

We are very interested in building a library of common tasks that can benefit from batch processing. If you would like to share a script template you find useful please send us an email with your template for future inclusion with CadTempo.