<?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 VBA code to save &amp;amp; replace component in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9965306#M54762</link>
    <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a assembly, which contain a library &amp;amp; customized parts. I want to use this assembly as master assembly. Need a VBA code by the help of that I can save &amp;amp; replace these parts in one go.&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/5330176"&gt;@JhoelForshav&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/108623" target="_self"&gt;&lt;SPAN class=""&gt;@JDMather&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/116141" target="_self"&gt;@ekinsb&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2105322"&gt;@sundars&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/473476"&gt;@bradeneuropeArthur&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Dec 2020 11:40:45 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-12-28T11:40:45Z</dc:date>
    <item>
      <title>Need VBA code to save &amp; replace component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9965306#M54762</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a assembly, which contain a library &amp;amp; customized parts. I want to use this assembly as master assembly. Need a VBA code by the help of that I can save &amp;amp; replace these parts in one go.&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/5330176"&gt;@JhoelForshav&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/108623" target="_self"&gt;&lt;SPAN class=""&gt;@JDMather&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/116141" target="_self"&gt;@ekinsb&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2105322"&gt;@sundars&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/473476"&gt;@bradeneuropeArthur&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 11:40:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9965306#M54762</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-12-28T11:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need VBA code to save &amp; replace component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9965521#M54763</link>
      <description>&lt;P&gt;Can't you use i-logic copy design for this.&lt;/P&gt;
&lt;P&gt;This is shipped with inventor and can be found in the ribbon when NO document is opened!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 14:03:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9965521#M54763</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2020-12-28T14:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need VBA code to save &amp; replace component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9972158#M54764</link>
      <description>&lt;P&gt;currently I am using iLogic copy design, in this tool every time I have to close all part.&lt;BR /&gt;I want a VBA code that I can use as macros. so in single click I can do all these activities.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jan 2021 11:13:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9972158#M54764</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-01T11:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need VBA code to save &amp; replace component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9975034#M54765</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My apologies for the late response. We have been on our annual shutdown and I had not read my email in a while. For your issue, can you post a copy of your iLogic Rule. You can take your iLogic rule and wrap it up in a VBA script with slight modifications.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We also have a sample vba program in the API help which replaces content parts - you could take a look at that and see if you can modify it to suit your needs. (See attached).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all"&gt;
&lt;DIV id="VBA" class="api-code ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-hidden="false" aria-labelledby="ui-id-1"&gt;
&lt;PRE class="api-code"&gt;Sub ReplaceContentCenterPart()
    &lt;SPAN&gt;' Set a reference to the active assembly document.&lt;/SPAN&gt;
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument

    &lt;SPAN&gt;' Prompt user to pick an occurrence&lt;/SPAN&gt;
    Dim oOcc As ComponentOccurrence
    Set oOcc = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Pick occurrence to replace")

    If oOcc.DefinitionDocumentType &amp;lt;&amp;gt; kPartDocumentObject Then
        MsgBox "Occurrence does not reference a content part."
        Exit Sub
    End If

    Dim oOccDef As PartComponentDefinition
    Set oOccDef = oOcc.Definition

    If Not oOccDef.IsContentMember Then
        MsgBox "The occurrence does not reference a content part."
        Exit Sub
    End If

    &lt;SPAN&gt;' Set a reference to the ContentCenter object.&lt;/SPAN&gt;
    Dim oContentCenter As ContentCenter
    Set oContentCenter = ThisApplication.ContentCenter

    &lt;SPAN&gt;' Get the content node (category) "Fasteners:Bolts:Hex Head"&lt;/SPAN&gt;
    Dim oContentNode As ContentTreeViewNode
    Set oContentNode = oContentCenter.TreeViewTopNode.ChildNodes.Item("Fasteners").ChildNodes.Item("Bolts").ChildNodes.Item("Hex Head")

    &lt;SPAN&gt;' Get the "ISO 4015" Family object.&lt;/SPAN&gt;
    Dim oFamily As ContentFamily
    For Each oFamily In oContentNode.Families
        If oFamily.DisplayName = "ISO 4015" Then
            Exit For
        End If
    Next

    &lt;SPAN&gt;' Create a member based on the second row of the family.&lt;/SPAN&gt;
    Dim error As MemberManagerErrorsEnum
    Dim strContentPartFileName As String
    Dim strErrorMessage As String
    strContentPartFileName = oFamily.CreateMember(2, error, strErrorMessage)

    Call oOcc.Replace(strContentPartFileName, False)
End Sub&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Thanks and Happy New Year&lt;/P&gt;
&lt;P&gt;-shiva&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jan 2021 18:10:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9975034#M54765</guid>
      <dc:creator>sundars</dc:creator>
      <dc:date>2021-01-03T18:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need VBA code to save &amp; replace component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9975633#M54766</link>
      <description>&lt;P&gt;Happy new year Shiva&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a assembly, which contain a library &amp;amp; customized parts. Actually I want to use this assembly as master assembly &amp;amp; when I run VBA code then all customized&amp;nbsp;parts (not library parts) will save as &amp;amp; replace automatically.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;above code is for replace content center parts.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 03:46:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9975633#M54766</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-04T03:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need VBA code to save &amp; replace component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9977298#M54767</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say "Customized parts" are you referring to custom content parts? If so, in the above example we iterate through the content family. For each family you can query whether it's custom?&amp;nbsp;oFamily.IsCustom function will tell you if it's a custom content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="api-code"&gt;    &lt;SPAN&gt;' Get the "ISO 4015" Family object.&lt;/SPAN&gt;
    Dim oFamily As ContentFamily
    For Each oFamily In oContentNode.Families
        If oFamily.&lt;STRONG&gt;IsCustom&lt;/STRONG&gt; Then
            Exit For
        End If
    Next&lt;/PRE&gt;
&lt;P&gt;If not, then you would have to somehow figure out a way to tag your custom parts with some unique property/attribute and then search for that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;-shiva&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:37:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9977298#M54767</guid>
      <dc:creator>sundars</dc:creator>
      <dc:date>2021-01-04T19:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need VBA code to save &amp; replace component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9981439#M54768</link>
      <description>&lt;P&gt;Sorry for not to explain in detail&lt;BR /&gt;Actually I am not using parts from content center.&lt;/P&gt;&lt;P&gt;For Library parts means it is not from contain center. These are local standard parts/assemblies. I just create a folder in local &amp;amp; define path in project file to locate these parts/assemblies.&lt;/P&gt;&lt;P&gt;And for customized parts it means local parts/assemblies saved in same folder where I saved master assembly.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 09:50:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9981439#M54768</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-06T09:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need VBA code to save &amp; replace component</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9982657#M54769</link>
      <description>&lt;P&gt;HI&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am afraid, we dont have any VBA utility in the API to achieve the kind of automation you want. ILogic Copy design is the closest thing to your needs. If not, you would essentially have to build something like that in the API using VBA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could still take the sample program I attached and modify it to read a source and target list of components from some text file and execute the replace. It could be as simple as some comma delimted text format containing source and target files. Then your vba program could read that and call replace via the API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;-shiva&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 18:02:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-vba-code-to-save-amp-replace-component/m-p/9982657#M54769</guid>
      <dc:creator>sundars</dc:creator>
      <dc:date>2021-01-06T18:02:14Z</dc:date>
    </item>
  </channel>
</rss>

