Hello All -
Has anyone attempted to use VB/VBA or Vlisp to set options (specifically file name) for prints originating in AutoCAD? If so - I would greatly appreciate any tips on how to begin.
Thanks,
Peter
That's how I get it done. You can play w/ the options, though. Just showing you my method to my madness :)private withevents mypdf as PDFCreator.clsPDFCreator
private readystate as boolean = true
private sub pdf_create()
mypdf = New PDFCreator.clsPDFCreator
If mypdf.cStart("/NoProcessingAtStartup") = False Then
mypdf.cClose()
mypdf = Nothing
Shell("taskkill /f /im PDFCreator.exe", AppWinStyle.Hide, True)
mypdf = New PDFCreator.clsPDFCreator
mypdf.cStart("/NoProcessingAtStartup")
End If
Dim dp As String = mypdf.cDefaultPrinter
With mypdf
.cDefaultPrinter = "PDFCreator"
.cClearCache()
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = "C:\Your\Directory\Path" 'Make sure you leave off the trailing \
.cOption("AutosaveFormat") = 0
.cOption("AutosaveFilename") = "your_file_name" 'Make sure you leave off the .pdf
.cOption("PDFUseSecurity") = 1
.cOption("PDFOwnerPass") = 1
.cOption("PDFOwnerPasswordString") = "your_pass"
.cOption("PDFDisallowCopy") = 1
.cOption("PDFDisallowModifyContents") = 1
.cOption("PDFDisallowModifyAnnotations") = 1
.cOption("PDFHighEncryption") = 1
.cPrintFile("C:\Path\to\CAD\File.dwg")
.cPrinterStop = False
readystate = False
Do While Not readystate
Application.DoEvents()
Loop
.cPrinterStop = True
.cDefaultPrinter = dp
.cCloseRunningSession()
.cClose()
End With
mypdf = Nothing
end sub
Private Sub pdf_ready() Handles mypdf.eReady
readystate = True
End Sub
I should mention that this code is practically copied out of the COM folder in C:\Program Files\PDFCreator. They provide pretty good documentation. The only IP I added was the taskill for the /NoProcessingAtStartup startup flag. If you need more examples, make sure to check in the COM folder. :)
endersshadow - thank you for answering. Yes, I did look at that code and couldn't quite figure out how to make it work for my situation. I am using vlisp to plot so the VB printer object is not available (... as far as I know).
I ended up modifying the registry as needed before sending each plot through the autocad plot object - and resetting it after the PDF file is created. These keys need to be modified:
"AutosaveFormat" "AutosaveDirectory" "AutosaveFilename" "UseAutosave" "UseAutosaveDirectory"
in "HKEY_CURRENT_USER\Software\PDFCreator\Program"
So far I haven't run into any problems...
Peter
This is not a good solution:
...
Shell("taskkill /f /im PDFCreator.exe", AppWinStyle.Hide, True)
...
Better:
If mypdf.cStart("/NoProcessingAtStartup") = False Then
...
mypdf.cStart("/NoProcessingAtStartup", True)
...