Hi,
' Checks the assembly and subassemblies for the DisplayNameOverridden flag
' Outputs unique files in a MessageBox
Sub Main()
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim overriddenList As New ArrayList
Dim notOverriddenList As New ArrayList
Dim processedDocs As New ArrayList ' Track processed documents
' Start recursive check
CheckDisplayNameOverridden(oDoc, overriddenList, notOverriddenList, processedDocs)
' Format results
Dim result As String
result = "Files with DisplayNameOverridden = True:" & vbCrLf
For Each file In overriddenList
result = result & file & vbCrLf
Next
result = result & vbCrLf & "Files with DisplayNameOverridden = False:" & vbCrLf
For Each file In notOverriddenList
result = result & file & vbCrLf
Next
' Display in MessageBox
MessageBox.Show(result, "DisplayNameOverridden Check Results")
End Sub
Sub CheckDisplayNameOverridden(oDoc As Document, overriddenList As ArrayList, notOverriddenList As ArrayList, processedDocs As ArrayList)
' Skip if document already processed
If processedDocs.Contains(oDoc.FullFileName) Then
Return
End If
' Add to processed list
processedDocs.Add(oDoc.FullFileName)
' Check current document
If oDoc.DisplayNameOverridden Then
overriddenList.Add(oDoc.FullFileName)
Else
notOverriddenList.Add(oDoc.FullFileName)
End If
' If document is an assembly, check components
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
Dim oAsmDoc As AssemblyDocument
oAsmDoc = oDoc
Dim oCompDef As AssemblyComponentDefinition
oCompDef = oAsmDoc.ComponentDefinition
' Iterate through all components
For Each oOcc As ComponentOccurrence In oCompDef.Occurrences
Try
Dim refDoc As Document
refDoc = oOcc.Definition.Document
' Recursive check for subassemblies and parts
CheckDisplayNameOverridden(refDoc, overriddenList, notOverriddenList, processedDocs)
Catch
' Ignore errors (e.g., for proxy components)
End Try
Next
End If
End Sub
INV 2025.3