First you need a good CAD viewer that can view and print good quality CAD drawings and that lend itself to be automated without too much trouble. The ideal candidate that we found is the DWGTrueView 2010 from Autodesk(r). Once the viewer is installed, you first need to tweak the registry as follows:
- Open the registry editor (regedit) and browse to the following location:
[HKEY_CLASSES_ROOT\DWGTrueView.Drawing.18\shell\print\command]
- Set the “Default” value to:
"C:\Program Files\DWG TrueView 2010\DWGVIEWR.exe" "%1" /b "c:\temp\plot.scr"
What this will do is run the c:\temp\plot.scr script whenever a Print command is requested. Here is a sample Autocad(r) script that instructs the viewer to print the drawing to the Amyuni PDF Converter printer:
Code: Select all
;BEGIN SCRIPT
PLOT
Y
MODEL
Amyuni PDF Converter
LETTER
INCHES
LANDSCAPE
NO
DISPLAY
FIT
0,0
NO
.
YES
YES
N
Y
Y
CLOSE
;END SCRIPT
Once the script is validated, you can write another VBS script to automate the batch conversion of multiple drawings to PDF. Here is a sample VBS script:
Code: Select all
Dim cdi
Set cdi = CreateObject("CDIntfEx.CDIntfEx.4")
cdi.DriverInit( "Amyuni PDF Converter" )
cdi.FileNameOptionsEx = &H4003
cdi.DefaultFileName = "c:\temp\test.pdf"
cdi.BatchConvert "c:\temp\*.dwg"
Set cdi = Nothing
Advanced users can do more sophisticated things such as generating layered PDFs from the source DWG drawing. To generate a layered PDF, each layer in the drawing can be printed to one PDF then all the layers merged together in a single PDF using the Merge method of Amyuni PDF Converter.