Author Topic: Open drawing from listview  (Read 11570 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Open drawing from listview
« Reply #30 on: February 28, 2007, 07:30:35 PM »
Since I have two global arrays, should I clear them at the end of the code?  I mean I know they are only global when the program is called, but I was just thinking I should clear (make them null) at the end of the code.
I was thinking something like
Code: [Select]
Array.Clear(PlottingArray, 0, PlottingArray.Length);
Array.Clear(ScaleValueArray, 0, ScaleValueArray.Length);
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Open drawing from listview
« Reply #31 on: February 28, 2007, 07:37:47 PM »
You can never be too tidy in my opinion. That looks ok for clearing the arrays.

After a bit of fiddling, I managed to get it to open drawings, but the plot was failing...no biggy yet as it's early days.
It does indeed seem to open the drawings correctly...I'll keep playing.

Thanks Tim.
Me

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Open drawing from listview
« Reply #32 on: February 28, 2007, 07:43:32 PM »
You can never be too tidy in my opinion. That looks ok for clearing the arrays.

After a bit of fiddling, I managed to get it to open drawings, but the plot was failing...no biggy yet as it's early days.
It does indeed seem to open the drawings correctly...I'll keep playing.

Thanks Tim.
Thanks Glenn for helping me on this one.  I'm going home now, but look forward to seeing what you suggest tomorrow, as I don't have Acad installed at home right now, so I can't play there.
Tim

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

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Open drawing from listview
« Reply #33 on: February 28, 2007, 08:14:51 PM »
Just flying past ...

To me, there are several of learning, 2 of which I think of as "by example" and "by heuristic"
... this is a great eample of the latter.

The others , cause I know 'someone' will ask, are "by rote" , "in your sleep" . "by algorithm" and "for desperation" .. there are probably more ...  :lol:
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Open drawing from listview
« Reply #34 on: February 28, 2007, 09:15:51 PM »
.. "by heuristic"

.. by that I mean concentrating on ‘how’ to solve problems or where/how to look for answers rather than the “answer” itself.

If you read that after a couple of beers it sounds better :lol:
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Open drawing from listview
« Reply #35 on: March 01, 2007, 02:27:11 PM »
So I changed my error message to this.
Code: [Select]
catch (System.Exception ex) {
Autodesk.AutoCAD.Runtime.Exception AcadEr = ex as Autodesk.AutoCAD.Runtime.Exception;
if (AcadEr !=null) MessageBox.Show(AcadEr.ErrorStatus.ToString());
else MessageBox.Show(ex.ToString());
}
And found out the issue is that there is  a background plot inprogress, so I figure I either have to turn that off background plotting, or put in a loop to wait for it.  I think I will try and code it so that it will not plot in the background.  Will be back.
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Open drawing from listview
« Reply #36 on: March 01, 2007, 03:13:07 PM »
So changing the system variable 'backgroundplot' worked.  Here is the code I added to the start of the 'MyPlotPart' sub
Code: [Select]
object OldBkGdPlt = AcadApp.GetSystemVariable("BackGroundPlot");
AcadApp.SetSystemVariable("BackGroundPlot", 0);
Then at the very end of the same sub, I added
Code: [Select]
AcadApp.SetSystemVariable("BackGroundPlot", OldBkGdPlt);
It seems to have sent them, but they are stuck in my printer right now spooling.

This doesn't look good.  I may have to change this again...... be back after some more testing...
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Open drawing from listview
« Reply #37 on: March 01, 2007, 03:48:56 PM »
This does not work for me and my printer.  It will spool until 48 bytes, and the it will stop spooling, so I need to wait for the background plot to finish before going to the next drawing.

Off to see how to do that.
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Open drawing from listview
« Reply #38 on: March 01, 2007, 06:14:07 PM »
You must explicitly turn backgroundplot OFF...that's the very first thing I do.

Also, your catch clause, whilst technically correct if a not the best way. Look up exception handing in a C# book if you have one handy and tell me what you find. A hint - you can have more than one...
Me

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Open drawing from listview
« Reply #39 on: March 01, 2007, 06:35:35 PM »
You must explicitly turn backgroundplot OFF...that's the very first thing I do.
If I do, they don't get printed, as they just stay in the printer spooling for hours on a small drawing.  I will try again soon, just don't want to hold up the netword printer for myself.  :-)

Also, your catch clause, whilst technically correct if a not the best way. Look up exception handing in a C# book if you have one handy and tell me what you find. A hint - you can have more than one...
I don't have one at all.  I read all my stuff online.  I know you can have more that one, I just didn't see how to code for specific Acad ones.  I tried a couple of ways, and they just wouldn't compile.  I think I might know how to do it now, but am trying to find a way to sort of pause the plotting until the background plot is done.  Haven't gotten a good way yet.  I tried a cheap little 'while' loop that would do nothing until Acad said the plot was done.  Something like
Code: [Select]
while (PlotFactory.ProcessPlotState != 0) {}It worked, but it takes so long for it to plot even small drawings.  There has to be a better way, I just haven't found it yet.  Thanks again for your help on this Glenn.  I really appreciate it.
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Open drawing from listview
« Reply #40 on: March 01, 2007, 06:43:56 PM »
As far as I'm aware, you HAVE to turn backgrounplot off - all sorts of ussues arise if you do not.
Me

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Open drawing from listview
« Reply #41 on: March 01, 2007, 07:01:09 PM »
As far as I'm aware, you HAVE to turn backgrounplot off - all sorts of ussues arise if you do not.
Okay it seems to work when I turn backgroundplot off.  The first one is the only one that takes some time.  I guess I was in too much of a rush.

I still can't get the specific Acad errors to complie.  Do I have to get the base one, and then test each one?  It seems like that is the case in my searches.

Edit: This is how I did it.
Code: [Select]
catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message);
}
catch (System.Exception ex){
MessageBox.Show(ex.Message);
}
« Last Edit: March 01, 2007, 07:05:05 PM by T.Willey »
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Open drawing from listview
« Reply #42 on: March 01, 2007, 07:20:29 PM »
Good - that's better.

Now, in your adesk catch clause, you could put in a switch statement and switch on the ErroStatus for example...
Me

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Open drawing from listview
« Reply #43 on: March 01, 2007, 07:45:15 PM »
Good - that's better.

Now, in your adesk catch clause, you could put in a switch statement and switch on the ErroStatus for example...
Ah... I will have to read up on 'switch'... I think they are like 'cond' in lisp but not sure.  Now I have to make my dialog look purddy, as it seems to work correctly now with all your help.  Thanks again.  I will look into this other stuff tomorrow as time permits.
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Open drawing from listview
« Reply #44 on: March 01, 2007, 08:18:21 PM »
Yes, a switch is essentially like a lisp cond.

I strongly suggest you get some training in .NET or at the very least, get a few good books. For C# I would recommend 'Pro C# 2005 and the .NET 2.0 Platform', by Andrew Troelsen, published by Apress.

Cheers,
Glenn.
Me