.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

plot pdf using example code yields no pdf file

3 REPLIES 3
Reply
Message 1 of 4
kcimos
652 Views, 3 Replies

plot pdf using example code yields no pdf file

so I implemented the code from the autodesk developers guide for plotting

(http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html?url=WS1a919382...)

 

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

 

3 REPLIES 3
Message 2 of 4
norman.yuan
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".

 

 

 

Message 3 of 4
Alexander.Rivilis
in reply to: kcimos

BACKGROUNDPLOT – system variable

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 4 of 4
kcimos
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"

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost