.NET

Reply
Contributor
csludtke
Posts: 24
Registered: ‎03-17-2003
Message 1 of 6 (307 Views)
Accepted Solution

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

307 Views, 5 Replies
09-30-2013 10:55 AM

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

Contributor
csludtke
Posts: 24
Registered: ‎03-17-2003
Message 2 of 6 (302 Views)

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

09-30-2013 11:00 AM 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

Contributor
csludtke
Posts: 24
Registered: ‎03-17-2003
Message 3 of 6 (299 Views)

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

09-30-2013 11:06 AM 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
*Expert Elite*
norman.yuan
Posts: 962
Registered: ‎04-27-2009
Message 4 of 6 (286 Views)

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

09-30-2013 12:17 PM 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".

Contributor
csludtke
Posts: 24
Registered: ‎03-17-2003
Message 5 of 6 (283 Views)

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

09-30-2013 12:26 PM 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.

 

Contributor
csludtke
Posts: 24
Registered: ‎03-17-2003
Message 6 of 6 (221 Views)

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

10-03-2013 09:20 AM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community