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

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: Open drawing from listview
« Reply #15 on: February 28, 2007, 06:08:28 PM »
So how did you get it to open the drawings?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing from listview
« Reply #16 on: February 28, 2007, 06:15:11 PM »
So how did you get it to open the drawings?
I moved the open part outside the dialog call, like you said.  I got all the information I needed when closing the dialog, stored it in a global array, and use it outside of the dialog.  Then I used the 'open' method on the 'DocumentManager' (document collection) with the name of the file, and the bool value set to true, so it opens it as read only.

After a test, it doesn't work correctly if I cancel the dialog, so I'm going to have to change something, but that is not my main concern right now.  Right now it is the plotting that I can't seem to figure anything out on.  I'm reading the ARX help files, but they are not helping.  :ugly:

I seem to be not using my 'PlotEngine' correctly.

My search continues.......
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: 5251
Re: Open drawing from listview
« Reply #17 on: February 28, 2007, 06:21:29 PM »
After a test, it doesn't work correctly if I cancel the dialog, so I'm going to have to change something, but that is not my main concern right now. 
Fixed!  :-)
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Open drawing from listview
« Reply #18 on: February 28, 2007, 06:23:52 PM »
You're using the DocumentCollection's Open method...could you post the relevant snip of code please.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing from listview
« Reply #19 on: February 28, 2007, 06:34:30 PM »
You're using the DocumentCollection's Open method...could you post the relevant snip of code please.
Sure.  'PlottingArray' holds all the info for my plotting right now.
Code: [Select]
try {
tempDoc = DocCol.Open(PlottingArray[i,0], true);
using (DocumentLock DocLock = tempDoc.LockDocument()) {
if (string.Compare("Model", LayoutManager.Current.CurrentLayout) == 0) {
IsModel = true;
}
else IsModel = false;
if (PlottingArray[i,5] != null) LastPlot = true;
StdScaleType ScaleType = (StdScaleType) Enum.Parse(typeof(StdScaleType), PlottingArray[i,4], false);
MyPlottingPart(PlottingArray[i,1], PlottingArray[i,2], PlottingArray[i,3], ScaleType, IsModel, LastPlot);
}
}
catch (System.Exception ex){
MessageBox.Show(ex.ToString());
}
finally {
if (tempDoc != null) tempDoc.CloseAndDiscard();
}
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Open drawing from listview
« Reply #20 on: February 28, 2007, 06:37:54 PM »
What is 'DocCol' Tim? ie How is it declared/defined?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing from listview
« Reply #21 on: February 28, 2007, 06:42:56 PM »
What is 'DocCol' Tim? ie How is it declared/defined?
It is defined in the main program portion of the code that is called by the command name.  If you want I can post that whole portion, but didn't think it was needed....... well I will post it, as it is almost all posted above.
Code: [Select]
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
DocumentCollection DocCol = AcadApp.DocumentManager;
Code: [Select]
[CommandMethod("MyPlot", CommandFlags.Session)]
public void MethodCall () {
DialogResult dr;
using (MyPlot modalForm = new MyPlot()) {
dr = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(modalForm);
}
if (dr == DialogResult.OK) {
bool IsModel;
bool LastPlot = false;
Document tempDoc = null;
DocumentCollection DocCol = AcadApp.DocumentManager;
for (int i = 0; i < (PlottingArray.Length / 6); ++i) {
if (PlottingArray[i,1] != null) {
try {
tempDoc = DocCol.Open(PlottingArray[i,0], true);
using (DocumentLock DocLock = tempDoc.LockDocument()) {
if (string.Compare("Model", LayoutManager.Current.CurrentLayout) == 0) {
IsModel = true;
}
else IsModel = false;
if (PlottingArray[i,5] != null) LastPlot = true;
StdScaleType ScaleType = (StdScaleType) Enum.Parse(typeof(StdScaleType), PlottingArray[i,4], false);
MyPlottingPart(PlottingArray[i,1], PlottingArray[i,2], PlottingArray[i,3], ScaleType, IsModel, LastPlot);
}
}
catch (System.Exception ex){
MessageBox.Show(ex.ToString());
}
finally {
if (tempDoc != null) tempDoc.CloseAndDiscard();
}
}
}
}
}

Edit:  I had to lock the document while trying to plot it.  Before I locked it, it wouldn't work at all.
« Last Edit: February 28, 2007, 06:45:50 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

  • Guest
Re: Open drawing from listview
« Reply #22 on: February 28, 2007, 06:47:13 PM »
Tim,

Immediately after this line:
Code: [Select]
tempDoc = DocCol.Open(PlottingArray[i,0], true);

can you put in a MessageBox call and spit up the the name of MdiActiveDocument please?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing from listview
« Reply #23 on: February 28, 2007, 06:58:54 PM »
Tim,

Immediately after this line:
Code: [Select]
tempDoc = DocCol.Open(PlottingArray[i,0], true);

can you put in a MessageBox call and spit up the the name of MdiActiveDocument please?
It showed the name of the drawing I selected to plot, not the one it was called from.  It even plotted 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

  • Guest
Re: Open drawing from listview
« Reply #24 on: February 28, 2007, 07:04:44 PM »
What happened when you didn't lock it?

The reason I ask is this. I tried using your open approach first and it wouldn't work because the Open method is asynchronous - meaning the line of code executes, then it trucks on and doesn't wait for the drawing to finish opening. So this approach went out the door very quickly. I then settled on COM to open the drgs, but always wanted a better way. Then Alexander Rivilis posted a bit of code here on using P/INVOKE to get access to a synchronous open method.

I don't lock the drawing to plot though, whereas you do...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing from listview
« Reply #25 on: February 28, 2007, 07:08:06 PM »
What happened when you didn't lock it?

The reason I ask is this. I tried using your open approach first and it wouldn't work because the Open method is asynchronous - meaning the line of code executes, then it trucks on and doesn't wait for the drawing to finish opening. So this approach went out the door very quickly. I then settled on COM to open the drgs, but always wanted a better way. Then Alexander Rivilis posted a bit of code here on using P/INVOKE to get access to a synchronous open method.

I don't lock the drawing to plot though, whereas you do...
When I didn't lock the drawings, it would act like it was plotting, but then nothing would show up at the plotter.  I mean the window for the plot progress dialog would show, but it wouldn't ACTUALLY plot anything.  Once I added in the dock locking, it plots.  I don't understand it really, just reading in the ARX files made me think it would work.
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Open drawing from listview
« Reply #26 on: February 28, 2007, 07:08:52 PM »
Actually, after looking through my plot function, I do in fact lock the document to plot it...sorry.

I'm still intrigued as to why your open is working though........hmmmm......

Glenn R

  • Guest
Re: Open drawing from listview
« Reply #27 on: February 28, 2007, 07:09:46 PM »
Can you post the project, or a stripped down one if you like please Tim...I want to step it...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing from listview
« Reply #28 on: February 28, 2007, 07:14:27 PM »
Actually, after looking through my plot function, I do in fact lock the document to plot it...sorry.

I'm still intrigued as to why your open is working though........hmmmm......
Thats fine with me.  I'm still learning, so questioning why I do things is not bad for me.  It makes me think why I did it that way.  :-)

Can you post the project, or a stripped down one if you like please Tim...I want to step it...
I can post the whole thing.  I will just use a file instead of the code window though.  I'm on '06 and using .Net 1.1.  I had to change the ext to 'txt', so I think you can just change it back.
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Open drawing from listview
« Reply #29 on: February 28, 2007, 07:18:02 PM »
Thanks for that...looking at it now...hang a sec...