<?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: iLogic Code to change between Model State on an Assembly in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12178679#M44380</link>
    <description>&lt;P&gt;Anybody try?&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2023 19:27:34 GMT</pubDate>
    <dc:creator>GosponZ</dc:creator>
    <dc:date>2023-08-17T19:27:34Z</dc:date>
    <item>
      <title>iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10702754#M44367</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some help with iLogic. I have an assembly where 8 of the 10 parts are driven by Multi-Body Model State. The source Multi-Body part has multiple Model States with various sizes. I would like to have a form in the Assembly where the user enters the Model state that they want their assembly to corresponding to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From my basic understanding of iLogic, we want the iLogic rule to open all the&amp;nbsp; 8 individual components and change the Multi State to what the user entered in the form. With the help from the post below, I was able to run external rules where the code goes to the individual components and changes the model state. The difficulty I'm having is where I want to incorporate the Form function with user input for the Model State. Currently I'm opening the source code and manually changing the Multi-State name, I would like to change this so the users don't mess around the source code and just uses the Form to change between the Model States.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="Change Multi State for a component. " href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/change-drive-part-model-stage-using-ilogic/m-p/10643539#M129287" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/change-drive-part-model-stage-using-ilogic/m-p/10643539#M129287&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 01:08:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10702754#M44367</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2021-10-21T01:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10703774#M44368</link>
      <description>&lt;P&gt;This sounds fairly simple when you say it, but I'm thinking it will be more complicated than it sounds.&amp;nbsp; In order to use an iLogic Form in the main assembly that will allow you to change the ModelState of all those components, you would likely have to create a multi-value, text type user parameter within your main assembly for each of those components, that contains the names of each available ModelState within that component.&amp;nbsp; Then you will need to create the Form.&amp;nbsp; Then you will need to create a rule that is triggered by those specific user parameters changing in that main assembly.&amp;nbsp; Then this rule will need to be able to identify which parameter is for which component, so that when you loop through the components, it will know which parameter to get the ModelState name from to assign to the component.&amp;nbsp; This is just a game plan for the project.&amp;nbsp; One additional tool you may or may not need to help in this task, is a rule that will loop through those components first, get their list of available ModelState names, and write them to the multi-value parameters in your main assembly.&amp;nbsp; Then if you continue to develop any of those components and add or subtract from those ModelStates, you would need to run this rule again to update the parameters multi-value lists, or update them manually.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 12:26:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10703774#M44368</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-10-21T12:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10704305#M44369</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10796286"&gt;@frahaman7SKBG&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you're looking for something like this? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can create a multivalue parameter, in my case named ModelStates and have a rule that tries to update all the occurrences modelstates in the assembly to that parameters value.&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN style="color: #ce5c95;"&gt;Sub&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;Main&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;oAsm&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN style="color: #9d6bce;"&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #9d6bce;"&gt;Document&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;oDef&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;AssemblyComponentDefinition&lt;/SPAN&gt; = &lt;SPAN style="color: #db9652;"&gt;oAsm&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;For&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;Each&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;oOcc&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;ComponentOccurrence&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;In&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;oDef&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;Occurrences&lt;/SPAN&gt;
	&lt;SPAN style="color: #ce5c95;"&gt;Try&lt;/SPAN&gt;
		&lt;SPAN style="color: #db9652;"&gt;ChangeState&lt;/SPAN&gt;(&lt;SPAN style="color: #db9652;"&gt;oOcc&lt;/SPAN&gt;, &lt;SPAN style="color: #5178c8;"&gt;ModelStates&lt;/SPAN&gt;)
	&lt;SPAN style="color: #ce5c95;"&gt;Catch&lt;/SPAN&gt;
	&lt;SPAN style="color: #ce5c95;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;Try&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;Next&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;Sub&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;Sub&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;ChangeState&lt;/SPAN&gt;(&lt;SPAN style="color: #db9652;"&gt;occ&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #db9652;"&gt;ComponentOccurrence&lt;/SPAN&gt;, &lt;SPAN style="color: #db9652;"&gt;stateName&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;String&lt;/SPAN&gt;)
	&lt;SPAN style="color: #db9652;"&gt;occ&lt;/SPAN&gt;.&lt;SPAN style="color: #db9652;"&gt;ActiveModelState&lt;/SPAN&gt; = &lt;SPAN style="color: #db9652;"&gt;stateName&lt;/SPAN&gt;
&lt;SPAN style="color: #ce5c95;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ce5c95;"&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 15:12:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10704305#M44369</guid>
      <dc:creator>JhoelForshav</dc:creator>
      <dc:date>2021-10-21T15:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10704309#M44370</link>
      <description>&lt;P&gt;I forgot to add the screencast&lt;/P&gt;
&lt;DIV id="9eecf990-cc6f-494d-961d-58e96990bbbd" class="myscreencast-iframe iframe-container active-myscreencast"&gt;&lt;IFRAME src="https://screencast.autodesk.com/Embed/Timeline/9eecf990-cc6f-494d-961d-58e96990bbbd" width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/9eecf990-cc6f-494d-961d-58e96990bbbd"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="970e24bf-a716-49ec-82a7-605df39c4b7a" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/970e24bf-a716-49ec-82a7-605df39c4b7a"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="3a5e4bfe-0168-4859-9d90-9348596e5086" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/3a5e4bfe-0168-4859-9d90-9348596e5086"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="59946e59-3a9c-49e7-ad70-b3473af0f493" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/59946e59-3a9c-49e7-ad70-b3473af0f493"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="9b158824-a9fa-4f9d-8c87-ab130feb4f61" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/9b158824-a9fa-4f9d-8c87-ab130feb4f61"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="7100e33a-e0ce-4101-b9d2-9afca8f9e518" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/7100e33a-e0ce-4101-b9d2-9afca8f9e518"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="615cc502-ed6a-42b9-81e3-f7d7d24351dc" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/615cc502-ed6a-42b9-81e3-f7d7d24351dc"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="00c8db1e-7bdf-405e-b24f-b5be5d4c1852" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/00c8db1e-7bdf-405e-b24f-b5be5d4c1852"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="b73ec756-e590-4b53-b136-74986cab4bdf" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/b73ec756-e590-4b53-b136-74986cab4bdf"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="d5878df2-4317-404f-a8e9-218e4e0baac8" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/d5878df2-4317-404f-a8e9-218e4e0baac8"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="aed7437b-cb92-49ef-9dbb-9b2c45389316" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/aed7437b-cb92-49ef-9dbb-9b2c45389316"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="ebf47c71-404c-4350-845a-640c4a0e7484" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/ebf47c71-404c-4350-845a-640c4a0e7484"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="1b9a114e-d5e6-4bb2-a340-772b4f1eeeee" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/1b9a114e-d5e6-4bb2-a340-772b4f1eeeee"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="ebefc64e-9243-4d20-9ba0-94d08e3aec04" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/ebefc64e-9243-4d20-9ba0-94d08e3aec04"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="e3e51d2a-fdab-42a4-9a5b-12d371d64e60" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="680" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/e3e51d2a-fdab-42a4-9a5b-12d371d64e60"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="1168a742-a54a-47e4-8e5c-c8fdde6e56de" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/1168a742-a54a-47e4-8e5c-c8fdde6e56de"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="63932171-3b59-4079-a504-bea3be54e549" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="680" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/63932171-3b59-4079-a504-bea3be54e549"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="85b3b9d4-b3c3-451f-bdef-15d437388dc2" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/85b3b9d4-b3c3-451f-bdef-15d437388dc2"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="08325df6-be52-4d4c-8378-f91f70d18459" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/08325df6-be52-4d4c-8378-f91f70d18459"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="0f11fb60-7d73-4b7d-9fb2-7fc3f9464d79" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/0f11fb60-7d73-4b7d-9fb2-7fc3f9464d79"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="699b7d53-4392-4a66-a7ea-64f2bba771c9" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/699b7d53-4392-4a66-a7ea-64f2bba771c9"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="27267123-5435-4abc-9826-37debb103ac1" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/27267123-5435-4abc-9826-37debb103ac1"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="281bed07-1468-4ec1-875c-a4669be8cdd4" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/281bed07-1468-4ec1-875c-a4669be8cdd4"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="5f902d27-94e1-4964-8d9f-c316b59bd0ac" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/5f902d27-94e1-4964-8d9f-c316b59bd0ac"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="4fb7ce56-87d5-46c8-af62-a7e46f739e14" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/4fb7ce56-87d5-46c8-af62-a7e46f739e14"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="11907bac-4f19-4912-b02e-5d8c0f5b8e3f" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/11907bac-4f19-4912-b02e-5d8c0f5b8e3f"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="8227e8e8-2fce-42df-8294-feb011d9ab6b" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="620" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/8227e8e8-2fce-42df-8294-feb011d9ab6b"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="9af033da-61df-49d2-a601-021c93ce87b5" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/9af033da-61df-49d2-a601-021c93ce87b5"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="22f8c13a-0b3d-4e17-8ded-93ee8bb7fee0" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="590" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/22f8c13a-0b3d-4e17-8ded-93ee8bb7fee0"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;
&lt;DIV id="dcd5500e-62bc-4b32-8355-54e1975d9048" class="myscreencast-iframe iframe-container" style="display: none;"&gt;&lt;IFRAME width="640" height="650" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" data-src="https://screencast.autodesk.com/Embed/Timeline/dcd5500e-62bc-4b32-8355-54e1975d9048"&gt;&lt;/IFRAME&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 21 Oct 2021 15:13:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10704309#M44370</guid>
      <dc:creator>JhoelForshav</dc:creator>
      <dc:date>2021-10-21T15:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10705536#M44371</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;@&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5330176" target="_self"&gt;&lt;SPAN class="login-bold"&gt;JhoelForshav, but for some reason your code does nothing.&amp;nbsp;&lt;/SPAN&gt;&lt;/A&gt;However, I was able to come up with a solution that seem to be doing the task I wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I first use one rule to take user input to capture the new Model State and place it as a custom iProperty and then use another rule to push this custom iProperty that has a new Model State name to all the sub-assemblies and parts. I have added a rule to all the sub-assemblies and parts to change Model State to what the custom iProperty has. And then I run another rule in my man assembly that runs this rule that is on each individual part. Below are snippets of all the rules. Let me know if there is a faster/better way of doing this.&lt;/P&gt;&lt;P&gt;Let me know if my explanation makes sense, can do a screencast to show how it works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 1:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;'Promt the user for the value of a variable&lt;/SPAN&gt;
&lt;SPAN&gt;modelstate&lt;/SPAN&gt; = &lt;SPAN&gt;InputBox&lt;/SPAN&gt;(&lt;SPAN&gt;"Please Enter the Model Sate Here"&lt;/SPAN&gt;, &lt;SPAN&gt;"Custom Property Input Box"&lt;/SPAN&gt;, &lt;SPAN&gt;"Eg. 21017-xxx"&lt;/SPAN&gt;)

&lt;SPAN&gt;'assign the value of that variable to a custom property&lt;/SPAN&gt;
&lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Custom"&lt;/SPAN&gt;, &lt;SPAN&gt;"Model_State:"&lt;/SPAN&gt;) = &lt;SPAN&gt;modelstate&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Step 2:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;
&lt;SPAN&gt;'Gets the Active Document&lt;/SPAN&gt;
&lt;SPAN&gt;oDoc&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;

&lt;SPAN&gt;'Saves this document&lt;/SPAN&gt;
&lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Save&lt;/SPAN&gt;

&lt;SPAN&gt;'Checks if the active document is an assembly&lt;/SPAN&gt;
&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;DocumentType&lt;/SPAN&gt; = &lt;SPAN&gt;kAssemblyDocumentObject&lt;/SPAN&gt;
	&lt;SPAN&gt;'Gets the assembly occurrences&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOccs&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrences&lt;/SPAN&gt;
	&lt;SPAN&gt;oOccs&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN&gt;Occurrences&lt;/SPAN&gt;
	&lt;SPAN&gt;'Call the subprocedure to traverse the assembly&lt;/SPAN&gt;
	&lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;TraverseAssembly&lt;/SPAN&gt;(&lt;SPAN&gt;oOccs&lt;/SPAN&gt;)
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;

&lt;SPAN&gt;'***************&lt;/SPAN&gt;
&lt;SPAN&gt;Public&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;TraverseAssembly&lt;/SPAN&gt;(&lt;SPAN&gt;oOccs&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrences&lt;/SPAN&gt;)
 &lt;SPAN&gt;'Integer to traverse the assembly occurrences&lt;/SPAN&gt;
 &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;i&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt;
 
 &lt;SPAN&gt;'For i=1 To oOccs.Count&lt;/SPAN&gt;
  &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt;
&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oOccs&lt;/SPAN&gt;
  &lt;SPAN&gt;'oOcc = oOccs.Item(i)  &lt;/SPAN&gt;
 	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Suppressed&lt;/SPAN&gt; = &lt;SPAN&gt;False&lt;/SPAN&gt;
   
		&lt;SPAN&gt;'Occurrence Name (Display Name)&lt;/SPAN&gt;
		&lt;SPAN&gt;oOccName&lt;/SPAN&gt; = &lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt;
		
		&lt;SPAN&gt;'Gets the first three leters of the Occurrence Name (e.g. "STK")&lt;/SPAN&gt;
		&lt;SPAN&gt;oOccPrefix&lt;/SPAN&gt; = &lt;SPAN&gt;Left&lt;/SPAN&gt;(&lt;SPAN&gt;oOccName&lt;/SPAN&gt;, 3)
		
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oOccPrefix&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN&gt;"STK"&lt;/SPAN&gt;
		
			&lt;SPAN&gt;Try&lt;/SPAN&gt;
&lt;SPAN&gt;'				&lt;/SPAN&gt;
				&lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;oOccName&lt;/SPAN&gt;, &lt;SPAN&gt;"Custom"&lt;/SPAN&gt;, &lt;SPAN&gt;"Model_State:"&lt;/SPAN&gt;) = &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Custom"&lt;/SPAN&gt;, &lt;SPAN&gt;"Model_State:"&lt;/SPAN&gt;)
			
				
			&lt;SPAN&gt;Catch&lt;/SPAN&gt;
				&lt;SPAN&gt;'It won't be able to change Read-Only parts (e.g. Content Center)&lt;/SPAN&gt;
				&lt;SPAN&gt;'MessageBox.Show("This is a content center file: " &amp;amp; oOcc.Name, "Title")&lt;/SPAN&gt;
			&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Try&lt;/SPAN&gt;
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;DefinitionDocumentType&lt;/SPAN&gt; = &lt;SPAN&gt;kAssemblyDocumentObject&lt;/SPAN&gt;
			&lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;TraverseAssembly&lt;/SPAN&gt;(&lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;SubOccurrences&lt;/SPAN&gt;)
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
&lt;SPAN&gt;Next&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 3:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;
&lt;SPAN&gt;auto&lt;/SPAN&gt; = &lt;SPAN&gt;iLogicVb&lt;/SPAN&gt;.&lt;SPAN&gt;Automation&lt;/SPAN&gt;

&lt;SPAN&gt;' Set Rule name&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;ruleName&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;
&lt;SPAN&gt;ruleName&lt;/SPAN&gt; = &lt;SPAN&gt;"Update_Model_State"&lt;/SPAN&gt;

&lt;SPAN&gt;' Get the active assembly. &lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oAsmDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyDocument&lt;/SPAN&gt; 
&lt;SPAN&gt;oAsmDoc&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt; 

&lt;SPAN&gt;' Get all of the referenced documents. &lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oRefDocs&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DocumentsEnumerator&lt;/SPAN&gt; 
&lt;SPAN&gt;oRefDocs&lt;/SPAN&gt; = &lt;SPAN&gt;oAsmDoc&lt;/SPAN&gt;.&lt;SPAN&gt;AllReferencedDocuments&lt;/SPAN&gt; 

&lt;SPAN&gt;' Iterate through the list of documents. &lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oRefDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Document&lt;/SPAN&gt; 

&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oRefDoc&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oRefDocs&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;rule&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Object&lt;/SPAN&gt;
	&lt;SPAN&gt;rule&lt;/SPAN&gt; = &lt;SPAN&gt;auto&lt;/SPAN&gt;.&lt;SPAN&gt;GetRule&lt;/SPAN&gt;(&lt;SPAN&gt;oRefDoc&lt;/SPAN&gt;, &lt;SPAN&gt;ruleName&lt;/SPAN&gt;)
	&lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;rule&lt;/SPAN&gt; &lt;SPAN&gt;Is&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt;) &lt;SPAN&gt;Then&lt;/SPAN&gt;
&lt;SPAN&gt;'	Call MsgBox("No rule named " &amp;amp; ruleName &amp;amp; " was found in the document.")&lt;/SPAN&gt;
	&lt;SPAN&gt;Else&lt;/SPAN&gt;
&lt;SPAN&gt;'	MessageBox.Show(rule.Name, oRefDoc.DisplayName)&lt;/SPAN&gt;
	
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;i&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt;
	&lt;SPAN&gt;i&lt;/SPAN&gt; = &lt;SPAN&gt;auto&lt;/SPAN&gt;.&lt;SPAN&gt;RunRuleDirect&lt;/SPAN&gt;(&lt;SPAN&gt;rule&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;Next&lt;/SPAN&gt; 
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Here is the rule that is in the individual parts:&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;doc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;comp&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DerivedPartComponent&lt;/SPAN&gt; = &lt;SPAN&gt;doc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN&gt;ReferenceComponents&lt;/SPAN&gt;.&lt;SPAN&gt;DerivedPartComponents&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(1)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;derivedDef&lt;/SPAN&gt; = &lt;SPAN&gt;comp&lt;/SPAN&gt;.&lt;SPAN&gt;Definition&lt;/SPAN&gt;
&lt;SPAN&gt;Logger&lt;/SPAN&gt;.&lt;SPAN&gt;Info&lt;/SPAN&gt;(&lt;SPAN&gt;"current model state = {0}"&lt;/SPAN&gt;, &lt;SPAN&gt;derivedDef&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveModelState&lt;/SPAN&gt;)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;stateWanted&lt;/SPAN&gt; = &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Custom"&lt;/SPAN&gt;, &lt;SPAN&gt;"Model_State:"&lt;/SPAN&gt;)
&lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;derivedDef&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveModelState&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN&gt;stateWanted&lt;/SPAN&gt;) &lt;SPAN&gt;Then&lt;/SPAN&gt;
	&lt;SPAN&gt;derivedDef&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveModelState&lt;/SPAN&gt; = &lt;SPAN&gt;stateWanted&lt;/SPAN&gt;
	&lt;SPAN&gt;comp&lt;/SPAN&gt;.&lt;SPAN&gt;Definition&lt;/SPAN&gt; = &lt;SPAN&gt;derivedDef&lt;/SPAN&gt; &lt;SPAN&gt;' apply the modified definition back to the DerivedPartComponent&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 02:02:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10705536#M44371</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2021-10-22T02:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10706621#M44372</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10796286"&gt;@frahaman7SKBG&lt;/a&gt;.&amp;nbsp; Most of your code looks OK at first glance, but there was one point in 'Step 2' code that I saw that I believe will need to be changed.&amp;nbsp; You are using a Sub routine in that rule that accepts a &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-729F272D-821C-4DFF-B604-8C89035D6D88" target="_blank" rel="noopener"&gt;ComponentOccurrences&lt;/A&gt; object as its input variable.&amp;nbsp; You are using this properly the first time, within your main Sub of that rule, but within that 'TraverseAssembly' Sub itself, where it calls itself again, you are supplying it with a &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-B94A953F-EFB7-4177-BF6D-237B2691A67B" target="_blank" rel="noopener"&gt;ComponentOccurrencesEnumerator&lt;/A&gt; object, which I don't think will work.&amp;nbsp; You should get the ComponentOccurrences from that assembly type component's definition, and use that as input for that Sub routine, similarly to how you did in the main Sub part of that rule instead.&amp;nbsp; Does that make sense to you?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 12:38:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10706621#M44372</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-10-22T12:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10710715#M44373</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;, Thanks for your response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not an expert in iLogic in any capacity. Most of my codes are taken as snippets from various forums and modified slightly to suit my needs. I think I understand what you are saying, but I don't have the in-depth knowledge on how to put it in code format. Would you be able to provide me with a snippet that I can use? Thank you for all your wonderful help and suggestion.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 03:22:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10710715#M44373</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2021-10-25T03:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10711618#M44374</link>
      <description>&lt;P&gt;Sure.&amp;nbsp; This is just a slight update to the code you posted in your 'Step 2' above.&lt;/P&gt;
&lt;P&gt;Mainly I just changed this line:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Call TraverseAssembly(oOcc.SubOccurrences)&lt;/LI-CODE&gt;
&lt;P&gt;to this:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;TraverseAssembly(oOcc.Definition.Occurrences)&lt;/LI-CODE&gt;
&lt;P&gt;Because oOcc.SubOccurrences returns a ComponentOccurrencesEnumerator object, and the&amp;nbsp; oOcc.Definition.Occurrences returns a ComponentOccurrences object, which matches the Type of the input variable specified in the definition line of the TraverseAssembly Sub routine.&amp;nbsp; Also you don't really need to include the term 'Call' in front of those lines in iLogic.&amp;nbsp; That is more for use in a VBA macro.&lt;/P&gt;
&lt;P&gt;Here is the whole thing again, just to be clear.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	'Gets the 'local' document (the one this rule is saved within)
	'or the document that was 'Active' when the rule started
	oDoc = ThisDoc.Document
	'Saves this document
	oDoc.Save
	'Checks if the active document is an assembly
	If oDoc.DocumentType = kAssemblyDocumentObject
		'Gets the assembly occurrences
		Dim oOccs As ComponentOccurrences = oDoc.ComponentDefinition.Occurrences
		'Call the subprocedure to traverse the assembly
		TraverseAssembly(oOccs)
	End If
End Sub

'***************
Public Sub TraverseAssembly(oOccs As ComponentOccurrences)
	Dim oOcc As ComponentOccurrence
	For Each oOcc In oOccs
		If oOcc.Suppressed = False Then
			'Occurrence Name (Display Name)
			oOccName = oOcc.Name
			'Gets the first three leters of the Occurrence Name (e.g. "STK")
			oOccPrefix = Left(oOccName, 3)
			If oOccPrefix &amp;lt;&amp;gt; "STK" Then
				Try	
					iProperties.Value(oOccName, "Custom", "Model_State:") = iProperties.Value("Custom", "Model_State:")
				Catch
					'It won't be able to change Read-Only parts (e.g. Content Center)
					'MessageBox.Show("This is a content center file: " &amp;amp; oOcc.Name, "Title")
				End Try
			End If
			If oOcc.DefinitionDocumentType = kAssemblyDocumentObject
				TraverseAssembly(oOcc.Definition.Occurrences)
			End If
		End If
	Next
End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 25 Oct 2021 12:26:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10711618#M44374</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-10-25T12:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10712193#M44375</link>
      <description>Thank you &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;</description>
      <pubDate>Mon, 25 Oct 2021 16:05:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/10712193#M44375</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2021-10-25T16:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/11823684#M44376</link>
      <description>&lt;P&gt;Ok, so I think I need to figure this out for a project.&lt;/P&gt;&lt;P&gt;I have a multibody part that drives a Main Assembly, I need to be able to switch model states on each part via ONE main switch in the Main Assembly.&amp;nbsp; &amp;nbsp; But I'm not sure where to put each part of these codes?&amp;nbsp; IE what code needs to be in the multibody part? What needs to be in the Main Assembly?&amp;nbsp; What needs to be in each part?&lt;/P&gt;&lt;P&gt;Thanks in advance for any insight and assistance.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 16:53:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/11823684#M44376</guid>
      <dc:creator>esimers</dc:creator>
      <dc:date>2023-03-15T16:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12169251#M44377</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;STRONG&gt;Jhoel Forshav,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;that works great but have some question about. I do have 3 MS in part level and 3 in assembly. They named same.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;When i switching MS from assembly it is working just as supposed. When using you rule there is no error but it changed on assembly level but not on part level. It is not in sinc. Could you help i would like to change as you present in video which is working awsome.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 10:23:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12169251#M44377</guid>
      <dc:creator>GosponZ</dc:creator>
      <dc:date>2023-08-14T10:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12169435#M44378</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1097622"&gt;@GosponZ&lt;/a&gt;.&amp;nbsp; It sounds like you are wanting to simulate the 'Link ModelStates' tool, but from an iLogic rule, is that correct?&amp;nbsp; If so, then the only thing you would likely need to add to the routine is to loop through each of the main assembly's ModelStates, activate it, then loop the components, trying to set them to a ModelState with the same name as the currently active assembly ModelState.&amp;nbsp; I posted an example of this process last year at the following link:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-to-link-model-states-in-an-assembly-via-ilogic-or-vba/m-p/11515210/highlight/true#M144443" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-to-link-model-states-in-an-assembly-via-ilogic-or-vba/m-p/11515210/highlight/true#M144443&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I would probably enclose that one line that is trying to set the ModelState of components within a Try...Catch block, to avoid the potential errors that would occur when the component does not have a ModelState available to it with the same name.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Try : oOcc.ActiveModelState = oMS.Name : Catch : End Try&lt;/LI-CODE&gt;
&lt;P&gt;...and I would likely change the oADoc.Update to oADoc.Update2(True).&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 11:50:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12169435#M44378</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-08-14T11:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12169870#M44379</link>
      <description>&lt;P&gt;Thank you for fast answer. I tried all possible ways i cold think off but no success. So again 3&amp;nbsp; text parameters. 3 ms part level and 3 ms in assembly. Would like to change thru form like in above example.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 14:48:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12169870#M44379</guid>
      <dc:creator>GosponZ</dc:creator>
      <dc:date>2023-08-14T14:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12178679#M44380</link>
      <description>&lt;P&gt;Anybody try?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 19:27:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12178679#M44380</guid>
      <dc:creator>GosponZ</dc:creator>
      <dc:date>2023-08-17T19:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12860757#M44381</link>
      <description>&lt;P&gt;IS there any way you can make this iterate through sub assemblies and any opart driven by a muitl solid so the shildren change when i change the model state in the assembly so that the children from the multibody change to the same. CAn't find a way to edit derived part and make all of the model states match so i can use the top level assembly in mutiple states. Basically the children do not change when i change the model state of the assembly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 17:54:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12860757#M44381</guid>
      <dc:creator>t_fransman</dc:creator>
      <dc:date>2024-06-25T17:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12860883#M44382</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5834641"&gt;@t_fransman&lt;/a&gt;.&amp;nbsp; Unfortunately I do not have time to tackle this one today, but hopefully I can get back here to work on this tomorrow, if I don't forget, or get swamped with other stuff.&amp;nbsp; This can certainly be a pretty complex task to automate properly.&amp;nbsp; And controlling that many levels of ModelStates in an assembly is not really something that I have ever needed to deal with where I work, especially where derived parts are involved (or skeleton modeling in an assembly).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dealt with first level components before, as you can see in the article I had a link to above, but perpetuating a top level ModelState change down to lower levels is more complicated, and would require the use of a 'recursive' Sub routine.&amp;nbsp; One important factor in this type of routine is how you step down into each lower level.&amp;nbsp; We can either use &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ComponentOccurrence_SubOccurrences" target="_blank" rel="noopener"&gt;ComponentOccurrence.SubOccurrences&lt;/A&gt;&amp;nbsp;property, or we can use ComponentOccurrence.Definition.Occurrences property.&amp;nbsp; Which one you use can make a big difference, because it changes 'context'.&amp;nbsp; Using SubOccurrences tends to keep the context 'as seen by the main assembly', while the other is more strict, only making changes within the definitions of those other referenced documents.&amp;nbsp; One thing that may need to be included in a process like this is saving these ModelState status changes at each level of the assembly, within that parent assembly's active ModelState.&amp;nbsp; But similar to dealing with view representations, this type of thing is best set up manually, starting with the lowest level parts, then lowest level sub assemblies, then stepping up the assembly structure until you get to the top level.&amp;nbsp; Trying to do processes like this starting from the top level, then down through multiple levels is very challenging to get to work out correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example codes that&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10796286"&gt;@frahaman7SKBG&lt;/a&gt;&amp;nbsp;posted in Message 5, within the fourth code window, is a similar process that would have to be dealt with to change the ModelState of a derived part.&amp;nbsp; But getting that change to show at the top level of an assembly that this component may be in a lower level of is another challenge.&amp;nbsp; And I do not believe that whatever ModelState was active in the host part will record which ModelState you set the 'derived in' part to, so controlling that at the assembly level is going to be very challenging also, if possible.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 19:05:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12860883#M44382</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-06-25T19:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12860888#M44383</link>
      <description>&lt;P&gt;THANKS BECAUSE THE OTHER CODE SEE MY HARDWARE AND THE FACT I HAVE A COUPLE BASIC WELDMENTS PROBABLY AND CRASHES MY SESSION EVERY TIME.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 19:11:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12860888#M44383</guid>
      <dc:creator>t_fransman</dc:creator>
      <dc:date>2024-06-25T19:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12862109#M44384</link>
      <description>&lt;P&gt;i just can't believe that this is not a fundamental default behavior. Lol&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 10:50:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12862109#M44384</guid>
      <dc:creator>t_fransman</dc:creator>
      <dc:date>2024-06-26T10:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12862554#M44385</link>
      <description>&lt;P&gt;Another issue i am having (that may be easier to fix) is if i add the skeleton to the spreadsheet and make all the matching lines so it changes when a model state is selected at the top level it works but my rules to change number of of holes in the skeleton does not update until i open the skeleton.&amp;nbsp; I've tried many event triggers at the skeleton level&amp;nbsp; to no effect.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 14:18:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12862554#M44385</guid>
      <dc:creator>t_fransman</dc:creator>
      <dc:date>2024-06-26T14:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Code to change between Model State on an Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12862629#M44386</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5834641"&gt;@t_fransman&lt;/a&gt;.&amp;nbsp; I finally found my way back here.&amp;nbsp; I just typed/assembled some code that you can put into a single external iLogic rule for hopefully handling a large part of this task, but I did not leave much in the way of comments or feedback messages in there, because I was in a hurry.&amp;nbsp; The main two things this code will attempt to do is the following:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Get the name of the active ModelState of the main assembly, then recursively iterate through every assembly component, at every level, and attempt to set each of them to that same ModelState, but only if a ModelState by that same name already exists within the file that they are referencing.&amp;nbsp; If any of them are suppressed, or virtual, similar oddity, it will skip over them.&amp;nbsp; This means that if you have a component suppressed that represents a sub assembly, it will not do anything with that component, or any if its sub components.&amp;nbsp; We can not do much with a component that is suppressed.&lt;/LI&gt;
&lt;LI&gt;Get the collection of all referenced documents, iterate through them, if they are a part, check if they have another part derived into them, if so, try to change the ModelState of the 'source' part that is being derived into it.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I am not experienced with 'skeleton' modeling in an assembly, so if that is what you are doing, I may not be able to help much with that aspect of the project.&lt;/P&gt;
&lt;P&gt;The code I have is in the attached text file.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 14:52:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-code-to-change-between-model-state-on-an-assembly/m-p/12862629#M44386</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-06-26T14:52:25Z</dc:date>
    </item>
  </channel>
</rss>

