Showing results for 
Search instead for 
Did you mean: 

Closing Documents

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Prior to Solid Edge ST8 being released, one of the developers emailed me to give me a heads up on a new API to handle closing documents. The problem has always been that in order to close a document, you had to call the Close() method of that object. The problem was that Solid Edge couldn't fully close the document because we were still holding a reference to it. In ST8, we have a new option available.


If you download the lastest Samples for Solid Edge on GitHub, you'll notice a new OpenClose project. I wrote this project to demonstrate our options for closing documents. Rather than copy\pasting the entire code in this post, I'll highlight the important part. The code below is C# but the VB version is available on GitHub.


The main point to notice is that starting with ST8, the Documents collection has a new CloseDocument() method. This method allows you to fully release your reference to the document prior to closing it. Something we have not had the ability to do prior to ST8.


// Prior to ST8, we needed a reference to a document to close it.
// That meant that SE can't fully close the document because we're holding a reference.
if (solidEdgeVesion.Major < 108)
	// Close the document.

	// Release our reference to the document.
	document = null;

	// Give SE a chance to do post processing (finish closing the document).
	// Release our reference to the document.
	document = null;

	// Starting with ST8, the Documents collection has a CloseDocument() method.
	documents.CloseDocument(file.FullName, false, Missing.Value, Missing.Value, true);


The definition of the Documents.CloseDocument() method look like:


void CloseDocument(String Filename, [Object SaveChanges], [Object SaveAsFileName], [Object RouteWorkbook], [Object DoIdle])
   Member of SolidEdgeFramework.Documents

You will want to pass true to the DoIdle argument. That will prevent you from having to call application.DoIdle() manually.


Be sure and check out the Solid Edge ST8 - What's New SDK topic. I always enjoy browsing the What's New pages for each version to see what goodies the development team gave us.


Thank You Jason for this solution. You save my week!

Writing a batch software for Part Sheet Metal Documents to kill the link to Excel Gagetable with the normal Solid Edge API is horror... SeApp.DoIdle and a lots of Threading.Thread.Sleep(200) make me headache...

With your definiton document.close(), my batch Software works well!

Thanks a lot for your great job!

Greetings from Switzerland

Matthias Leemann

Solution Partner Phenom

Very happy to hear that my post was useful. Thank you for the feedback!

Solution Partner Dreamer