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

Thank you for your advice, could you be more specific what do you meant? Maybe post example of code?

I have modified the code that it is unsuppressing suboccurrences but this does not work (it throws error).
Heres the code:

Sub Main()
    Dim oAsmDoc As Inventor.AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
'    Dim oAsmCompDef As AssemblyComponentDefinition
'    Set oAsmCompDef = oAsmDoc.ComponentDefinition
'    Dim oOccurrences As ComponentOccurrences
'    Set oOccurrences = oAsmCompDef.Occurrences
    Zapnuti_occurrence oAsmDoc
End Sub
Sub Zapnuti_occurrence(oDoc As Inventor.AssemblyDocument)
    Dim oAsmCompDef As AssemblyComponentDefinition
    Set oAsmCompDef = oDoc.ComponentDefinition
    Dim oOccurrences As ComponentOccurrences
    Dim oSubOccurrence As ComponentOccurrence
    Dim oOccurrence As ComponentOccurrence
    Set oOccurrences = oAsmCompDef.Occurrences
    
'    Dim oSuppress_Occurrence As Boolean
'    Dim oModelState As ModelState
'    Dim oModelState_created As Boolean
    
'    oModelState_created = False
    For Each oOccurrence In oOccurrences 'tady to změnit na list
'        oSuppress_Occurrence = False
        If oOccurrence.Suppressed = True Then
'            If oModelState_created = False Then
'                Set oModelState = ThisApplication.ActiveDocument.ComponentDefinition.ModelStates.Add("Part2Suppressed2")
'            End If
            oOccurrence.Unsuppress
'            oSuppress_Occurrence = True
        End If
        'do stuff...
        'If oSuppress_Occurrence = True Then
        '    oSuppress_Occurrence = False
        '    oOccurrence.Suppress
        'End If
    
        If oOccurrence.DefinitionDocumentType = kAssemblyDocumentObject Then
                Dim oSubAsmCompDoc As AssemblyDocument
                Set oSubAsmCompDoc = oOccurrence.Definition.Document
'            If InStr(oOccurrence.Definition.Document.DisplayName, new_element) = 0 Then
'                oDoc.Update
'            End If
'            oDoc = ThisApplication.Documents.Open(oOccurrence.Definition.Document.FullFileName)
             For Each oSubOccurrence In oOccurrence.SubOccurrences
             
                 If oSubOccurrence.Suppressed = True Then
        '            If oModelState_created = False Then
        '                Set oModelState = ThisApplication.ActiveDocument.ComponentDefinition.ModelStates.Add("Part2Suppressed2")
        '            End If
                    oSubOccurrence.Unsuppress
        '            oSuppress_Occurrence = True
                End If
                
             Next
            
            Call Zapnuti_occurrence(oSubAsmCompDoc)
            
'            oDoc.Save2
'            oDoc.Close
        End If
    Next
End Sub