Author Topic: PlotPreview lockup  (Read 3229 times)

0 Members and 1 Guest are viewing this topic.

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
PlotPreview lockup
« on: January 10, 2007, 06:17:31 PM »
Here is the next issue I'm dealing with on my plotting program.
I have a "Preview" button on my modal form.
Here is part of the code that executes when the button is clicked:
Code: [Select]
            PlotProgressDialog prog = new PlotProgressDialog(true, 1, true);
            this.Hide();
           
            PlotEngine pEng = PlotFactory.CreatePreviewEngine(0);
           
            prog.OnBeginPlot();
            prog.IsVisible = true;
            pEng.BeginPlot(prog, null);
            pEng.BeginDocument(pInf, currDwgName, null, 1, false, string.Empty);
            pEng.BeginPage(pPInfo, pInf, true, null);
            pEng.BeginGenerateGraphics(null);

            pEng.EndGenerateGraphics(null);
            pEng.EndPage(null);
            pEng.EndDocument(null);
            pEng.EndPlot(null);
            prog.IsVisible = false;
            prog.OnEndPlot();
            prog.Destroy();
            pEng.Destroy();
I've left out some of the code to help focus on what I think is the problem.

Everything works fine up until the line: "pEng.BeginGenerateGraphics(null);"
The program never comes out of that method. The preview shows in the AutoCAD window and everything looks as it should but that window is frozen. AutoCAD never gets control.

Any ideas?
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: PlotPreview lockup
« Reply #1 on: January 10, 2007, 06:28:24 PM »
While this is obviously not the cause of your immediate issue ....
.. should you destroy the Engine before you destroy the Dialog ?
« Last Edit: January 10, 2007, 09:44:08 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: PlotPreview lockup
« Reply #2 on: January 11, 2007, 06:15:06 AM »
Not having Acad or anything else handy, I'm flying blind on this one, however, having said that, what is the function signature for BeginGenerateGraphics? I seem to vaguely remember in my code that I had an argument in there.......maybe the plot progress dialog..........?????

Cheers,
Glenn.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: PlotPreview lockup
« Reply #3 on: January 11, 2007, 08:02:44 AM »
I think the  pEng.BeginGenerateGraphics(null); is correct ; the parameter is ( Object parameters) <Reserved for future use>

Mark, are you using a validator ? ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: PlotPreview lockup
« Reply #4 on: January 11, 2007, 08:05:47 AM »
I 'spose you've had a look at this ..
« Last Edit: January 11, 2007, 08:07:43 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: PlotPreview lockup
« Reply #5 on: January 11, 2007, 02:11:52 PM »
Kerry, I have not had a look at that . . . or the example it promises.
I destroyed the prog dialog last because I created it first. But I've tried it both ways. I've tried it 50 ways with more or less the same result.
For anyone trying this, when AutoCAD freezes do -NOT- kill the process using the task manager. Just stop the program from the VS IDE. Any open drawings will not get saved properly and AutoCAD will complain. But that is better than what happens if you kill the process. I'm still not emotionally ready to talk to anyone about it.

Maybe it has something to do with context. To Preview we have to turn focus and control over to AutoCAD until the preview is dismissed. Then we need to know how it was dismissed. (plot, cancel etc.)
In my case I don't want the user to be able to choose plot. I want focus to go back to my dialog.

If this was an .exe I would look at something like the vb "appactivate" function. But this is a .NET dll running in AutoCAD space. It should (and probably is) actually be easier to hand focus back and forth.
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions