<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unable to suppress occurrence in subassembly in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682215#M129932</link>
    <description>&lt;P&gt;It's the desired behavior and pointed out in the LOD to MS migration document (&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/important-for-developers-working-with-level-of-details/td-p/10022289" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/important-for-developers-working-with-level-of-details/td-p/10022289&lt;/A&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Suppress&amp;nbsp;a&amp;nbsp;ComponentOccurrenceProxy&amp;nbsp;is&amp;nbsp;not&amp;nbsp;allowed.&lt;BR /&gt;&lt;BR /&gt;To achieve what you want you should work in the context of oOccurrence parent document.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Or consider to make the occurrence invisible instead if it's just what you need.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 12 Oct 2021 10:22:22 GMT</pubDate>
    <dc:creator>CattabianiI</dc:creator>
    <dc:date>2021-10-12T10:22:22Z</dc:date>
    <item>
      <title>Unable to suppress occurrence in subassembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682063#M129928</link>
      <description>&lt;P&gt;Hello everyone&lt;BR /&gt;&lt;BR /&gt;I have this VBA code that check for each occurrence if it is suppressed. If yes it will unsuppress. Then it recursively calls itself if the occurrence is assembly.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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 oOccurrences, oAsmDoc
End Sub
Sub Zapnuti_occurrence(oOccurrences As ComponentOccurrences, oDoc As Inventor.AssemblyDocument)
    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
            If InStr(oOccurrence.Definition.Document.DisplayName, new_element) = 0 Then
                oDoc.Update
            End If
            Set oDoc = ThisApplication.Documents.Open(oOccurrence.Definition.Document.FullFileName)
                            
            
            Zapnuti_occurrence oOccurrence.SubOccurrences, oDoc
            
            oDoc.Save2
            oDoc.Close
        End If
    Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;When trying to unsuppress occurrence of subassembly, it throws this error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unsuppress error.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/976088i6FD4662A8586E760/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Unsuppress error.png" alt="Unsuppress error.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;It does not matter if before trying to suppress occurrence It creates new model state or not. Please do you know how to solve this problem?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 05:10:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682063#M129928</guid>
      <dc:creator>daniel.puchta</dc:creator>
      <dc:date>2021-10-12T05:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to suppress occurrence in subassembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682215#M129932</link>
      <description>&lt;P&gt;It's the desired behavior and pointed out in the LOD to MS migration document (&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/important-for-developers-working-with-level-of-details/td-p/10022289" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/important-for-developers-working-with-level-of-details/td-p/10022289&lt;/A&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Suppress&amp;nbsp;a&amp;nbsp;ComponentOccurrenceProxy&amp;nbsp;is&amp;nbsp;not&amp;nbsp;allowed.&lt;BR /&gt;&lt;BR /&gt;To achieve what you want you should work in the context of oOccurrence parent document.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Or consider to make the occurrence invisible instead if it's just what you need.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 12 Oct 2021 10:22:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682215#M129932</guid>
      <dc:creator>CattabianiI</dc:creator>
      <dc:date>2021-10-12T10:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to suppress occurrence in subassembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682253#M129933</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()
    Dim oAsmDoc As Inventor.AssemblyDocument
    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
    oAsmCompDef = oDoc.ComponentDefinition
    Dim oOccurrences As ComponentOccurrences
	Dim oOccurrence As ComponentOccurrence
    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
    				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)
                            
            
            Call Zapnuti_occurrence(oSubAsmCompDoc) 
            
'            oDoc.Save2
'            oDoc.Close
        End If
    Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;Which inventor version are you use？&lt;/P&gt;&lt;P&gt;In the 2021，there is no modelstate .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:12:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682253#M129933</guid>
      <dc:creator>Stakin</dc:creator>
      <dc:date>2021-10-12T07:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to suppress occurrence in subassembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682320#M129935</link>
      <description>&lt;P&gt;Thank you for your advice, could you be more specific what do you meant? Maybe post example of code?&lt;BR /&gt;&lt;BR /&gt;I have modified the code that it is unsuppressing suboccurrences but this does not work (it throws error).&lt;BR /&gt;Heres the code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:48:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682320#M129935</guid>
      <dc:creator>daniel.puchta</dc:creator>
      <dc:date>2021-10-12T07:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to suppress occurrence in subassembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682323#M129936</link>
      <description>&lt;P&gt;Sorry I work with Inventor 2022, so there are model states and the behaviour of occurrences and suboccurrences is different..&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:50:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682323#M129936</guid>
      <dc:creator>daniel.puchta</dc:creator>
      <dc:date>2021-10-12T07:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to suppress occurrence in subassembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682598#M129943</link>
      <description>&lt;P&gt;What if you change this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Zapnuti_occurrence oOccurrence.SubOccurrences, oDoc&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Zapnuti_occurrence oDoc.ComponentDefinition.Occurrences, oDoc&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Oct 2021 10:01:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682598#M129943</guid>
      <dc:creator>j.haggenjos</dc:creator>
      <dc:date>2021-10-12T10:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to suppress occurrence in subassembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682624#M129944</link>
      <description>&lt;P&gt;Thank you, it works!&lt;BR /&gt;Here is the final code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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 oOccurrences, oAsmDoc
End Sub
Sub Zapnuti_occurrence(oOccurrences As ComponentOccurrences, oDoc As Inventor.AssemblyDocument)
    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
            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
            If InStr(oOccurrence.Definition.Document.DisplayName, new_element) = 0 Then
                oDoc.Update
            End If
            Set oDoc = ThisApplication.Documents.Open(oOccurrence.Definition.Document.FullFileName)
                            
            
            Zapnuti_occurrence oDoc.ComponentDefinition.Occurrences, oDoc
            
            oDoc.Save2
            oDoc.Close
        End If
    Next
End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Oct 2021 10:16:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10682624#M129944</guid>
      <dc:creator>daniel.puchta</dc:creator>
      <dc:date>2021-10-12T10:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to suppress occurrence in subassembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10684546#M129981</link>
      <description>&lt;LI-CODE lang="general"&gt;Sub Main()
    Dim oAsmDoc As Inventor.AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
    Zapnuti_occurrence  oAsmDoc
End Sub
Sub Zapnuti_occurrence( oDoc As Inventor.AssemblyDocument)
    Dim oSuppress_Occurrence As Boolean
    Dim oOccurrences As ComponentOccurrences
        oOccurrences =oDoc.ComponentDefinition.Occurrences
    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
            oOccurrence.Unsuppress
            oSuppress_Occurrence = True
        End If

        If oOccurrence.DefinitionDocumentType = kAssemblyDocumentObject Then
            If InStr(oOccurrence.Definition.Document.DisplayName, new_element) = 0 Then
                oDoc.Update
            End If
            Rem In the Opened Asm File,All the oOccurrence were opened in memeroy,needn't use the document open method again; try this.
            Zapnuti_occurrence oOccurrence.Definition.Document
        End If
    Next
oDoc.Save
End Sub&lt;/LI-CODE&gt;&lt;P&gt;In the Opened Asm File,All the oOccurrence were opened in memeroy,needn't use the document open method again; try this.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 02:21:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/unable-to-suppress-occurrence-in-subassembly/m-p/10684546#M129981</guid>
      <dc:creator>Stakin</dc:creator>
      <dc:date>2021-10-13T02:21:50Z</dc:date>
    </item>
  </channel>
</rss>

