I am curious how I can tell my application to wait until my document is loaded. Currently, I have a code that is activated on a button.click event. A section of the code is:
System.Diagnostics.Process.Start(oInitialPath & ".idw")
oDrawingDoc = _invApp.Documents.ItemByName(oInitialPath & ".idw")
oDrawingDoc.SaveAs(StripFilename(MyFile) & oNewName & ".idw", False)
I'm not sure if .process.start is the best way to open an Autodesk Inventor document, but regardless it works. The issue is that the next line, where I assign the document to the variable, is called before the document can open. So I get an exception error because the document doesnt exist yet. What can I put in that will make the application wait until the document is fully open before assigning it to a variable? Without using a messagebox or threading.sleep.
You have already identified the cause of your problem: You use two different ways to communicate with your third-party application:
The solution is simple: Use the application's COM automation interface (_invApp
) also for opening the file. How to do that can be found in the documentation of your third-party application.