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.
Dim oMod As ModelReference
Dim Filename As String
Dim PDFFilename As String
'Define the output Directory:
If ActiveWorkspace.IsConfigurationVariableDefined("MS_PLTFILES") Then
Filename = ActiveWorkspace.ConfigurationVariableValue("MS_PLTFILES")
Filename = Filename + ActiveDesignFile.Name
Filename = ActiveDesignFile.FullName
'Open the print dialog, so that the "Print" command loads:
CadInputQueue.SendKeyin "DIALOG PLOT"
'Print each sheet model:
For Each oMod In ActiveDesignFile.Models
If oMod.Type = msdModelTypeSheet Then
'Output filename is based on drawing name + model name:
PDFFilename = Filename + "--" + oMod.Name + ".PDF"
'Print to File:
CadInputQueue.SendKeyin "print execute " + PDFFilename
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.