You are currently reviewing an older revision of this page.
Any existing sheet models in a drawing should be printed to PDF via VBA.
In the following example, such an approach is shown. As a prerequisite, it is assumed that a printer driver set to print to PDF is already present.
Sub
PlotAllerBlattmodelle()
Dim
oMod
As
ModelReference
Filename
String
PDFFilename
'Define the output Directory:
If
ActiveWorkspace.IsConfigurationVariableDefined(
"MS_PLTFILES"
)
Then
Filename = ActiveWorkspace.ConfigurationVariableValue(
Filename = Filename + ActiveDesignFile.Name
Else
Filename = ActiveDesignFile.FullName
End
'Open the print dialog, so that the "Print" command loads:
CadInputQueue.SendCommand
"DIALOG PLOT"
'Print each sheet model:
For
Each
In
ActiveDesignFile.Models
oMod.Type = msdModelTypeSheet
oMod.Activate
'Output filename is based on drawing name + model name:
PDFFilename = Filename +
"--"
+ oMod.Name +
".PDF"
'Print to File:
"print execute "
+ PDFFilename
Next
To make sure the output directory is checks, we will use the variable defined as MS_PLTFILES.
If it is checked, the path is used for output. The filename of the PDF file is defined by the drawing name + model name.
This will only print sheet models, and all other models will be ignored while printing.