一般的に、間取り図のような大きな図面を印刷するときは、実際の作図単位を、印刷するインチまたはミリメートルに変換する尺度を指定します。しかしモデル空間から印刷するときは、設定が指定されない場合に使用される既定にはシステム プリンタへ出力、現在の表示を印刷、尺度自動調整、回転角度 0、オフセット 0,0 が含まれます。
PlotSettings オブジェクトを使用して印刷するレイアウトの印刷設定を変更し、次に PlotSettings オブジェクトを PlotInfo オブジェクトに渡す前に PlotSettingsValidator オブジェクトを使用して印刷設定を検証します。PlotInfo オブジェクトが定義されたら、PlotEngine オブジェクトを使用してレイアウトやシートを印刷できます。
この例では、現在のレイアウトのオブジェクト範囲を Myplot という名前の DWF ファイルに印刷します。
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.PlottingServices ' Plots the current layout to a DWF file <CommandMethod("PlotLayout")> _ Public Shared Sub PlotLayout() ' Get the current document and database, and start a transaction Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() ' Reference the Layout Manager Dim acLayoutMgr As LayoutManager = LayoutManager.Current ' Get the current layout and output its name in the Command Line window Dim acLayout As Layout = _ acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), _ OpenMode.ForRead) ' Get the PlotInfo from the layout Using acPlInfo As PlotInfo = New PlotInfo() acPlInfo.Layout = acLayout.ObjectId ' Get a copy of the PlotSettings from the layout Using acPlSet As PlotSettings = New PlotSettings(acLayout.ModelType) acPlSet.CopyFrom(acLayout) ' Update the PlotSettings object Dim acPlSetVdr As PlotSettingsValidator = _ PlotSettingsValidator.Current ' Set the plot type acPlSetVdr.SetPlotType(acPlSet, _ DatabaseServices.PlotType.Extents) ' Set the plot scale acPlSetVdr.SetUseStandardScale(acPlSet, True) acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit) ' Center the plot acPlSetVdr.SetPlotCentered(acPlSet, True) ' Set the plot device to use acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWF6 ePlot.pc3", _ "ANSI_A_(8.50_x_11.00_Inches)") ' 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 PlotInfoValidator = New PlotInfoValidator() acPlInfoVdr.MediaMatchingPolicy = MatchingPolicy.MatchEnabled acPlInfoVdr.Validate(acPlInfo) ' Check to see if a plot is already in progress If PlotFactory.ProcessPlotState = _ ProcessPlotState.NotPlotting Then Using acPlEng As PlotEngine = _ PlotFactory.CreatePublishEngine() ' Track the plot progress with a Progress dialog Using acPlProgDlg As PlotProgressDialog = _ New PlotProgressDialog(False, 1, True) Using (acPlProgDlg) ' Define the status messages to display ' when plotting starts acPlProgDlg.PlotMsgString( _ PlotMessageIndex.DialogTitle) = "Plot Progress" acPlProgDlg.PlotMsgString( _ PlotMessageIndex.CancelJobButtonMessage) = _ "Cancel Job" acPlProgDlg.PlotMsgString( _ PlotMessageIndex.CancelSheetButtonMessage) = _ "Cancel Sheet" acPlProgDlg.PlotMsgString( _ PlotMessageIndex.SheetSetProgressCaption) = _ "Sheet Set Progress" acPlProgDlg.PlotMsgString( _ PlotMessageIndex.SheetProgressCaption) = _ "Sheet Progress" ' Set the plot progress range acPlProgDlg.LowerPlotProgressRange = 0 acPlProgDlg.UpperPlotProgressRange = 100 acPlProgDlg.PlotProgressPos = 0 ' Display the Progress dialog acPlProgDlg.OnBeginPlot() acPlProgDlg.IsVisible = True ' Start to plot the layout acPlEng.BeginPlot(acPlProgDlg, Nothing) ' Define the plot output acPlEng.BeginDocument(acPlInfo, _ acDoc.Name, _ Nothing, _ 1, _ True, _ "c:\myplot") ' Display information about the current plot acPlProgDlg.PlotMsgString( _ PlotMessageIndex.Status) = _ "Plotting: " & acDoc.Name & _ " - " & acLayout.LayoutName ' Set the sheet progress range acPlProgDlg.OnBeginSheet() acPlProgDlg.LowerSheetProgressRange = 0 acPlProgDlg.UpperSheetProgressRange = 100 acPlProgDlg.SheetProgressPos = 0 ' Plot the first sheet/layout Using acPlPageInfo As PlotPageInfo = _ New 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
using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.PlottingServices; // Plots the current layout to a DWF file [CommandMethod("PlotLayout")] public static void PlotLayout() { // Get the current document and database, and start a transaction Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { // Reference the Layout Manager LayoutManager acLayoutMgr = LayoutManager.Current; // Get the current layout and output its name in the Command Line window Layout acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), OpenMode.ForRead) as Layout; // Get the PlotInfo from the layout using (PlotInfo acPlInfo = new PlotInfo()) { acPlInfo.Layout = acLayout.ObjectId; // Get a copy of the PlotSettings from the layout using (PlotSettings acPlSet = new PlotSettings(acLayout.ModelType)) { acPlSet.CopyFrom(acLayout); // Update the PlotSettings object PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current; // Set the plot type acPlSetVdr.SetPlotType(acPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents); // Set the plot scale acPlSetVdr.SetUseStandardScale(acPlSet, true); acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit); // Center the plot acPlSetVdr.SetPlotCentered(acPlSet, true); // Set the plot device to use acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWF6 ePlot.pc3", "ANSI_A_(8.50_x_11.00_Inches)"); // 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 (PlotInfoValidator acPlInfoVdr = new PlotInfoValidator()) { acPlInfoVdr.MediaMatchingPolicy = MatchingPolicy.MatchEnabled; acPlInfoVdr.Validate(acPlInfo); // Check to see if a plot is already in progress if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting) { using (PlotEngine acPlEng = PlotFactory.CreatePublishEngine()) { // Track the plot progress with a Progress dialog using (PlotProgressDialog acPlProgDlg = new PlotProgressDialog(false, 1, true)) { using ((acPlProgDlg)) { // Define the status messages to display // when plotting starts acPlProgDlg.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Plot Progress"); acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Cancel Job"); acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Cancel Sheet"); acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Sheet Set Progress"); acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Sheet Progress"); // Set the plot progress range acPlProgDlg.LowerPlotProgressRange = 0; acPlProgDlg.UpperPlotProgressRange = 100; acPlProgDlg.PlotProgressPos = 0; // Display the Progress dialog acPlProgDlg.OnBeginPlot(); acPlProgDlg.IsVisible = true; // Start to plot the layout acPlEng.BeginPlot(acPlProgDlg, null); // Define the plot output acPlEng.BeginDocument(acPlInfo, acDoc.Name, null, 1, true, "c:\\myplot"); // Display information about the current plot acPlProgDlg.set_PlotMsgString(PlotMessageIndex.Status, "Plotting: " + acDoc.Name + " - " + acLayout.LayoutName); // Set the sheet progress range acPlProgDlg.OnBeginSheet(); acPlProgDlg.LowerSheetProgressRange = 0; acPlProgDlg.UpperSheetProgressRange = 100; acPlProgDlg.SheetProgressPos = 0; // Plot the first sheet/layout using (PlotPageInfo acPlPageInfo = new PlotPageInfo()) { acPlEng.BeginPage(acPlPageInfo, acPlInfo, true, null); } acPlEng.BeginGenerateGraphics(null); acPlEng.EndGenerateGraphics(null); // Finish plotting the sheet/layout acPlEng.EndPage(null); acPlProgDlg.SheetProgressPos = 100; acPlProgDlg.OnEndSheet(); // Finish plotting the document acPlEng.EndDocument(null); // Finish the plot acPlProgDlg.PlotProgressPos = 100; acPlProgDlg.OnEndPlot(); acPlEng.EndPlot(null); } } } } } } } } }
Sub PlotLayout() ' Set the extents and scale of the plot area ThisDrawing.ActiveLayout.PlotType = acExtents ThisDrawing.ActiveLayout.StandardScale = acScaleToFit ' Center the plot ThisDrawing.ActiveLayout.CenterPlot = True ' Set the plot device to use ThisDrawing.ActiveLayout.ConfigName = "DWF6 ePlot.pc3" ' Set the plot output size ThisDrawing.ActiveLayout.CanonicalMediaName = "ANSI_A_(8.50_x_11.00_Inches)" ' Set the number of copies to one ThisDrawing.Plot.NumberOfCopies = 1 ' Initiate the plot ThisDrawing.Plot.PlotToFile "c:\myplot" End Sub
デバイス名は、ConfigName プロパティを使用して指定することができます。このデバイスは、PlotToDevice メソッドで PC3 ファイルを指定することで上書きすることができます。