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 :
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:
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
Solved! Go to Solution.
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
Using DSDDataFile AsNewDsdDataUsing PPD AsPlotProgressDialog = NewPlotProgressDialog(False, my_PresentFormats.BaseCollection.Count, True)
PlotMessageIndex.DialogTitle) = "PDF Creation Progress"
PlotMessageIndex.CancelJobButtonMessage) = "Cancel PDF Creation"
PlotMessageIndex.CancelSheetButtonMessage) = "Cancel Sheet PDF Creation"
PlotMessageIndex.SheetSetProgressCaption) = "Multi-sheet PDF Create job Progress"
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
Dim PDFPlotConfig AsPlotConfig = PlotConfigManager.SetCurrentConfig("BATC PDF.pc3")
Catch sys_ex As System.Exception
Sorry, this is easier to read.
Public Sub ExecutePublishProcess() Try Dim CurrAcadDoc As Document = Application.DocumentManager.MdiActiveDocument Autodesk.AutoCAD.ApplicationServices.Application.S
etSystemVariable("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.CancelJobButton Message) = "Cancel PDF Creation" PPD.PlotMsgString(PlotMessageIndex.CancelSheetButt onMessage) = "Cancel Sheet PDF Creation" PPD.PlotMsgString(PlotMessageIndex.SheetSetProgres sCaption) = "Multi-sheet PDF Create job Progress" PPD.PlotMsgString(PlotMessageIndex.SheetProgressCa ption) = "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.P ublisher DSDDataFile.ReadDsd(DSDFileName) Dim PDFPlotConfig As PlotConfig = PlotConfigManager.SetCurrentConfig("BATC PDF.pc3") oPublisher.PublishExecute(DSDDataFile, PDFPlotConfig) End Using End Using Autodesk.AutoCAD.ApplicationServices.Application.S etSystemVariable("BACKGROUNDPLOT", 1) Catch sys_ex As System.Exception MsgBox(sys_ex.Message) End Try End Sub
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".
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.
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
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.