Reply

Closing Documents Woes

[ Edited ]

 

Hi All

I'm having problems with the following code

objseSheetDoc.Close(SaveChanges:=False) or

objseSheetDoc.Close() or

objse.activedocument.close()

It seems to make Edge Crash most of the time,but if i don't use it it seems to work fine except i have lots of documents left open so i have pined it down to this.

Since I'm new to .net is there a Doevents type thing to let Edge process all of its pending commands before i send it another one? as it hangs for a short time before if quits on or around this command

Thanks

Snow

 

Posted by: Snow Mackenzie
Post date: 11/28/2008 2:20:23 PM

6 REPLIES

RE: Closing Documents Woes

[ Edited ]

Hi Snow,

 

problems with SE ST or other versions?

 

except i have lots of documents left open

 

I think it is related to this. I've encountered similar errors if leaving the documents open. Just try to open the document/sheet, process operation on the doc, and then close it. I'm using the following code quite often without any problems (well except of ST):

 

foreach( Sheet sheet in doc.sheets)

{

sheet.Activate();

 

//Process operations

...

 

sheet.Close();

 

}

 

Sibi

 

Posted by: Seb Sosna
Post date: 11/29/2008 10:51:47 PM

RE: Closing Documents Woes

[ Edited ]

Hi Sibi

Thanks for your reply. What i'm doing is making a save as flat macro in V18.

What it does id it goes threw a list of sheetmetal docs an generated a flat DXF drawing off them.

What edge is doing, is that is looks like it it trying to close the document (next line in the code) after the save as command has been sent but the command hasn't completed in edge so when i send the Close() cmd it crashes.

Is there a way to check that edge has completed the command that has been send before you send the next one?. I have tried using a App.wait which helps but this seem to be a poor way of doing it. Looking in the VB.net help there is a command 'Threadstate' type instruction, but i don't know how to tie it in to Edge command or even if it is the right command that i'm looking for

 

Your Thougths?

 

Snow

 

 

Posted by: Snow Mackenzie
Post date: 11/30/2008 12:59:53 PM

RE: Closing Documents Woes

[ Edited ]

Hi Snow,

 

in VB.Net you can use Application.DoEvents(), but I'm not sure this will help. You could also try checking SolidEdgeFramework.Application.IsIdle() to see if SE has finished processing but I have a funny feeling that this has always returned true in the past...

 

Just a thought - does this happen on the first document you process. If not then it may be a problem with releasing resources, I seem to remember having a similar problem once. Make sure to call Marshal.ReleaseComObject on all your Solid Edge objects as soon as you've finished with them.

 

Sorry I can't be of more help,

Calum

 

Posted by: Calum McLellan
Post date: 11/30/2008 8:13:25 PM

RE: Closing Documents Woes

[ Edited ]

Hi Calum

Yip that worked a treat

 

Do While System.Runtime.InteropServices.Marshal.ReleaseComObject(objseSheetDoc.Models)

Loop

 

Slowed down the processing heaps but didn't have one crash

That row of monteiths is getting longer and longer Smiley Happy

 

Thank heaps

Snow

 

 

Posted by: Snow Mackenzie
Post date: 11/30/2008 10:10:31 PM

RE: Closing Documents Woes

[ Edited ]

 

Watch out - I might be back next year to collect

 

Posted by: Calum McLellan
Post date: 12/1/2008 2:40:35 AM

RE: Closing Documents Woes

[ Edited ]

Hi Calum

Just woundering is there and good books out for learning .net. Might need a lesson or 2. Seems totally drifferent to good old vb6

 

Cheers

 

Posted by: Snow Mackenzie
Post date: 12/1/2008 7:50:03 PM