<?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 Need to change file &amp;amp; active model state in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/need-to-change-file-amp-active-model-state/m-p/12673770#M165618</link>
    <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to change user parameter of assembly &amp;amp; base on that occureence name "GEAR BOX" replace file &amp;amp; active required model state. need help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Sub SetGearandMotor(ByRef TxtGearSize As Windows.Forms.TextBox, ByRef TxtRatio As Windows.Forms.TextBox, ByRef TxtMotorSize As Windows.Forms.TextBox)&lt;BR /&gt;Try&lt;BR /&gt;Dim TextValue As String = TxtGearSize.Text&lt;BR /&gt;Dim TextValue2 As String = TxtMotorSize.Text&lt;BR /&gt;Dim TextValue1 As String = TxtRatio.Text&lt;/P&gt;&lt;P&gt;' Get the assembly document&lt;BR /&gt;Dim oAssDoc As AssemblyDocument = invApp.ActiveDocument&lt;/P&gt;&lt;P&gt;' Replace the component with the new file&lt;BR /&gt;Dim newComponentFilePath As String = "M:\MIXION\LIBRARY\PREFERENCES\GEAR BOX\BONFIGLIOLI MAKE GEAR BOX\"&lt;BR /&gt;Dim Filename As String = $"{TextValue} F P{TextValue2} B5 V1.ipt"&lt;BR /&gt;Dim newStateName As String = $"{Filename}_RATIO_{TextValue1}"&lt;BR /&gt;Dim newFilePathWithState As String = $"{newComponentFilePath}{newStateName}"&lt;/P&gt;&lt;P&gt;' Check if the new file exists&lt;BR /&gt;If Not IO.File.Exists(newFilePathWithState) Then&lt;BR /&gt;MsgBox($"File '{newFilePathWithState}' not found.")&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;' Get the component occurrence by name&lt;BR /&gt;Dim selectedComponent As ComponentOccurrence = Nothing&lt;BR /&gt;For Each occurrence As ComponentOccurrence In oAssDoc.ComponentDefinition.Occurrences&lt;BR /&gt;If occurrence.Name = "GEAR BOX" Then&lt;BR /&gt;selectedComponent = occurrence&lt;BR /&gt;Exit For&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;' Check if the component occurrence was found&lt;BR /&gt;If selectedComponent Is Nothing Then&lt;BR /&gt;MsgBox("Component occurrence 'GEAR BOX' not found.")&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;' Replace the component&lt;BR /&gt;selectedComponent.Replace(newFilePathWithState, True)&lt;/P&gt;&lt;P&gt;' Activate the new occurrence&lt;BR /&gt;Dim newOccurrence As ComponentOccurrence = oAssDoc.ComponentDefinition.Occurrences.ItemByName(newStateName)&lt;BR /&gt;If newOccurrence IsNot Nothing Then&lt;BR /&gt;newOccurrence.Activate()&lt;BR /&gt;Else&lt;BR /&gt;MsgBox("New occurrence not found.")&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Catch ex As Exception&lt;BR /&gt;MsgBox("Error setting gear and motor: " &amp;amp; ex.Message)&lt;BR /&gt;End Try&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dhaval&lt;/P&gt;</description>
    <pubDate>Fri, 29 Mar 2024 06:13:45 GMT</pubDate>
    <dc:creator>dhaval3112</dc:creator>
    <dc:date>2024-03-29T06:13:45Z</dc:date>
    <item>
      <title>Need to change file &amp; active model state</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/need-to-change-file-amp-active-model-state/m-p/12673770#M165618</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to change user parameter of assembly &amp;amp; base on that occureence name "GEAR BOX" replace file &amp;amp; active required model state. need help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Sub SetGearandMotor(ByRef TxtGearSize As Windows.Forms.TextBox, ByRef TxtRatio As Windows.Forms.TextBox, ByRef TxtMotorSize As Windows.Forms.TextBox)&lt;BR /&gt;Try&lt;BR /&gt;Dim TextValue As String = TxtGearSize.Text&lt;BR /&gt;Dim TextValue2 As String = TxtMotorSize.Text&lt;BR /&gt;Dim TextValue1 As String = TxtRatio.Text&lt;/P&gt;&lt;P&gt;' Get the assembly document&lt;BR /&gt;Dim oAssDoc As AssemblyDocument = invApp.ActiveDocument&lt;/P&gt;&lt;P&gt;' Replace the component with the new file&lt;BR /&gt;Dim newComponentFilePath As String = "M:\MIXION\LIBRARY\PREFERENCES\GEAR BOX\BONFIGLIOLI MAKE GEAR BOX\"&lt;BR /&gt;Dim Filename As String = $"{TextValue} F P{TextValue2} B5 V1.ipt"&lt;BR /&gt;Dim newStateName As String = $"{Filename}_RATIO_{TextValue1}"&lt;BR /&gt;Dim newFilePathWithState As String = $"{newComponentFilePath}{newStateName}"&lt;/P&gt;&lt;P&gt;' Check if the new file exists&lt;BR /&gt;If Not IO.File.Exists(newFilePathWithState) Then&lt;BR /&gt;MsgBox($"File '{newFilePathWithState}' not found.")&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;' Get the component occurrence by name&lt;BR /&gt;Dim selectedComponent As ComponentOccurrence = Nothing&lt;BR /&gt;For Each occurrence As ComponentOccurrence In oAssDoc.ComponentDefinition.Occurrences&lt;BR /&gt;If occurrence.Name = "GEAR BOX" Then&lt;BR /&gt;selectedComponent = occurrence&lt;BR /&gt;Exit For&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;' Check if the component occurrence was found&lt;BR /&gt;If selectedComponent Is Nothing Then&lt;BR /&gt;MsgBox("Component occurrence 'GEAR BOX' not found.")&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;' Replace the component&lt;BR /&gt;selectedComponent.Replace(newFilePathWithState, True)&lt;/P&gt;&lt;P&gt;' Activate the new occurrence&lt;BR /&gt;Dim newOccurrence As ComponentOccurrence = oAssDoc.ComponentDefinition.Occurrences.ItemByName(newStateName)&lt;BR /&gt;If newOccurrence IsNot Nothing Then&lt;BR /&gt;newOccurrence.Activate()&lt;BR /&gt;Else&lt;BR /&gt;MsgBox("New occurrence not found.")&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Catch ex As Exception&lt;BR /&gt;MsgBox("Error setting gear and motor: " &amp;amp; ex.Message)&lt;BR /&gt;End Try&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dhaval&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2024 06:13:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/need-to-change-file-amp-active-model-state/m-p/12673770#M165618</guid>
      <dc:creator>dhaval3112</dc:creator>
      <dc:date>2024-03-29T06:13:45Z</dc:date>
    </item>
  </channel>
</rss>

