<?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: Change Model State and parameter of assembly occurrence in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787720#M167613</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/533605"&gt;@J_Dumont&lt;/a&gt;.&amp;nbsp; There is no vb.net equivalent of that iLogic 'ModelStatesGlobalScope' resource.&amp;nbsp; When we want a change to be applied to all ModelStates the same way, we either iterate through each of the ModelStates, activate them, then make the same change, or we make the change to each row in the ModelStateTable, or to each row in the ModelStates Excel worksheet.&amp;nbsp; Working with the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ModelStateTable" target="_blank" rel="noopener"&gt;ModelStateTable&lt;/A&gt; is not too difficult, but nearly everything in it is ReadOnly, except for the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ModelStateTableCell_Value" target="_blank" rel="noopener"&gt;data cell values&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Correction:&amp;nbsp; If we can access the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ModelStates" target="_blank" rel="noopener"&gt;ModelStates&lt;/A&gt; collection of that component, then we can control its &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ModelStates_MemberEditScope" target="_blank" rel="noopener"&gt;MemberEditScope&lt;/A&gt; property value, which can then be set to 'kEditAllMembers' (a variation of the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=MemberEditScopeEnum" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=MemberEditScopeEnum&lt;/A&gt;).&amp;nbsp; Then we can make the change just once, and it will effect all ModelStates of that file.&amp;nbsp; But you must start from the 'factory' document version of that file.&amp;nbsp; One shortcut way to do that from an assembly perspective, is to use the '&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Documents_Open" target="_blank" rel="noopener"&gt;Open&lt;/A&gt;' method, specify the true FullDocumentName (not just FullFileName) of that component, and capture the Document that this method returns, then use that to access the ModelStates, and further interactions / edits to that document.&amp;nbsp; The document you get back from that Open method will effectively always be the 'factory', due to the way you are opening it with that method.&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2024 15:57:40 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2024-05-21T15:57:40Z</dc:date>
    <item>
      <title>Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12785405#M167543</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'd appreciate any help with the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've gone through many earlier posts, and I can't get the code to change the Model State and Parameter of an assembly occurrence to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've gotten it to work in iLogic, but I need to move to VB.Net for various reasons to make an Add-in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I prompt the user for input, which gives me the information for the needed model state and the value of the parameter that needs to change. I also need to set the occurrence to Global Edit. Below is the snippet for iLogic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;AssDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;

&lt;SPAN&gt;'Set Grille style using Model States&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;Occ&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt; = &lt;SPAN&gt;AssDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN&gt;Occurrences&lt;/SPAN&gt;.&lt;SPAN&gt;ItemByName&lt;/SPAN&gt;(&lt;SPAN&gt;"Linear Bar"&lt;/SPAN&gt;) 
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;partdoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;Occ&lt;/SPAN&gt;.&lt;SPAN&gt;Definition&lt;/SPAN&gt;.&lt;SPAN&gt;FactoryDocument&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;MSGSS&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;New&lt;/SPAN&gt; &lt;SPAN&gt;ModelStatesGlobalScope&lt;/SPAN&gt;(&lt;SPAN&gt;partdoc&lt;/SPAN&gt;)
&lt;SPAN&gt;Occ&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveModelState&lt;/SPAN&gt;=&lt;SPAN&gt;BarGrilleStyle&lt;/SPAN&gt;
&lt;SPAN&gt;InventorVb&lt;/SPAN&gt;.&lt;SPAN&gt;DocumentUpdate&lt;/SPAN&gt;()
&lt;SPAN&gt;partdoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN&gt;Parameters&lt;/SPAN&gt;.&lt;SPAN&gt;ModelParameters&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;"Length"&lt;/SPAN&gt;).&lt;SPAN&gt;Value&lt;/SPAN&gt; = &lt;SPAN&gt;LinearBarLength&lt;/SPAN&gt;*2.54 &lt;SPAN&gt;'convert from cm to in&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;Here's the VB code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;        Dim oDoc As AssemblyDocument
        oDoc = g_inventorApplication.ActiveDocument

        Dim oAssemblyCompDef As AssemblyComponentDefinition
        oAssemblyCompDef = oDoc.ComponentDefinition

        ' Specify an occurrence to change its active model state.
        Dim oOccu As ComponentOccurrence
        oOccu = oAssemblyCompDef.Occurrences(1)

        ' Get native document ComponentDefinition of occurrence.
        Dim oOccuDef As ComponentDefinition
        oOccuDef = oOccu.Definition

        oOccu.ActiveModelState = "CA400"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I referenced code from the following:&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-045E78DB-DBE3-4220-8EBC-29EB53890E1A" target="_blank"&gt;https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-045E78DB-DBE3-4220-8EBC-29EB53890E1A&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the message I get.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="J_Dumont_0-1716224118772.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1364790i37CA038330F303E2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="J_Dumont_0-1716224118772.png" alt="J_Dumont_0-1716224118772.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 16:58:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12785405#M167543</guid>
      <dc:creator>J_Dumont</dc:creator>
      <dc:date>2024-05-20T16:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12785451#M167544</link>
      <description>&lt;P&gt;For me this code works correct.&lt;/P&gt;
&lt;P&gt;It wil set the Model State of the first occurrence to "CA400" if defined correctly in the (sub)Assembly Occurrence&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 17:25:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12785451#M167544</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2024-05-20T17:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12785692#M167556</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/473476"&gt;@bradeneuropeArthur&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My apologies; I did not proofread my code before I copied it to the forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to specify the occurrence name and then change its Model State.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code that is not working.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;        Dim oDoc As AssemblyDocument
        oDoc = g_inventorApplication.ActiveDocument

        Dim oAssemblyCompDef As AssemblyComponentDefinition
        oAssemblyCompDef = oDoc.ComponentDefinition

        ' Specify an occurrence to change its active model state.
        Dim oOccu As ComponentOccurrence
        oOccu = oAssemblyCompDef.Occurrences.Item("Linear Bar")

        ' Get native document ComponentDefinition of occurrence.
        Dim oOccuDef As ComponentDefinition
        oOccuDef = oOccu.Definition

        oOccu.ActiveModelState = "CA400"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="J_Dumont_0-1716234183323.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1364858iEE199C3BF9A2BF83/image-size/medium?v=v2&amp;amp;px=400" role="button" title="J_Dumont_0-1716234183323.png" alt="J_Dumont_0-1716234183323.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 19:43:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12785692#M167556</guid>
      <dc:creator>J_Dumont</dc:creator>
      <dc:date>2024-05-20T19:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787412#M167600</link>
      <description>&lt;P&gt;Looks like you may just need to switch from using the regular &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ComponentOccurrences_Item" target="_blank" rel="noopener"&gt;Item&lt;/A&gt; property (only accepts Integer/Long), to using the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ComponentOccurrences_ItemByName" target="_blank" rel="noopener"&gt;ItemByName&lt;/A&gt; property for that one line of code.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 14:04:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787412#M167600</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-05-21T14:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787646#M167611</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/473476"&gt;@bradeneuropeArthur&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your assistance with the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can either of you help me with my second issue? After I change the Model State, I need to adjust the Length parameter.&lt;/P&gt;&lt;P&gt;The Length parameter is not defined in each State, so I will need to change the edit scope to Global and then change the length parameter.&lt;/P&gt;&lt;P&gt;If I need to, I can start another message.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 15:22:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787646#M167611</guid>
      <dc:creator>J_Dumont</dc:creator>
      <dc:date>2024-05-21T15:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787720#M167613</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/533605"&gt;@J_Dumont&lt;/a&gt;.&amp;nbsp; There is no vb.net equivalent of that iLogic 'ModelStatesGlobalScope' resource.&amp;nbsp; When we want a change to be applied to all ModelStates the same way, we either iterate through each of the ModelStates, activate them, then make the same change, or we make the change to each row in the ModelStateTable, or to each row in the ModelStates Excel worksheet.&amp;nbsp; Working with the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ModelStateTable" target="_blank" rel="noopener"&gt;ModelStateTable&lt;/A&gt; is not too difficult, but nearly everything in it is ReadOnly, except for the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ModelStateTableCell_Value" target="_blank" rel="noopener"&gt;data cell values&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Correction:&amp;nbsp; If we can access the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ModelStates" target="_blank" rel="noopener"&gt;ModelStates&lt;/A&gt; collection of that component, then we can control its &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ModelStates_MemberEditScope" target="_blank" rel="noopener"&gt;MemberEditScope&lt;/A&gt; property value, which can then be set to 'kEditAllMembers' (a variation of the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=MemberEditScopeEnum" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=MemberEditScopeEnum&lt;/A&gt;).&amp;nbsp; Then we can make the change just once, and it will effect all ModelStates of that file.&amp;nbsp; But you must start from the 'factory' document version of that file.&amp;nbsp; One shortcut way to do that from an assembly perspective, is to use the '&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Documents_Open" target="_blank" rel="noopener"&gt;Open&lt;/A&gt;' method, specify the true FullDocumentName (not just FullFileName) of that component, and capture the Document that this method returns, then use that to access the ModelStates, and further interactions / edits to that document.&amp;nbsp; The document you get back from that Open method will effectively always be the 'factory', due to the way you are opening it with that method.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 15:57:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787720#M167613</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-05-21T15:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787734#M167614</link>
      <description>&lt;P&gt;Also, have you read this help page about the assembly needing to be updated when multiple component instances are included for models that have multiple ModelStates.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-418B956A-AC3F-48D8-BEBC-FC28C4B51DA2" target="_blank" rel="noopener"&gt;To Modify an Occurrence Parameter with a Model State&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 15:50:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12787734#M167614</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-05-21T15:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12790590#M167662</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the info. I will see if I can dig deeper into what you sent me.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 16:25:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12790590#M167662</guid>
      <dc:creator>J_Dumont</dc:creator>
      <dc:date>2024-05-22T16:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Change Model State and parameter of assembly occurrence</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12790597#M167663</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, this is where I first started, but I had no luck changing the occurrence parameters with the information within this link. The link seems to be focused on iLogic or VBA.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 16:28:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-model-state-and-parameter-of-assembly-occurrence/m-p/12790597#M167663</guid>
      <dc:creator>J_Dumont</dc:creator>
      <dc:date>2024-05-22T16:28:10Z</dc:date>
    </item>
  </channel>
</rss>

