Message 1 of 4
plot pdf using example code yields no pdf file
Not applicable
05-17-2013
05:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
so I implemented the code from the autodesk developers guide for plotting
I made a few minor changes such as making it a sub instead of a command, and commented out a few of the plot settings
the routine seems to work except that I don't get a PDF
I added the actrans.commit() to see fi that might help = nope.
also note that ACF.acdoc & ACF.db in my code replace acdoc & acCurDb in the original code
'<CommandMethod("PlotCurrentLayout")> _
Public Sub PlotMe(suBpath As String, subFileName As String)
'' 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 = ACF.Db.TransactionManager.StartTransaction()
'' Reference the Layout Manager
Dim acLayoutMgr As LayoutManager
acLayoutMgr = LayoutManager.Current
'' Get the current layout and output its name in the Command Line window
Dim acLayout As Layout
acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), OpenMode.ForRead)
'' Get the PlotInfo from the layout
Dim acPlInfo As PlotInfo = New PlotInfo()
acPlInfo.Layout = acLayout.ObjectId
'' Get a copy of the PlotSettings from the layout
Dim 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, 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
Dim 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 = Autodesk.AutoCAD.PlottingServices.ProcessPlotState.NotPlotting Then
Using acPlEng As PlotEngine = PlotFactory.CreatePublishEngine()
'' Track the plot progress with a Progress dialog
Dim 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, ACF.acDoc.Name, Nothing, 1, True, suBpath & subFileName)
'' Display information about the current plot
acPlProgDlg.PlotMsgString(PlotMessageIndex.Status) = "Plotting: " & ACF.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
Dim acPlPageInfo As PlotPageInfo = New PlotPageInfo()
acPlEng.BeginPage(acPlPageInfo, acPlInfo, True, Nothing)
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 If
acTrans.Commit()
End Using
End Sub

