<?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: Replace Imported Component in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/replace-imported-component/m-p/11272578#M139918</link>
    <description>&lt;P&gt;It appears that the replace reference mentioned above is not functioning and there is no documented sample to do this, so here is another approach.&amp;nbsp; The&amp;nbsp; manual replace all correctly keeps the reference to an imported component and the import type referenced model. So the below codes simply automates this procedure. Here is the article that references &lt;A href="https://modthemachine.typepad.com/my_weblog/2009/03/" target="_blank" rel="noopener"&gt;running commands.&lt;/A&gt;&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="AAcheson_1-1656713107293.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1086917i45CB2C9B924BCD80/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AAcheson_1-1656713107293.png" alt="AAcheson_1-1656713107293.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AAcheson_0-1656712994563.png" style="width: 403px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1086916i9C1021B18AFD8AFC/image-dimensions/403x504?v=v2" width="403" height="504" role="button" title="AAcheson_0-1656712994563.png" alt="AAcheson_0-1656712994563.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;&lt;PRE&gt;	&lt;SPAN&gt;' Get the command manager.&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;CommandManager&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;
	
	&lt;SPAN&gt;'Pick occurrence&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oAssyoOcc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt; = &lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;SelectionFilterEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kAssemblyOccurrenceFilter&lt;/SPAN&gt;, &lt;SPAN&gt;"Select Occurence"&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;'Select the chosen occurrence for processing&lt;/SPAN&gt;
	&lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;DoSelect&lt;/SPAN&gt;(&lt;SPAN&gt;oAssyoOcc&lt;/SPAN&gt;)
    
	&lt;SPAN&gt;'Clear the clipboard&lt;/SPAN&gt;
	&lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;ClearPrivateEvents&lt;/SPAN&gt;
	
	&lt;SPAN&gt;' Post the filename.&lt;/SPAN&gt;
    &lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;PostPrivateEvent&lt;/SPAN&gt;(&lt;SPAN&gt;PrivateEventTypeEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kFileNameEvent&lt;/SPAN&gt;,&lt;SPAN&gt;"C:\Users\Assembly5.stp"&lt;/SPAN&gt;)

    &lt;SPAN&gt;' Get control definition for the place component command.&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oControlDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ControlDefinition&lt;/SPAN&gt;= &lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;ControlDefinitions&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;"AssemblyReplaceAllCmd"&lt;/SPAN&gt;)

    &lt;SPAN&gt;' Execute the command synchronously. &lt;/SPAN&gt;
    &lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;oControlDef&lt;/SPAN&gt;.&lt;SPAN&gt;Execute2&lt;/SPAN&gt;(&lt;SPAN&gt;True&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jul 2022 22:11:05 GMT</pubDate>
    <dc:creator>A.Acheson</dc:creator>
    <dc:date>2022-07-01T22:11:05Z</dc:date>
    <item>
      <title>Replace Imported Component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/replace-imported-component/m-p/11265226#M139803</link>
      <description>&lt;P&gt;I have an existing Inventor Assembly references a STEP file as a Reference Model. I would like to rename the step file to something else and replace the reference via the API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this was an Inventor document reference it would be straightforward - I can use the Replace method on the ComponentOccurrence(s) that reference the document and be done. However, if it is a referenced STEP file, it appears that ComponentOccurrence.Replace, when provided the name of a STEP file, will&amp;nbsp;&lt;STRONG&gt;convert&amp;nbsp;&lt;/STRONG&gt;the STEP file - it doesn't continue to &lt;STRONG&gt;reference&lt;/STRONG&gt; the STEP file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I can add a new STEP file reference using the AssemblyDocument.ComponentDefinition.ImportedComponents.Add method, but I don't want to add a new one - I want to replace an existing one. Am I missing something or is what I need to do not possible?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 00:10:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/replace-imported-component/m-p/11265226#M139803</guid>
      <dc:creator>ForrestJudd</dc:creator>
      <dc:date>2022-06-29T00:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Imported Component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/replace-imported-component/m-p/11270602#M139896</link>
      <description>&lt;P&gt;&lt;FONT size="3"&gt;Here is a route that might be viable. I haven't tested it to see.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;1.Syntax&lt;/FONT&gt; &lt;FONT size="3"&gt;&lt;SPAN&gt;ImportedComponent.&lt;/SPAN&gt;&lt;STRONG&gt;ReferencedDocumentDescriptor&lt;/STRONG&gt;&lt;SPAN&gt;() As&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=DocumentDescriptor" target="_blank" rel="noopener"&gt;DocumentDescriptor&lt;/A&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;2.Syntax&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;DocumentDescriptor.&lt;/SPAN&gt;&lt;STRONG&gt;ReferencedFileDescriptor&lt;/STRONG&gt;&lt;SPAN&gt;() As&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=FileDescriptor" target="_blank" rel="noopener"&gt;FileDescriptor&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;3.Syntax&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;FileDescriptor.&lt;/SPAN&gt;&lt;STRONG&gt;ReplaceReference&lt;/STRONG&gt;&lt;SPAN&gt;(&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;FullFileName&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;As String )&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 02:59:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/replace-imported-component/m-p/11270602#M139896</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-07-01T02:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Imported Component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/replace-imported-component/m-p/11272578#M139918</link>
      <description>&lt;P&gt;It appears that the replace reference mentioned above is not functioning and there is no documented sample to do this, so here is another approach.&amp;nbsp; The&amp;nbsp; manual replace all correctly keeps the reference to an imported component and the import type referenced model. So the below codes simply automates this procedure. Here is the article that references &lt;A href="https://modthemachine.typepad.com/my_weblog/2009/03/" target="_blank" rel="noopener"&gt;running commands.&lt;/A&gt;&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="AAcheson_1-1656713107293.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1086917i45CB2C9B924BCD80/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AAcheson_1-1656713107293.png" alt="AAcheson_1-1656713107293.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AAcheson_0-1656712994563.png" style="width: 403px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1086916i9C1021B18AFD8AFC/image-dimensions/403x504?v=v2" width="403" height="504" role="button" title="AAcheson_0-1656712994563.png" alt="AAcheson_0-1656712994563.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;&lt;PRE&gt;	&lt;SPAN&gt;' Get the command manager.&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;CommandManager&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;
	
	&lt;SPAN&gt;'Pick occurrence&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oAssyoOcc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt; = &lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;SelectionFilterEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kAssemblyOccurrenceFilter&lt;/SPAN&gt;, &lt;SPAN&gt;"Select Occurence"&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;'Select the chosen occurrence for processing&lt;/SPAN&gt;
	&lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;DoSelect&lt;/SPAN&gt;(&lt;SPAN&gt;oAssyoOcc&lt;/SPAN&gt;)
    
	&lt;SPAN&gt;'Clear the clipboard&lt;/SPAN&gt;
	&lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;ClearPrivateEvents&lt;/SPAN&gt;
	
	&lt;SPAN&gt;' Post the filename.&lt;/SPAN&gt;
    &lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;PostPrivateEvent&lt;/SPAN&gt;(&lt;SPAN&gt;PrivateEventTypeEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kFileNameEvent&lt;/SPAN&gt;,&lt;SPAN&gt;"C:\Users\Assembly5.stp"&lt;/SPAN&gt;)

    &lt;SPAN&gt;' Get control definition for the place component command.&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oControlDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ControlDefinition&lt;/SPAN&gt;= &lt;SPAN&gt;oCommandMgr&lt;/SPAN&gt;.&lt;SPAN&gt;ControlDefinitions&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;"AssemblyReplaceAllCmd"&lt;/SPAN&gt;)

    &lt;SPAN&gt;' Execute the command synchronously. &lt;/SPAN&gt;
    &lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;oControlDef&lt;/SPAN&gt;.&lt;SPAN&gt;Execute2&lt;/SPAN&gt;(&lt;SPAN&gt;True&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 22:11:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/replace-imported-component/m-p/11272578#M139918</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-07-01T22:11:05Z</dc:date>
    </item>
  </channel>
</rss>

