Find displayname override ilogic

Find displayname override ilogic

Jelvin_
Advocate Advocate
164 Views
2 Replies
Message 1 of 3

Find displayname override ilogic

Jelvin_
Advocate
Advocate

I would like to know if there is a way to find out if the displayname (not iam occurrence name) has been changed. 

 

The code i have now compares the filename with the displayname and works ok. The issues is that sometimes the displayname is overridden witht the filename. In that case the comparison doesnt work as intended, and when i copy a file, the old filename is still there as a displayname override

 

So, ilogic to find displayname override/dirty?

0 Likes
Accepted solutions (1)
165 Views
2 Replies
Replies (2)
Message 2 of 3

Ivan_Sinicyn
Advocate
Advocate
Accepted solution

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
Message 3 of 3

Jelvin_
Advocate
Advocate

Thanks so much. I will test, but i guess i was looking for:

oDoc.DisplayNameOverridden

 

This code is actually what i intended to build, so thank you again 🙂