Author Topic: Cancel current publish job after event  (Read 3515 times)

0 Members and 1 Guest are viewing this topic.

xenspidey

  • Mosquito
  • Posts: 15
Cancel current publish job after event
« on: April 07, 2015, 12:29:24 PM »
I am working on something that detects the publish event using "AboutToBeginPublishingEventHandler" I then present the user with a dialog that gives them a yes, no, or cancel option. Ideally, the yes selection would continue the publish command, a no selection would cancel the current publish job, change a system variable then restart the publish job, and a cancel selection would cancel the current publish job. I have everything working well except for the ability to cancel a publish job programmatically once it's been started. I also haven't gotten the resend a publish job working but I'm not as worried about that as the user could just resend, it would be nice but not necessary.

Any help would be greatly appreciated.

Thanks,

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Cancel current publish job after event
« Reply #1 on: April 07, 2015, 01:00:54 PM »
Most commands cannot be cancelled from within the preview event. To do what you're describing is usually better implemented by writing a replacement command that initiates the plotting.  Then use aliases in your PGP to replace the stock plot command with your custom command.
Revit 2019, AMEP 2019 64bit Win 10

xenspidey

  • Mosquito
  • Posts: 15
Re: Cancel current publish job after event
« Reply #2 on: April 07, 2015, 01:42:11 PM »
So what you are saying is it might not be possible to cancel a publish job without the user actually hitting "Cancel Job" from the publish progress dialog? I suppose i could write my own publish command but we do all of our printing through the sheet set manager using page setup overrides.

xenspidey

  • Mosquito
  • Posts: 15
Re: Cancel current publish job after event
« Reply #3 on: April 21, 2015, 09:19:46 AM »
Most commands cannot be cancelled from within the preview event. To do what you're describing is usually better implemented by writing a replacement command that initiates the plotting.  Then use aliases in your PGP to replace the stock plot command with your custom command.

I am still trying to find a solution to my problem and have been thinking about your suggestion of using a custom "publish" command. Do you know if it's possible to add a custom entry into the sheet set context menu? that would be the easiest solution to have a custom publish command while maintaining a similar method of publishing that everyone is used to.

I still find it hard to believe that I cannot find a way to cancel a plot job programmatically once an the event "AboutToBeginPublishingEvent" has been triggeres. The cancel all button on the progress dialog triggers a command...

BlackBox

  • King Gator
  • Posts: 3770
Re: Cancel current publish job after event
« Reply #4 on: April 21, 2015, 12:44:44 PM »
I know of no way to add a MenuItem to the native SSM context menu, YMMV... That said, SSM hasn't really been updated since 2006 or 2009, AFAIK.

Autodesk is a bit inconsistent with respective MenuItem Click Events; some lock the Document and invoke CommandMethods (which can subsequently caught, and Veto()-ed, etc.), and others, particularly in Civil 3D 'silently' invoke the source Method in the code-behind (without locking Document, etc.), which disallows us to correct native issues if we wanted to. Grrr

Not sure that it will help with your current task, but if you're going to continue to develop around SSM, this reference may be of use:

http://adndevblog.typepad.com/autocad/2013/09/using-sheetset-manager-api-in-vbnet.html



Cheers
"How we think determines what we do, and what we do determines what we get."

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Cancel current publish job after event
« Reply #5 on: April 22, 2015, 07:35:50 AM »
Most commands cannot be cancelled from within the preview event. To do what you're describing is usually better implemented by writing a replacement command that initiates the plotting.  Then use aliases in your PGP to replace the stock plot command with your custom command.

You might find it easier to clone the SSM Dialog in your custom command.

I am still trying to find a solution to my problem and have been thinking about your suggestion of using a custom "publish" command. Do you know if it's possible to add a custom entry into the sheet set context menu? that would be the easiest solution to have a custom publish command while maintaining a similar method of publishing that everyone is used to.

I still find it hard to believe that I cannot find a way to cancel a plot job programmatically once an the event "AboutToBeginPublishingEvent" has been triggeres. The cancel all button on the progress dialog triggers a command...

You might find it easier to clone the SSM Dialog in your command.
Revit 2019, AMEP 2019 64bit Win 10

xenspidey

  • Mosquito
  • Posts: 15
Re: Cancel current publish job after event
« Reply #6 on: April 23, 2015, 09:33:06 AM »
I have been able to cancel the current publishing job programmatically Yeah!
Code: [Select]
void callback_BeginPlot(object sender, BeginPlotEventArgs e)
        {     
               PlotProgress m_PlotProgress = e.PlotProgress;
               m_PlotProgress.PlotCancelStatus = PlotCancelStatus.CanceledByCancelAllButton;
        }     
 
Now what I have done is before canceling i have stored the DsdData and PlotConfig data and once i have changed a system variable (PUBLISHCOLLATE) I'm trying to republish the same set that the user originally was publishing using
Code: [Select]
Autodesk.AutoCAD.ApplicationServices.Application.Publisher.PublishExecute(m_dsdData, m_plotConfig);
However, I can't get it to republish or even spit out an error... So I'm definitely getting closer.

BlackBox

  • King Gator
  • Posts: 3770
Re: Cancel current publish job after event
« Reply #7 on: April 23, 2015, 01:53:24 PM »
I'm sure that I'm failing to understand, or recall something important here... *but*... *if* that's all you're doing (setting a sysvar), then why not just set PUBLISHCOLLATE as part of your production profile, or at session start via Acad.lsp, Initialize(), etc.?  :?
"How we think determines what we do, and what we do determines what we get."

xenspidey

  • Mosquito
  • Posts: 15
Re: Cancel current publish job after event
« Reply #8 on: April 23, 2015, 02:06:59 PM »
I'm sure that I'm failing to understand, or recall something important here... *but*... *if* that's all you're doing (setting a sysvar), then why not just set PUBLISHCOLLATE as part of your production profile, or at session start via Acad.lsp, Initialize(), etc.?  :?

The people who do the majority of printing need the PUBLISHCOLLATE set differently depending on if they are printing to a plotter or if the are printing to PDF's. I have all of the options set in page setup overrides under the publish SSM menu. If it's set to individual sheets when they print to our plotter then it prints them first to last instead of last to first like when sent as one set. Having to re-collate 100 sheets in the 11th hour isn't exactly enjoyable so I am writing a routine that will intercept the AboutToBeginPublishing event, check the PUBLISHCOLLATE variable and inform the user. The user then can select "yes" to continue with the publish, "no" to switch the variable and republish or "cancel" to just forget the whole thing. Unfortunately the PUBLISHCOLLATE cariable is checked by autocad prior to firing the AboutToBeginPublishing event so i have to actually cancel the plot before i can switch it and resend it.

I hope that makes a little more sense.