Applies To | |||
Product(s): | MicroStation | ||
Version(s): | 08.11.09.578 | ||
Environment: | Windows 7 32 bit,Windows 7 64 bit | ||
Area: | Programming | ||
Subarea: | VBA | ||
Original Author: | Tristan Anderson, Bentley Technical Support Group | ||
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 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 Else Filename = ActiveDesignFile.FullName End If '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 oMod.Activate 'Output filename is based on drawing name + model name: PDFFilename = Filename + "--" + oMod.Name + ".PDF" 'Print to File: CadInputQueue.SendKeyin "print execute " + PDFFilename End If Next End Sub
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.