Mora Teknikutveckling AB:s Logo Your Experts on Software Development
   Home ] About Us ] News ] Document Management ] CAD Utilies ] GIS ] Manual
   Sales ] [ Manual ]

 

 

AdocScrx - batch process files

Basics
The Script File
The COM Interface
Directory
Clear database button
Scan button
Execute button
The Browse Tab
The Settings Tab
Terminate/Restart hanging AutoCAD
The Log File
The Inspect AutoCAD button
Version information
FAQ

 

 

 

AdocScrx searches for files and can execute AutoCAD commands for each file found.

Basics

1. Search for files, add files to database
2. Execute Autocad commands

First of all, if everything was working without problems, there would be no need for the database.

But, since computers tend to do what you tell them to do, not want you want them to do, we do need the database.

The database makes it possible to restart whatever we were doing, if something unexpected happened. Beside this, it makes it possible to see what we are about to do, as well as see what we have done... 

 

The Script File

The script file is a series of commands, sent to Autocad, as if you typed them on the command prompt in Autocad. 

Sample:

zoom e
qsave

Simple as that, zoom extents and save.

The script file is a plain text file, saved with the suffix .scr and will be used by AdocScrx, for each drawing file in the database.

Tip: To create a new script file from an old, right click, open a file, then use "Save as" and a new name.

 

 

The COM Interface

Script files are ancient history, but the work and they have been around for many years.

One important rule is "If it ain't broken, don't fix it!"

So, we has "simply" added the new COM or OLE automation feature in Autocad to AdocScrx!

Any command in the script file starting with a hash symbol -  #  -  will be interpreted as a COM object or a COM method. The "dot notation" is used to separate each object, starting from the Autocad object (called oAcad).

Sample

To create a DWF file from via COM:

#ActiveDocument.Plot.PlotToDevice("xxxxx")

The ActiveX/COM documentation can be found in Autocad's help files. You can also use the "Inspect AutoCAD" button to browse the Autocad object directly to see each object, event and method!

 

Directory

Enter (or browse to) the directory of your choice. If you check the "Include subdirectories" checkbox, AdocScrx will iterate through every subdirectory found, searching for files. You will also have an entry in the log file with the number of files found in every subdirectory.

 

Clear database button

Erases every row in the database, use this one to start from scratch. 

 

Scan button

Starts searching the directory and subdirectories. All files found are added to the database and a total will be displayed on the status bar (lower left).

Subdirectories will be added as well, if the "Include subdirectories" checkbox is marked.  

 

Execute button

Loads and starts AutoCAD. Applies all commands specified in the script file to AutoCAD. The behavior of Autocad is partly depending on the configuration, see also the Settings tab.

 

The Browse Tab

The Browse tab displays the database, and is pretty straightforward.

You do not have to scan directories for drawings, you can use Explorer and drag & drop files as well.

If the files dropped on the database has a suffix (dwg, dxf, etc) specified in the configuration file, then the file will be added to the database.

Another option is to use a text file, i.e. a file with a .txt suffix, containing the the full file specification for each file that should be added, dropping such a text file on the database will add all found files as specified in the text file (again, each file must have a suffix as specified in the configuration file).

Sample text file:

C:\Drawings\123.cal
C:\Drawings\123132.dwg
C:\Drawings\123133.dwg
C:\Drawings\123134.dwg
C:\Drawings\123135.dwg
C:\Drawings\2000.ls.cal
C:\Drawings\200000.bak
C:\Drawings\200000.cal
C:\Drawings\200002-Layout1.cal
C:\Drawings\200002-Model.cal
C:\Drawings\200002.bak
C:\Drawings\200002.cal
C:\Drawings\200002.cls.dwf
C:\Drawings\200002.DWG
C:\Drawings\20000301.bak
C:\Drawings\20000301.DWG
C:\Drawings\20000401.DWG
C:\Drawings\20000601.bak
C:\Drawings\20000601.DWG
C:\Drawings\200007.bak

Simple drop the text file on the database, each line will be evaluated and valid files are added.

When a drawing file is processed by AutoCAD, it is marked as "Processed".

You can change any field (like "Processed") if you like to...

If you would like to use the database for other purposes, see the FAQ!

 

The Settings Tab

You have probably guessed it, this is where the configuration is done.

Default is to process DWG files.

If you wish to process DXF files, mark the corresponding checkbox.

If you would like to process other files than DWG or DXF files, see the FAQ!

 

Terminate/Restart hanging Autocad

This option starts another application, AdocScrx Server Proxy, which will monitor Autocad and send appropriate commands to Autocad to let the execution continue. There are a number of - quite annoying - dialogs, which are displayed when AutoCAD loads some drawings. 

Version 1.6 of AdocScrx Server Proxy will handle following "issues":

Genius
AutoCAD Message
AutoCAD Alert
AutoCAD Error Aborting
acad.exe - Common Language Runtime Debugging Services
AutoCAD Error-abort
Error Report Cancelled
AutoCAD Mechanical Error Report
AutoCAD Application
New Xref Path
Unsupported Operation
Proxy Information

The Log File

The log file is called LogFile.txt and shows the number of files found in each and every subdirectory found.

Logfile created 20060901.
Checking directory: C:\Drawings\*.dwg Number of files: 4
Checking subdirectory: C:\Drawings\Docs\*.dwg Number of files: 1

The Inspect AutoCAD button

This button loads and starts AutoCAD as a child object. 
The function can be used to inspect AutoCAD's Properties, Events and Methods:

Sometimes, it is difficult to remember each and every command, and this might be easier than to look in the documentation....

Sample:

Open a drawing in AutoCAD (Here C:\Drawings\22020.dwg).

Double-click the property "ActiveDocument":

Double-click the property "Plot":

Click on the "Methods" Tab:

So, the method for PlotToDevice is apparently ActiveDocument.Plot.PlotToDevice(<with some arguments>)

To find more info, look in the documentation in Autocad:

Help | Additional Resources | Developer Help
then search for "PlotToDevice"

There we see that the "argument" is the plot configuration (could have guessed that, right?)

So, to make a default plot to a DWF file, the command would be:

ActiveDocument.Plot.PlotToDevice("DWF6 ePlot.pc3")

The corresponding script file would look like this:

_z _e
#ActiveDocument.Plot.PlotToDevice("DWF6 ePlot.pc3")

Instead of the "traditional" "Zoom, Extents"  at line #1, we could have used a OLE command....
S line #1 zooms extents and line #2 publishes the drawing as a DWF file.

Simple as that....

 

 

Version information

Version information can be found in the "About..." dialog, accessible from the menu.

AdocScrx operates in SDI (single document mode) internally.

Some erroneous drawing files seems to hang AutoCAD 2006 if  the system variable ERRORREPORT has been set to 0!

AdocScrx does not send log files, problems are only added to the log file, LogFile.txt.

 

FAQ - Frequently asked questions

Q1. Can I use AdocScrx to scan my disk for other files than AutoCAD related drawing files? If so, how?

A1. Yes. Edit the configuration files, AdocScrx.ini. Locate Section [Misc], and the line SuffixList. Add the suffix you want to include (AdocScrx defaults to "dwg" files, so if you do not have the line SuffixList, AdocScrx will look for dwg files...)

[Misc]
SuffixList=dxf,dwg,

 -------------------------------------------------------------------------

Q2. Can I use the database for other purposes? What fields and data does AdocScrx store?

A2. Yes, why not? The structure is:

Table type DBASE, Version 7

Field     Field Name Type     Length     Dec      Index
1 Processed  LOGICAL  1 N
2 FileName  CHARACTER  40  Y
3 Path  CHARACTER  250  N

 -------------------------------------------------------------------------

 

© Mora Teknikutveckling AB 2006-2010