Problem to read open documents

Problem to read open documents

cavallerin
Enthusiast Enthusiast
97 Views
2 Replies
Message 1 of 3

Problem to read open documents

cavallerin
Enthusiast
Enthusiast

Hi all,

 

i have the following code that looks for open inventor files, discard what it is not an assembly and prepare a list of selectable document, then data are retrieved from the model and written on an excel sheet.

The purpose of this function is to give the user the ability to say from which assembly he/she can retrieve data.

All is performed within an excel workbook.

 

The problem I'm facing is:

when I open a new file and run the code, it will not shows the new opened document in the selectable list. It seemes that there's a kind of "cache", but I don't know exactly how it works.

 

e.g

I open assembly1, run the code, a pop-up windows show in the list the "assembly1.iam" row

If then I open another assembly (assembly2) and rerun the code, only assembly1 is selectable.

 

How would you manage that?

Thanks

Michele

 

I defined as global variable on the module the inventor application

 

Option Explicit
Dim invApp As Inventor.Application

 

here's the GetDocumentList function...

Private Function GetDocumentList(ByRef docs As Object) As Variant

    Dim assiemiCount As Integer
    Dim i As Integer
    Dim doc As Object
    Dim docNames, selectedDocName As String
    Dim isAssemblyDocument, selezioneValida, gestioneCiclo As Boolean
    
    For i = 1 To docs.VisibleDocuments.Count
        Set doc = docs.Item(i)
        isAssemblyDocument = TypeName(doc) = "AssemblyDocument"
           
        If InStr(doc.FullFileName, "iam") And isAssemblyDocument Then
            docNames = docNames & i & ": " & doc.DisplayName & vbCrLf
            assiemiCount = assiemiCount + 1
        End If

    Next i
    
    If assiemiCount ....

 

0 Likes
98 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor

could you share the complete code with us, so that we can test it ourselves?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 3

Sure, here you are.

I let only the sub involved in the macro.

Inside the zip there is a excel file named: _code.xlsm

To run it, please:

  1. Start Inventor
  2. Open an assembly with a least one component.
  3. Click the button on the excel sheet

To raise the strange behaviour:

  1. Keep the previous assembly opened
  2. Open a new Assembly with a least one component.
  3. Re-run the macro on the excel sheet

Thanks for any help.

0 Likes