0

I wanted to remove the broken publications which are having No Element Status only highlighted in yellow as shown below.

enter image description here

enter image description here

Below is my code its not giving full result. please help me to resolve this.

Sub CATMain()

    Set CATIA = GetObject(, "CATIA.APPLICATION")
    Set oSelection = CATIA.ActiveDocument.Selection
    oSelection.Search "CATAsmSearch.Part,all"
    For i = 1 To oSelection.Count
        Dim num_of_publ_existing As Integer
        num_of_publ_existing = oSelection.Item(i).Value.Publications.Count
        ReDim aa(num_of_publ_existing)
        For k = 1 To num_of_publ_existing
            PubName = oSelection.Item(i).Value.Publications.Item(k).Name
            Set pubRef = oSelection.Item(i).Value.Publications.Item(PubName).Valuation
            If pubRef.DisplayName <> "" Then
                aa(k - 1) = PubName
                 Debug.Print PubName
                 Debug.Print pubRef.DisplayName
            End If
        Next
        For j = 0 To num_of_publ_existing

                oSelection.Item(i).Value.Publications.Remove (aa(j))

        Next
    Next
    oSelection.Clear
    
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
sid
  • 1
  • 1
  • 1
    Do you get an error? Are you sure the publications are not removed? In my short test the publications are removed but they still shown in the tree (bug). After reopening the file the publications were shown correct. – Shrotter Jan 27 '23 at 06:58

0 Answers0