I'm working on a plugin to import document control information into Sheet Set Manager when plotting and publishing. So far, everything seems to work as expected, except for a few problems with the EndPublish event that I had to work around.
What I'm dealing with now, though, is some inconsistency in the way AutoCAD updates fields during the ExportPDF or ExportDWF commands. From Publish or SSM, everything works as expected - the new data is imported into the Sheet Set Manager, and the appropriate fields (SheetSet.CurrentSheet.RevisionNumber and SheetSet.CurrentSheet.Purpose) in the drawing update accordingly. When using the ExportPDF or ExportDWF commands, AutoCAD does not update the fields unless the drawing was saved immediately before being exported. The PlotDate fields are updating, but the SSM fields are not.
I tried saving the drawing, but Database.SaveAs crashes AutoCAD during the CommandWillStart, AboutToBeginPublishing and AboutToBeginBackgroundPublishing events - as I would expect it to.
I've tried enumerating all of the paperspace objects (using PublishSheetEventArgs) during the BeginSheet event, and although I can confirm that the fields are being Evaluated, the PDF is showing the unedited values. I've tried Regenerating the drawing during the AboutToBeginPublishing and BeginSheet events, to no avail. It seems as though AutoCAD is publishing from a background copy of the drawing that is not available through the Editor/Database objects.
Perhaps I should be using a different method (other than Field.Evaluate()) to update fields from the BeginSheet event handler? What is the correct way to enumerate all of the objects in paper space during the BeginSheet event? Is there another way to ensure AutoCAD updates these fields?