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

From this page: http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-0123304B-EC33-4430-B4F1-CBF225CB5B8F

comes this example iLogic Rule (Adapted slightly, because at the page above the code was VBA):

 

Public Sub Main()

  Dim oFile As File = ThisApplication.ActiveDocument.File
    
  Call ProcessReferences(oFile)
    
End Sub

Private Sub ProcessReferences ( ByVal oFile As File )
    
  Dim oFileDescriptor As FileDescriptor    
  For Each oFileDescriptor In oFile.ReferencedFileDescriptors        
       	
    Debug.Print oFileDescriptor.FullFileName
        
    If Not oFileDescriptor.ReferenceMissing Then
        
      ' Since the ReferenceMissing has returned False, the ReferencedFile will return a File
      ' Recurse unless this is a foreign file reference
      If Not oFileDescriptor.ReferencedFileType = kForeignFileType Then

        Call ProcessReferences(oFileDescriptor.ReferencedFile)           			 
      End If            
    End If        
  Next    
End Sub

In theory you could use the same approach with a simple modification, instead of just checking whether the "oFileDescriptor.ReferenceMissing", you could do this:

 

If oFileDescriptor.ReferencedDocument = nothing then
'delete oFileDescriptor
End If

Of course, I have to ask why you want to delete unresolved references at all? Since in doing so, it will likely mean you'll end up with broken Assemblies and referencing drawings. Is it a dataset you inherited/don't have the time/money to fix?