Vb.net - Export files and then can not change project

Vb.net - Export files and then can not change project

premysl.misun
Advocate Advocate
926 Views
3 Replies
Message 1 of 4

Vb.net - Export files and then can not change project

premysl.misun
Advocate
Advocate

Hi,

 

I have my own program in vb.net to export drawings to pdf and dxf files, and part (or assembly) to stp files. It works very good (from opened drawing).

 

After I export one or more drawings by this, I can not change project and I have to close Inventor and start it again. Message from invenor is "Active project can not be changed, if are open files in Inventor" (I have in czech language, so that message can be little different). But all files in Inventor are vissibly closed (after export program closed drawing).

 

Do you have any idea to solved this in vb.net?

 

Thank you,

 

Premek

0 Likes
Accepted solutions (1)
927 Views
3 Replies
Replies (3)
Message 2 of 4

premysl.misun
Advocate
Advocate

Here is part of program:

 

Dim path As String = System.IO.Path.GetDirectoryName(soubor.FullFileName)
            Dim path2 As String = System.IO.Path.GetFileNameWithoutExtension(soubor.FullFileName)
            Dim path3 As String = System.IO.Path.GetFileName(soubor.FullFileName)

            soubor.SaveAs("D:\Projekty\Dokumentace\Pdf\" & path2 & ".pdf", True)
            soubor.SaveAs("D:\Projekty\Dokumentace\Dxf\" & path2 & ".dxf", True)

            Dim oDrawDoc As DrawingDocument
            oDrawDoc = _invApp.ActiveDocument
            Dim oRefDoc As Document

            For Each oRefDoc In oDrawDoc.ReferencedDocuments
                If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then

                    Dim model As Inventor.PartDocument = _invApp.Documents.Open(path & "\" & path2 & ".ipt", False)
                    model.SaveAs("D:\Projekty\Dokumentace\Stp\" & path2 & ".stp", True)
                    _invApp.ActiveDocument.Close()

                ElseIf oRefDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then

                    Dim sestava As Inventor.AssemblyDocument = _invApp.Documents.Open(path & "\" & path2 & ".iam", False)
                    sestava.SaveAs("D:\Projekty\Dokumentace\Stp\" & path2 & ".stp", True)
                    _invApp.ActiveDocument.Close()

                End If
            Next oRefDoc

Message 3 of 4

premysl.misun
Advocate
Advocate

Hi again,

 

do anybody now how to "unlock" change of project after file export?

 

P.

0 Likes
Message 4 of 4

MechMachineMan
Advisor
Advisor
Accepted solution

It seems fairly obvious that it is one of 2 things:

 

1. There is a bug.

2. You still have files open - probably invisibly, which still prevents file change.

 

After you run the rule, either check in the bottom right corner of your main window. There should be 2 boxes with numbers in. If both are not 0, you definitely have documents open. The other option is to check the application Documents enum using VBA to see the open documents count.

 

If you have documents open invisibly, you will need to revise your original export code to close the files after you are done exporting them.

 

** Modify your code to contain 

oRefDoc.Close AND model.Close inside of your loop. your _invApp.ActiveDocument is not doing a sufficient job of closing files - and will not close an invisible file, which is opened when using Documents.Open(,False)


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes