Author Topic: Issues with publish routine  (Read 3040 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Issues with publish routine
« on: January 04, 2018, 07:56:50 PM »
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?
Code - C#: [Select]
  1. pub.EndPublish += new EndPublishEventHandler(publishEndEvent);
  2. pub.AboutToEndPublishing += new AboutToEndPublishingEventHandler(publishEndEvent);
  3.  
  4. // call back function
  5. private void publishEndEvent(object sender, PublishEventArgs args){
  6.     MessageBox.Show("Trying to erase drawing: " + mSettingsDrawing + "\n\n\nSender:" + sender.ToString() + "\n\nArgs:" + args.ToString(), "End reactor.");
  7.     if (File.Exists(mSettingsDrawing)) File.Delete(mSettingsDrawing);
  8.     if (File.Exists(mDsdPath)) File.Delete(mDsdPath);
  9. }
  10.  


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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Refri

  • Mosquito
  • Posts: 11
Re: Issues with publish routine
« Reply #1 on: January 05, 2018, 05:32:04 AM »
Is there a better fix than this?
Look at the option of batch printing.
Prints from the Model and from many Layouts. There are many settings.
Here is the link: https://www.kdmsoft.net/revers.html

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Issues with publish routine
« Reply #2 on: January 05, 2018, 09:12:55 AM »
I have a routine that does batch plotting (https://www.theswamp.org/index.php?topic=17348.0).

I work mainly as a consultant right now when doing cad work, so I submit only in PDF files.  To make it easier, publishing will allow to print to a multi page pdf file.  That is the reason behind this program.

Thanks.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

n.yuan

  • Bull Frog
  • Posts: 348
Re: Issues with publish routine
« Reply #3 on: January 05, 2018, 10:00:53 AM »
Did not look at your source code, but assumed you use Publishing API (as opposed to PlotEngine API, which which, you could change "plot to extents" to "plot to layout, if the layout is empty). It looks you have code to check if an layout is empty or not (thus draw a temporary line on the layout before publishing). I am not sure if it is good way to do things or not, but if it works for you, good enough.

My point is, now that the code knows there is temporary line drawn, then you can simply not allow background plotting in this case.

Refri

  • Mosquito
  • Posts: 11
Re: Issues with publish routine
« Reply #4 on: January 05, 2018, 12:30:18 PM »
We do not see all the code, so I can not exactly answer.
But why do you perform so many actions before printing?
Easier to find and immediately print.
Attach a sample file with your title blocks.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Issues with publish routine
« Reply #5 on: January 05, 2018, 12:53:18 PM »
n.yuan:  For myself I would not use background plotting, as it takes much longer to plot, but I want to program something that someone can build off of if they want, and have it work for them also.  That is why I was hoping to find a solution to deleting the temporary files after they are used.  I am using the publishing class for the program, so your assumption is correct.

Refri:  The source code is attached in the first post in the zip file.  I preform those actions to allow the program to publish they way I want the publish command to work.  The companies I work for do not all use pagesetups, so I cannot import them.  To make this command work the way I want it to I need to set everything up within before plotting/publishing.  Sorry I cannot attach a sample title block, as I do not have permission to do so.

Thanks.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

BIGAL

  • Swamp Rat
  • Posts: 1411
  • 40 + years of using Autocad
Re: Issues with publish routine
« Reply #6 on: January 05, 2018, 10:07:18 PM »
I went down a different path as we have basicly 3 printers A3 b-w, colour A3 and A0 plotter we just pick which one we want to send to. The smart thing is that a dialouge pops up asks for range as we 99% only plot layouts. It auto defaults to 1st & last for a full set so press OK.

We went away from publish just had to many failures. Pick 1 menu option works every time. It could be converted to a batched method. dwg1 1-4,dwg2 12-14 18-20 etc

Re plot to pdf we use Ghostscript which has a pdf combine option so the auto plot routine plots all single pdf's as well as a combined to a predefined project directory all within lisp.

Marko rebar over at Cadtutor has done a pretty extensive plot just about anything program as well.

Ghostscript (http://www.ghostscript.com/) can be used to combine PDFs.



« Last Edit: January 05, 2018, 10:10:54 PM by BIGAL »
A man who never made a mistake never made anything

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Issues with publish routine
« Reply #7 on: January 06, 2018, 12:44:22 AM »
BIGAL:  That is how I used to do it.  Then I got a big project where there was over 200 drawings in a single set.  When I went to use the batch script (https://www.theswamp.org/index.php?topic=24337.0) written mostly by John, it would error.  That is the motivation behind the creation of the publish routine.  I tested it was a partial set of 125 drawings, and had no issues.  The only bad thing I noticed was that the partial published set of drawings was larger than the one plotted then combine with ghostscript.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Refri

  • Mosquito
  • Posts: 11
Re: Issues with publish routine
« Reply #8 on: January 06, 2018, 04:56:51 AM »
My personal opinion is to try everything that is offered. And choose the best, with the maximum possible. You have settled on one, in my opinion - there is better than you use. Not everyone knows the language C.