Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Vladimir.Ananyev
in reply to: DJFore

When your rule is executed in the context of the drawing document you are able to get access to all documents that are referenced by your drawing directly or indirectly.  Here is the VBA sample that uses ReferencedDocuments and AllReferencedDocuments collections to illustrate the workflow:

Sub Drawing_ReferencedDocs()
    'reference to the active drawing document
    Dim ThisDoc As Inventor.Document
    Set ThisDoc = ThisApplication.ActiveDocument
    
    Dim oDoc As Inventor.Document
    
    Debug.Print "Drawing document: " & ThisDoc.FullFileName
    
    'print all the documents directly referenced by this drawing.
    Debug.Print "Referenced documents: (full document names)"
    For Each oDoc In ThisDoc.ReferencedDocuments
        'Debug.Print oDoc.FullFileName
        Debug.Print oDoc.FullDocumentName
    Next
    Debug.Print
    'print all the document references of this drawing
    'along with all of the recursively nested references.
    Debug.Print "All Referenced documents:"
    For Each oDoc In ThisDoc.AllReferencedDocuments
        Debug.Print oDoc.FullFileName
    Next
    Debug.Print " ----------------- "
    Beep
End Sub

 

You may iterate these collections and save any documents you need. This code should work for assembly document as well. 

BTW you may access an assembly or a part document referenced by the specific DrawingView object:

Dim oView As DrawingView
Set oView = ThisDoc.Sheets.Item(1).DrawingViews.Item(1)

Dim oDiscr As DocumentDescriptor
Set oDiscr = oView.ReferencedDocumentDescriptor

Debug.Print "Displayname:      " & oDiscr.DisplayName
Debug.Print "FullDocumentName: " & oDiscr.FullDocumentName

Set oDoc = oDiscr.ReferencedDocument
Debug.Print "FullFileName:     " & oDoc.FullFileName

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network