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:
- 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:
Once the script is saved under c:\temp\plot.scr, you can test it before moving further. To do so, right click on any .dwg file and select "Print." You should see the viewer opening up the dwg file, executing the above script and then closing the document. If there are any errors in the script, you will see them right away in the viewer's command window. If nothing happens, i.e. the viewer does not open, you should check that you entered the registry values exactly as shown above.
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:
What is quite neat with the BatchConvert solution is that you do not even see the viewer opening up and closing each document separately, all the processing is done silently in the background.
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.