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

Exception obtained - PublishExecute - 55 Sheet PDF (AutoCAD Electrical 2013)

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
csludtke
1003 Views, 6 Replies

Exception obtained - PublishExecute - 55 Sheet PDF (AutoCAD Electrical 2013)

Background -

 

I created a vb add-in that creates standard sheet setups using a .pc3 file called BATC PDF.pc3 .   (This .pc3 file was created using the DWG To PDF.pc3 plot config - Margins were set to 0)

 

The add-in accomplisheds  the following :

 

  1. Queries a database for all of the blocks and associated attributes that our company has used over the past 20 years for Drawing Formats
  2. Determines if any of the blocks (formats) exists in the drawing.
  3. Determines if any of the plocks overlap and warn user
  4. Determines the appropriate sheet numbers for plotting
  5. Creates a standardized (by name) plot
  6. Creates a Drawing Sheet Description file (DSD file) that contains all of the sheets in the appropriate order (all sheet desctiptions usually exist in the same drawing file and the same drawing layout.
  7. Leverages the Publish Engine (Autodesk.AutoCAD.Publishing.Publisher  PublishExecute method to publish contents leveraging informaiton in the DSD

I am testing the application functionality with a wide variety of our AutoCAD drawing library.  I have ran into some anomalies with some of our drawings that have a large number of sheets:

 

  • Exceptions obtained Random) - via .dll (Random FATAL ERROR: Unhandled Access Violation Reading Oxffff Exception at ........
  • No exception - using CommandLine "Publish" using DSD created by routing
  • No exception - via Visual Studio debugging (speed via debug infrastructure is 1/10th publish speed)

 

Routine works well with drawings that have smaller sheet counts(10 or so) sheets.

 

I am configuring the Visual Studio solution so that it can be executed without the supporting database

6 REPLIES 6
Message 2 of 7
csludtke
in reply to: csludtke

Here is the section of code that is failing (during Publish Execute).

 

Note that the exception is not captured by the try-catch block

 

TryDim CurrAcadDoc AsDocument = Application.DocumentManager.MdiActiveDocument

Autodesk.AutoCAD.ApplicationServices.

Application.SetSystemVariable("BACKGROUNDPLOT", 0)

 

Using DSDDataFile AsNewDsdDataUsing PPD AsPlotProgressDialog = NewPlotProgressDialog(False, my_PresentFormats.BaseCollection.Count, True)

PPD.PlotMsgString(

PlotMessageIndex.DialogTitle) = "PDF Creation Progress"

PPD.PlotMsgString(

PlotMessageIndex.CancelJobButtonMessage) = "Cancel PDF Creation"

PPD.PlotMsgString(

PlotMessageIndex.CancelSheetButtonMessage) = "Cancel Sheet PDF Creation"

PPD.PlotMsgString(

PlotMessageIndex.SheetSetProgressCaption) = "Multi-sheet PDF Create job Progress"

PPD.PlotMsgString(

PlotMessageIndex.SheetProgressCaption) = "PDF Sheet Creation Progress"

PPD.UpperPlotProgressRange = 100

PPD.LowerPlotProgressRange = 0

PPD.UpperSheetProgressRange = 100

PPD.LowerSheetProgressRange = 0

Dim oPublisher As Autodesk.AutoCAD.Publishing.Publisher = Autodesk.AutoCAD.ApplicationServices.Application.Publisher

DSDDataFile.ReadDsd(DSDFileName)

Dim PDFPlotConfig AsPlotConfig = PlotConfigManager.SetCurrentConfig("BATC PDF.pc3")

oPublisher.PublishExecute(DSDDataFile, PDFPlotConfig)

EndUsingEndUsing

Autodesk.AutoCAD.ApplicationServices.

Application.SetSystemVariable("BACKGROUNDPLOT", 1)

 

Catch sys_ex As System.Exception

MsgBox(sys_ex.Message)

EndTry

Message 3 of 7
csludtke
in reply to: csludtke

 

Sorry, this is easier to read.

 

    Public Sub ExecutePublishProcess()
        Try
            Dim CurrAcadDoc As Document = Application.DocumentManager.MdiActiveDocument
            Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", 0)
            Using DSDDataFile As New DsdData
                Using PPD As PlotProgressDialog = New PlotProgressDialog(False, my_PresentFormats.BaseCollection.Count, True)
                    PPD.PlotMsgString(PlotMessageIndex.DialogTitle) = "PDF Creation Progress"
                    PPD.PlotMsgString(PlotMessageIndex.CancelJobButtonMessage) = "Cancel PDF Creation"
                    PPD.PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage) = "Cancel Sheet PDF Creation"
                    PPD.PlotMsgString(PlotMessageIndex.SheetSetProgressCaption) = "Multi-sheet PDF Create job Progress"
                    PPD.PlotMsgString(PlotMessageIndex.SheetProgressCaption) = "PDF Sheet Creation Progress"
                    PPD.UpperPlotProgressRange = 100
                    PPD.LowerPlotProgressRange = 0
                    PPD.UpperSheetProgressRange = 100
                    PPD.LowerSheetProgressRange = 0
                    Dim oPublisher As Autodesk.AutoCAD.Publishing.Publisher = Autodesk.AutoCAD.ApplicationServices.Application.Publisher
                    DSDDataFile.ReadDsd(DSDFileName)
                    Dim PDFPlotConfig As PlotConfig = PlotConfigManager.SetCurrentConfig("BATC PDF.pc3")
                    oPublisher.PublishExecute(DSDDataFile, PDFPlotConfig)
                End Using
            End Using
            Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", 1)
        Catch sys_ex As System.Exception
            MsgBox(sys_ex.Message)
        End Try
    End Sub
Message 4 of 7
norman.yuan
in reply to: csludtke

You did not mention if your code does something to prepare the layout (sheet) prior to publish. But here is one thing I learned from my PDF proltting development: if you have a layout created and have not saved the drawing prior to publishing, the publishing process will failed (Acad crashed). That is, if there is new layout, the drawing must be saved.

 

In my case, since I need to use code to create layout for present the printable content in desired scale, size... I have to give up on publishing, and do the plotting PDF one page at a time and then use PDF tool to stitch them into multiple page PDF file (which turned out  to be quite easy and more flexibale then using Acad's "DWG to PDF.pc3".

Message 5 of 7
csludtke
in reply to: norman.yuan

I have tried saving and not saving.

 

The Page Setups are in the drawing and have been saved.

 

The Application sest the current plot config (which was active during the last save) and starts the PublishExecute.

 

It would be too bad if I had to resort to a piecemeal approach.  I would then be subject to all of the other problems related to merging a bunch of pdf files.

 

Message 6 of 7
csludtke
in reply to: csludtke

Well, I sort of gave up.

 

Norman is right.  It is apparent that as of the 2013 release, the API publish functionality is far from robust using the .net API interface.  If you want to save time and end up with something robust, use single sheet plot output and an external pdf merge utility.

 

I re-wrote my application to create individual sheets and utilized iText.Sharp to merge them together.

 

My final solution creates an infrastructure so the user can utilize the AutoCAD publish engine to create merged pdf output.  I am running into issues with that functionality (I programically create standard plot setups and matching dsd files and allow the user to use the publish engine via the command line interface.)

 

I am running into issues right and left.

 

I would encourage Autodesk to consider the following:

 

When creating electronic output, some customers are concerned about scaling (we want 1:1 output).  We want this so that versioning, compare and  and markup functionality (leveraging different versions of .pdf files) embeded in our PLM system works correctly.  This also enables reasonably accurate "measure" functionality within our PLM system.

 

It seems as if all electronic format engines have "margins" built in and after several layers you end up with scaled output.   I think the root of the problems that I am experiencing are related to specifying 0 margins in output.

 

Like many companies, we are also interested in bolstering our PLM environment with automated links that are built on a reliable content publishing foundation.  I would encourage Autodesk to address issues with their publishing infrastructure

 

This is the end of my vent.  Thanks

Message 7 of 7
mcicognani
in reply to: csludtke

I solved the same problem using a 'using' around the PlotConfig declaration:

 

        using (PlotConfig pc = PlotConfigManager.SetCurrentConfig("DWF6 ePlot.pc3"))

        {

            publisher.PublishExecute(dsdData, pc);

        }

 

This is coherent with the original sample code from Viru:

 

http://adndevblog.typepad.com/autocad/2012/04/publishing-all-layouts-of-the-drawing-file-to-a-dwf-fi...

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