I have been working on a quick publish routine, where one can select certain options they want to (see image) and then select the drawings to publish. It will publish either in the foreground or background, depending on the variable BackGroundPlot.
The code works by creating a blank drawing and adding a new plot setting to said drawing. It then uses these items as parameters to publish. This seems to work except that the code plots to extents, and for this to work there needs to be entities in the drawing where the program is called. And if you want to plot paper space (Layout1 in my case) then you have to have once switched to paperspace before calling the program.
To fix this issue, I draw lines in each layout that does not seem to have any entity within it. I then erase the lines after the publish has been issued. Is there a better fix than this?
The other issue, when publishing in the back ground, I cannot erase my temporary files as the program ends before the publishing ends. I have tried to tap into events that should fire when the publish command has ended or is about to end, but they do not seem to fire when I run the code. Is there another way to handle this?
pub
.EndPublish += new EndPublishEventHandler
(publishEndEvent
);pub
.AboutToEndPublishing += new AboutToEndPublishingEventHandler
(publishEndEvent
);
// call back function
private void publishEndEvent(object sender, PublishEventArgs args){
MessageBox.Show("Trying to erase drawing: " + mSettingsDrawing + "\n\n\nSender:" + sender.ToString() + "\n\nArgs:" + args.ToString(), "End reactor.");
if (File.Exists(mSettingsDrawing)) File.Delete(mSettingsDrawing);
if (File.Exists(mDsdPath)) File.Delete(mDsdPath);
}
Attached is a pic of the dialog box and a zip file that contains the source code and a .dll compiled to 2012. The command is called by 'QuickPublish' after the .dll has been loaded.
Thanks in advance.