get all referencedocument without opening assembly

get all referencedocument without opening assembly

skyngu
Collaborator Collaborator
3,029 Views
6 Replies
Message 1 of 7

get all referencedocument without opening assembly

skyngu
Collaborator
Collaborator

hi all,

 

in inventor VBA, is it possible to get all reference documents without opening an assembly file in inventor?

 

this is i am using right now,

 

Dim oAssyDoc As AssemblyDocument

Set oAssyDoc = oInvApp.Documents.Open(sAssyPath)

oAssyDoc.Update

Dim oAllRefParts As DocumentsEnumerator

 If Check1 = True Then

Set oAllRefParts = oAssyDoc.ReferencedDocuments

Else

Set oAllRefParts = oAssyDoc.AllReferencedDocuments End If

 

thanks

Autodesk Inventor Professional 2019
0 Likes
3,030 Views
6 Replies
Replies (6)
Message 2 of 7

Mike.Wohletz
Collaborator
Collaborator

The file will need to be opened in something to get this, if you don't have it open then you can use the Apprentice Server to get the info needed.

0 Likes
Message 3 of 7

barbara.han
Alumni
Alumni

If you just want to use VBA, you can open the file as invisible. See the following demo:

 

Sub OpenAssembyInvisible()

    Dim assDoc As AssemblyDocument

    Set assDoc = ThisApplication.Documents.Open("c:\temp\assembly1.iam", False)

    

    On Error Resume Next

    Dim refDes As FileDescriptor

    For Each refDes In assDoc.File.ReferencedFileDescriptors

        Debug.Print refDes.FullFileName

        If Not refDes.ReferencedFile Is Nothing Then

            If Err Then

                ' refDes.ReferencedFile may be exception

                Err.Clear

            Else

                Dim refDoc As Document

                Set refDoc = refDes.ReferencedFile.AvailableDocuments(1)

                ' Do something here...

                Debug.Print refDoc.PropertySets.Count

            End If

        End If

    Next

    

    assDoc.Close (True)

End Sub

 

You may notice that I used AssemblyDocument.File.ReferencedFileDescriptors to iterate down the assembly structure, instead of AssemblyDocument.ReferencedDocumentDescriptors. This is due to some referenced files (e.g. substitue part) being not open in memory for sure. File.ReferencedFileDescriptors can find all files. Hope this helps.

Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 4 of 7

skyngu
Collaborator
Collaborator

thanks for the tip.

 

acturally, i try to print out all reference parts. I will see either server or open in "false" is faster.

Autodesk Inventor Professional 2019
0 Likes
Message 5 of 7

barbara.han
Alumni
Alumni

The real issue that affects the speed/performance lays on the file openning. Iterating the assembly structure is fast engough. Using apprentice server or Inventor may not be that different on the speed.

 

If you want to use apprentice, maybe you can refer to my sample application posted to Autodesk Labs:

Plugin of the Month Catalog on Autodesk Labs -->Inventor category -> Hierarchy Clone for Inventor. Good luck!

Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 6 of 7

skyngu
Collaborator
Collaborator

thanks again.

 

so that is possible to save a drawing as pdf without opening the drawing.  I tried to open drawing in "false". it gives me error. guess using apprentic server will do it.

Autodesk Inventor Professional 2019
0 Likes
Message 7 of 7

brendan.henderson
Advisor
Advisor

If you are just after a method to print all of the refeenced IDW's from an assembly then head over to the below page for a macro a friend gave me. Read the posts to get the caveats for use.

 

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Printing-all-drawings-of-an-assembly-f...

 

Brendan Henderson

Brendan Henderson
CAD Manager


New Blog | Old Blog | Google+ | Twitter


Inventor 2016 PDSU Build 236, Release 2016.2.2, Vault Professional 2016 Update 1, Win 7 64 bit


Please use "Accept as Solution" & give "Kudos" if this response helped you.

0 Likes