Inventor new instance on close

Inventor new instance on close

NachoShaw
Advisor Advisor
340 Views
1 Reply
Message 1 of 2

Inventor new instance on close

NachoShaw
Advisor
Advisor

Hey

 

im having a small issue with an invisible document appearing in my taskbar when i close inventor. This appears mainly after i run my app so i mustn't be closing something properly. In summary, here is my document open / save close process

 

1. Import step file using translator (no open file before import)

Call oSTEPTranslator.Open(oDataMedium, oContext, oOptions, oTarget)

2. Create a document view from the import

Dim oDoc As Inventor.Document = oTarget
oDoc.Views.Add()

3. Process all of the components in this document (not saved yet)

4. Rebuild & update active assembly (document from step 1)

5. Create a temp doc to hold the original ActiveDoc

Dim OldDoc As Inventor.AssemblyDocument = AddinGlobal.InventorApp.ActiveDocument

6. SaveAs the current ActiveDoc into a new location

 AddinGlobal.InventorApp.ActiveDocument.SaveAs(PathRoot & AssyName & ".iam", True)

7. Open the newly saved document as a new assembly

Dim NewDoc As Inventor.AssemblyDocument = AddinGlobal.InventorApp.Documents.Open(PathRoot & AssyName & ".iam", True)

8. Close the old doc that i created as the ActiveDoc prior to saving

OldDoc.Close(True)

9. Iterate assembly and SaveAs all components then replacing them in the assembly for the saved ones

 

This should leave 1 assembly active (the new one) and the old ones closed or is that not the case? Does item 2 actually create another document and is that the rogue document? Somewhere in this process is an invisible document. For every other process, i pass the ActiveDocument through instead creating document instances for example-

Private Sub DoSomething()
'process stuff here
Call NextSub(_InvApp.ActiveDocument)
End Sub

Private Sub NextSub(ByRef CurrDoc As AssemblyDocument)
'do something with CurrDoc
End Sub

 

The problem highlights when a new project is initiated as all documents need to be closed...

 

Any help greatly appreciated

 

Thanks

 

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
341 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

A little hard to follow, but kind of sounds like this built-in iLogic Sub may be able to help.

Dim oDoc As Document
oDoc.ReleaseReference

I only put the Dim oDoc As Document, in there to activate iLogic Rule Editor's intellisense type ability, to show what id does.

Release Reference screen capture.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes