Public Shared Sub PlotLayout() ' Get the current document and database, and start a transaction Dim acDoc As CAD_ApplicationServices.Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As CAD_DatabaseServices.Database = acDoc.Database Using acTrans As CAD_DatabaseServices.Transaction = acCurDb.TransactionManager.StartTransaction() ' Reference the Layout Manager Dim acLayoutMgr As CAD_DatabaseServices.LayoutManager = CAD_DatabaseServices.LayoutManager.Current ' Get the current layout and output its name in the Command Line window Dim acLayout As CAD_DatabaseServices.Layout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), CAD_DatabaseServices.OpenMode.ForRead) ' Get the PlotInfo from the layout Using acPlInfo As CAD_PlottingServices.PlotInfo = New CAD_PlottingServices.PlotInfo() acPlInfo.Layout = acLayout.ObjectId ' Get a copy of the PlotSettings from the layout Using acPlSet As CAD_DatabaseServices.PlotSettings = New CAD_DatabaseServices.PlotSettings(acLayout.ModelType) acPlSet.CopyFrom(acLayout) ' Update the PlotSettings object Dim acPlSetVdr As CAD_DatabaseServices.PlotSettingsValidator = CAD_DatabaseServices.PlotSettingsValidator.Current ' Set the plot type acPlSetVdr.SetPlotType(acPlSet, CAD_DatabaseServices.PlotType.Extents) ' Set the plot scale acPlSetVdr.SetUseStandardScale(acPlSet, True) acPlSetVdr.SetStdScaleType(acPlSet, CAD_DatabaseServices.StdScaleType.ScaleToFit) ' Center the plot acPlSetVdr.SetPlotCentered(acPlSet, True) ' Set the plot device to use acPlSetVdr.SetPlotConfigurationName(acPlSet, "Klenkdrucker.pc3", "A4") ' Set the plot info as an override since it will ' not be saved back to the layout acPlInfo.OverrideSettings = acPlSet ' Validate the plot info Using acPlInfoVdr As CAD_PlottingServices.PlotInfoValidator = New CAD_PlottingServices.PlotInfoValidator() acPlInfoVdr.MediaMatchingPolicy = CAD_PlottingServices.MatchingPolicy.MatchEnabled acPlInfoVdr.Validate(acPlInfo) ' Check to see if a plot is already in progress If CAD_PlottingServices.PlotFactory.ProcessPlotState = CAD_PlottingServices.ProcessPlotState.NotPlotting Then Using acPlEng As CAD_PlottingServices.PlotEngine = CAD_PlottingServices.PlotFactory.CreatePublishEngine() ' Track the plot progress with a Progress dialog Using acPlProgDlg As CAD_PlottingServices.PlotProgressDialog = New CAD_PlottingServices.PlotProgressDialog(False, 1, True) Using (acPlProgDlg) acPlEng.BeginPlot(acPlProgDlg, Nothing) acPlEng.BeginDocument(acPlInfo, acDoc.Name, Nothing, 1, True, "c:\temp\myplot.pdf") Using acPlPageInfo As CAD_PlottingServices.PlotPageInfo = New CAD_PlottingServices.PlotPageInfo() acPlEng.BeginPage(acPlPageInfo, acPlInfo, True, Nothing) End Using acPlEng.BeginGenerateGraphics(Nothing) acPlEng.EndGenerateGraphics(Nothing) ' Finish plotting the sheet/layout acPlEng.EndPage(Nothing) acPlProgDlg.SheetProgressPos = 100 acPlProgDlg.OnEndSheet() ' Finish plotting the document acPlEng.EndDocument(Nothing) ' Finish the plot acPlProgDlg.PlotProgressPos = 100 acPlProgDlg.OnEndPlot() acPlEng.EndPlot(Nothing) End Using End Using End Using End If End Using End Using End Using End Using End Sub