<?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 to create several model states and assign custom iproperty for each model state in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023265#M153773</link>
    <description>&lt;P&gt;Each ModelState can have it's own Part Number and other iProperties.&lt;/P&gt;&lt;P&gt;Edit them in MemberScrope and they will be different.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 15:59:35 GMT</pubDate>
    <dc:creator>Frederick_Law</dc:creator>
    <dc:date>2023-06-09T15:59:35Z</dc:date>
    <item>
      <title>iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023000#M153763</link>
      <description>&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;Edit - I decided to go a different direction. No need for the help on this one. Thanks all for looking!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hey everyone, we just upgraded to Inventor 2022 from 2020 and enjoying model states capability. I've been reading over a few threads and snippets that others have written. Some of them capture a small aspect of what I'm trying to do but I can't seem to pull it all together and functioning. I was hoping this thread would get me close to what I need but so far it only creates a model state for the top level assembly and we don't need dialog boxes just yet&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/example-create-and-activate-model-states-in-the-assembly-and/td-p/10391500" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/example-create-and-activate-model-states-in-the-assembly-and/td-p/10391500&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Previously in 2020 Inventor, we were using a simple snippet to combine the part number iproperty with a "-N" or "-G" etc text but with Model States I'm hoping we can make this even better. Here is the code we were using which is very simple as you can see:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;iProperties.Value("Custom", "Finished part number") = iProperties.Value("Project", "Part Number") &amp;amp; "-N"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to do is create an ilogic rule to run on our legacy Inventor 2020 files that will create several model states. I want to the ilogic code to create a string of model states, fetch the Master model state iproperty and populate it into each new model state's part number iproperty but add a suffix of the model state name at the end of the part number.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To give some info on what these values mean. -N is natural metal finish, -G is galvanized part, L-N is a left-hand natural metal finish part,&amp;nbsp; L-G is a left-hand galvanized part, R-N is a right-hand natural metal finish part,&amp;nbsp; R-G is a right-hand galvanized part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I need to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Automatically create "-N", "-G", "L-N", "L-R", "R-N", and "R-G" model states on each part or assembly file&lt;/LI&gt;&lt;LI&gt;Populate each new model state part number iproperty with the same&amp;nbsp;part number iproperty as the Master model state and then add a suffix to the part number of each model state that contains the model state's name&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hope that all makes sense. If not here are some pictures showing what I'm trying to achieve...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Model States:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="model states.jpg" style="width: 239px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1225604iA90B934460069474/image-size/large?v=v2&amp;amp;px=999" role="button" title="model states.jpg" alt="model states.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Master Model State Part Number iproperty:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MASTER IPROP.jpg" style="width: 779px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1226380i02EAA46D319A2E17/image-size/large?v=v2&amp;amp;px=999" role="button" title="MASTER IPROP.jpg" alt="MASTER IPROP.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;-N Model State Part Number iproperty needs to read as:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="-N IPROP.jpg" style="width: 772px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1226385iBF7C91330D009278/image-size/large?v=v2&amp;amp;px=999" role="button" title="-N IPROP.jpg" alt="-N IPROP.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;L-N Model State Part Number iproperty needs to read as:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="L-N IPROP.jpg" style="width: 770px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1226386iA1E97E7D69399DF3/image-size/large?v=v2&amp;amp;px=999" role="button" title="L-N IPROP.jpg" alt="L-N IPROP.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 21:27:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023000#M153763</guid>
      <dc:creator>kwilson_design</dc:creator>
      <dc:date>2023-06-12T21:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023028#M153764</link>
      <description>&lt;P&gt;You can get some insight here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/modelstate-ilogic-form-text-did-not-update/td-p/12018616" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/modelstate-ilogic-form-text-did-not-update/td-p/12018616&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13518190"&gt;@Andrii_Humeniuk&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:08:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023028#M153764</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-06-09T15:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023094#M153767</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5289378"&gt;@Frederick_Law&lt;/a&gt;&amp;nbsp;thanks for the link. Looking into it I've tried to modify it for what I'm trying to achieve but running into errors. I'm sure I haven't coded this correctly lol.&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="error1.jpg" style="width: 731px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1225633iF9233DB66C295BA1/image-size/large?v=v2&amp;amp;px=999" role="button" title="error1.jpg" alt="error1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&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;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&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;oCompDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oModelStates&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ModelStates&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oModelState&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ModelState&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOccu&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOccuDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOccuDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Document&lt;/SPAN&gt;
	&lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"-N"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) = &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"Master"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;)
	&lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"-G"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) = &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"Master"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;)
	&lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"L-N"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) = &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"Master"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;)
	&lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"L-G"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) = &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"Master"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;)
	&lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"R-N"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) = &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"Master"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;)
	&lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"R-G"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) = &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"Master"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&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;"Finished part number"&lt;/SPAN&gt;) = &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) &amp;amp; &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"-N"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&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;"Finished part number"&lt;/SPAN&gt;) = &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) &amp;amp; &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"-G"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&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;"Finished part number"&lt;/SPAN&gt;) = &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) &amp;amp; &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"L-N"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&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;"Finished part number"&lt;/SPAN&gt;) = &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) &amp;amp; &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"L-G"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&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;"Finished part number"&lt;/SPAN&gt;) = &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) &amp;amp; &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"R-N"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&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;"Finished part number"&lt;/SPAN&gt;) = &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&lt;/SPAN&gt;(&lt;SPAN&gt;"Project"&lt;/SPAN&gt;, &lt;SPAN&gt;"Part Number"&lt;/SPAN&gt;) &amp;amp; &lt;SPAN&gt;oModelState&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &lt;SPAN&gt;"R-G"&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;.&lt;SPAN&gt;Value&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;</description>
      <pubDate>Fri, 09 Jun 2023 14:47:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023094#M153767</guid>
      <dc:creator>kwilson_design</dc:creator>
      <dc:date>2023-06-09T14:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023155#M153769</link>
      <description>&lt;P&gt;Here is something you can try out.&amp;nbsp; I modified this from something I already had, in an attempt to suit your needs.&amp;nbsp; There are several ways to do something like this.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oDoc As Document = ThisDoc.FactoryDocument
	If oDoc Is Nothing OrElse ((Not TypeOf oDoc Is PartDocument) And (Not TypeOf oDoc Is AssemblyDocument)) Then
		MessageBox.Show("This code only works for a Part or Assembly.", "Wrong Document Type")
		Exit Sub
	End If
	If oDoc.IsModifiable = False Then Exit Sub
	'make sure the custom iProperty exists (then it will exist for all ModelStates)
	'first get a reference to the custom property set
	Dim oPNProp As Inventor.Property = oDoc.PropertySets.Item(3).Item("Part Number")
	Dim sPN As String 'this will hold the regular Part Number value later
	Dim oCProps As Inventor.PropertySet = oDoc.PropertySets.Item(4)
	'now create a variable to hold the custom property
	Dim oCProp As Inventor.Property = Nothing
	Try 'try to find existing one
		oCProp = oCProps.Item("Finished part number")
	Catch 'that failed, so create it
		oCProp = oCProps.Add("", "Finished part number")
	End Try
	If oCProp Is Nothing Then Exit Sub 'couldn't find or create the custom iProperty so exit rule
	Dim oMSs As ModelStates = oDoc.ComponentDefinition.ModelStates
	If oMSs.MemberEditScope &amp;lt;&amp;gt; MemberEditScopeEnum.kEditActiveMember Then
		oMSs.MemberEditScope = MemberEditScopeEnum.kEditActiveMember
	End If
	'make sure 'master/primary' ModelState is active, to get Part Number value from
	If oMSs.ActiveModelState IsNot oMSs.Item(1) Then
		oMSs.Item(1).Activate
	End If
	oDoc = oMSs.ActiveModelState.FactoryDocument
	sPN = oPNProp.Value
	Dim oNames() As String = {"-N", "-G", "L-N", "L-R", "R-N", "R-G" }
	For Each sName In oNames
		Dim oThisMS As ModelState = Nothing
		Try
			oThisMS = oMSs.Item(sName)
		Catch
			oThisMS = oMSs.Add(sName)
		End Try
		oThisMS.Activate
		oCProp.Value = sName
		oPNProp.Value = sPN &amp;amp; sName
	Next
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN&gt;&lt;STRONG&gt; ACCEPT SOLUTION &lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7401B55A0A518861312A0F851CD29320/emoticons/1f44d.png" alt=":thumbs_up:" title=":thumbs_up:" /&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:15:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023155#M153769</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-06-09T15:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023203#M153771</link>
      <description>&lt;P&gt;Well after testing model states on an assembly I did not realize the Bill of Materials is primarily driven by part number iProperty to determine how to treat model states and identify or display them as separate parts in a Parts List. Basically all of the model states can't share the same part number or else my assembly parts list shows a single part number field but with multiple QPA or instances. So now I need to rethink this and basically have the model states populate their part number field with the same master part number iProperty plus the corresponding model state. In essence forgo the population of the custom iProperty and instead use that to the part number iProperty field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-06-09 103800.jpg" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1225656i1CAB8C4E2B08A2DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-06-09 103800.jpg" alt="Screenshot 2023-06-09 103800.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-06-09 103956.jpg" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1225657i45C84099C13CE635/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-06-09 103956.jpg" alt="Screenshot 2023-06-09 103956.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-06-09 104019.jpg" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1225658iEC99BFE722382720/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-06-09 104019.jpg" alt="Screenshot 2023-06-09 104019.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:40:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023203#M153771</guid>
      <dc:creator>kwilson_design</dc:creator>
      <dc:date>2023-06-09T15:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023256#M153772</link>
      <description>&lt;P&gt;Actually, I see now that I should have changed a couple of the last lines in the code I posted, because they are not doing what you instructed.&amp;nbsp; The way I posted it, it is setting the custom iProperty to that suffix only, and not the part number plus the suffix, then it is setting the suffix to the end of the regular part number.&amp;nbsp; You wanted the regular part number to remain the same for each ModelState, and only the custom iProperty in each one to include the regular part number plus the suffix.&amp;nbsp; To fix that, just change these two lines near the end:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;oCProp.Value = sName
oPNProp.Value = sPN &amp;amp; sName&lt;/LI-CODE&gt;
&lt;P&gt;...like this:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;oCProp.Value = sPN &amp;amp; sName
oPNProp.Value = sPN&lt;/LI-CODE&gt;
&lt;P&gt;My mistake.&lt;/P&gt;
&lt;P&gt;But yes, your assembly's BOM can only show the contents of one ModelState at a time.&amp;nbsp; Each ModelState is like its own separate Document.&amp;nbsp; So a single file on disk can now have multiple Document definitions within it, with the introduction of ModelStates.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:55:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023256#M153772</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-06-09T15:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023265#M153773</link>
      <description>&lt;P&gt;Each ModelState can have it's own Part Number and other iProperties.&lt;/P&gt;&lt;P&gt;Edit them in MemberScrope and they will be different.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:59:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023265#M153773</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-06-09T15:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023447#M153775</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;Thanks for the snippet. Unfortunately I realized after originally posting that I just need the suffix (model state name) to be added to the corresponding model states' part number iproperty field. I edited your last two lines and it doesn't seem to generate the model states. When I ranit on a template that I already have created the model states, it does populate the finished part number custom iproperty with the model state name but doesn't include the part number. Now that I'm not needing it to write to the custom iproperty and rather write it to the part number iprop of the active model state, where should I alter the code at?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:12:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023447#M153775</guid>
      <dc:creator>kwilson_design</dc:creator>
      <dc:date>2023-06-09T17:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023457#M153776</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5289378"&gt;@Frederick_Law&lt;/a&gt;&amp;nbsp;yes we are using memberscope and I understand tht each model state can have it's own iprops. This is why I'm trying to get the model state name combined with the master part number field and then populate that new combo to the part number field of the corresponding model state.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Model state Master = part number iprop 12345 ("base" part number)&lt;/P&gt;&lt;P&gt;Model state -N =&amp;nbsp;part number iprop&amp;nbsp; 12345-N (the "base" part number is copied from master model state + model state name)&lt;/P&gt;&lt;P&gt;Model state -G =&amp;nbsp;part number iprop 12345-G&amp;nbsp;(the "base" part number is copied from master model state + model state name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and so on. Hope that helps explain.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:18:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12023457#M153776</guid>
      <dc:creator>kwilson_design</dc:creator>
      <dc:date>2023-06-09T17:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to create several model states and assign custom iproperty for each model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12027707#M153830</link>
      <description>&lt;P&gt;Edited the first post with what I'm actually needing to do now that I've tested this through with BOM's and Parts List. Hopefully someone can help me achieve this scripting. Many thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 13:08:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-several-model-states-and-assign-custom/m-p/12027707#M153830</guid>
      <dc:creator>kwilson_design</dc:creator>
      <dc:date>2023-06-12T13:08:58Z</dc:date>
    </item>
  </channel>
</rss>

