Valued Contributor
91 Posts
3 Kudos
Registered: ‎02-18-2010
Post 1 of 4

plot pdf using example code yields no pdf file

286 Views, 3 Replies
05-17-2013 05:52 AM

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)

            '' 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

            '' 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.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.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)


                        '' Finish plotting the sheet/layout
                        acPlProgDlg.SheetProgressPos = 100

                        '' Finish plotting the document

                        '' Finish the plot
                        acPlProgDlg.PlotProgressPos = 100
                    End Using

                End Using

            End If


        End Using
    End Sub


*Expert Elite*
1,088 Posts
217 Kudos
Registered: ‎04-27-2009
Post 2 of 4

Re: plot pdf using example code yields no pdf file

05-17-2013 06:41 AM in reply to: kcimos

Does the code run through without exception raised (it seems, because you did not mention)? If the code did run through without error, could it be that AutoCAD did output something but you did not notice:


The output is a DWF (because you used "DWF6 ePlot.pc3", not PDF. If your true intention is to plot to PDF, you should use "DWG to PDF.pc3 (or other available PDF plotting device available to the computer). So, if you tried to find *.PDF file in the output folder, you did not see PDF file, thus you thought nothing was plotted. Well, I do not know what output file name you passed in is. Assume it is correct (with *.pdf extention), try again with "Dwg To Pdf.pc3".




1,467 Posts
277 Kudos
Registered: ‎04-09-2008
Post 3 of 4

Re: plot pdf using example code yields no pdf file

05-17-2013 09:27 AM in reply to: kcimos

BACKGROUNDPLOT – system variable

Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
91 Posts
3 Kudos
Registered: ‎02-18-2010
Post 4 of 4

Re: plot pdf using example code yields no pdf file

05-21-2013 10:17 AM in reply to: kcimos

setting background plotting to be off probably helped.

I also need to add a "\" between my file path & file name.


now when i run the code with this:


acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWF6 ePlot.pc3", "ANSI_A_(8.50_x_11.00_Inches)")



it works,


but if I change that line to this:

acPlSetVdr.SetPlotConfigurationName(acPlSet, "CutePDF Writer.pc3", "Letter")

 it almost works; I get a PLT file instead of a pdf, & yes I do have a pc3 named "CutePDF Writer"

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!