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

Hi, this is created in vba, switch the commented line to actually delete the occurence

Sub DeleteUnresolvedFiles()
        Dim oFile As Inventor.File
        Set oFile = ThisApplication.ActiveDocument.File
        
        Dim oDoc As AssemblyDocument
        Set oDoc = ThisApplication.ActiveDocument
        oDoc.Save
        
        Dim oDocDef As AssemblyComponentDefinition
        Set oDocDef = oDoc.ComponentDefinition
        
        Call ProcessReferences(oFile, oDoc, oDocDef)

End Sub
Private Sub ProcessReferences(ByVal oFile As Inventor.File, oDoc As AssemblyDocument, oDocDef As ComponentDefinition)

        Dim oFileDescriptor As FileDescriptor
        For Each oFileDescriptor In oFile.ReferencedFileDescriptors
            If Not oFileDescriptor.ReferenceMissing Then
                If Not oFileDescriptor.ReferencedFileType = FileTypeEnum.kForeignFileType Then
                    Call ProcessReferences(oFileDescriptor.ReferencedFile, oDoc, oDocDef)
                End If
            Else
            Dim oComp As ComponentOccurrence
            For Each oComp In oDocDef.Occurrences
            If oComp.ReferencedDocumentDescriptor.ReferencedFileDescriptor.FullFileName = oFileDescriptor.FullFileName Then
            MsgBox (oFileDescriptor.FullFileName & vbCrLf & oFileDescriptor.RelativeFileName)
            'oComp.Delete
            End If
            Next oComp
            End If
                       
        Next
End Sub
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"