<?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 how do I run code on a part within an assembly? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-do-i-run-code-on-a-part-within-an-assembly/m-p/5446360#M121159</link>
    <description>&lt;P&gt;I have this ilogic routine&lt;/P&gt;&lt;PRE&gt;InventorVb.RunMacro("DocumentProject", "Color", "ChangeColor","red")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;However I want it to run this macro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Option Explicit

Dim oPartDoc As PartDocument
Dim oCompDef As ComponentDefinition

 
Public Sub ChangeColor(strColor As String)
    Set oPartDoc = ThisApplication.ActiveDocument
    Set oCompDef = oPartDoc.ComponentDefinition
    Dim appAsset As Asset
    Dim oLib As AssetLibrary
    Set oLib = ThisApplication.AssetLibraries("Autodesk Appearance Library")
    Set appAsset = oLib.AppearanceAssets(strColor)
    oPartDoc.ActiveAppearance = appAsset
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;within the part itself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately I need to save 3 versions of a file in an assy, each of a different color.&amp;nbsp; So I'm trying to set up a routine that takes the active part, copies an object from the assy to the part, saves 3 copies of different colors, and then creates an assy of each of those 3 parts.&amp;nbsp; I have code to perform almost all of these tasks but I'm stuck trying to bring them together.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My guess is if I can figure out how to&amp;nbsp;run macros on a part&amp;nbsp;from within the Assy I can do the rest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Dec 2014 16:32:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-12-17T16:32:50Z</dc:date>
    <item>
      <title>how do I run code on a part within an assembly?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-do-i-run-code-on-a-part-within-an-assembly/m-p/5446360#M121159</link>
      <description>&lt;P&gt;I have this ilogic routine&lt;/P&gt;&lt;PRE&gt;InventorVb.RunMacro("DocumentProject", "Color", "ChangeColor","red")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;However I want it to run this macro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Option Explicit

Dim oPartDoc As PartDocument
Dim oCompDef As ComponentDefinition

 
Public Sub ChangeColor(strColor As String)
    Set oPartDoc = ThisApplication.ActiveDocument
    Set oCompDef = oPartDoc.ComponentDefinition
    Dim appAsset As Asset
    Dim oLib As AssetLibrary
    Set oLib = ThisApplication.AssetLibraries("Autodesk Appearance Library")
    Set appAsset = oLib.AppearanceAssets(strColor)
    oPartDoc.ActiveAppearance = appAsset
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;within the part itself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately I need to save 3 versions of a file in an assy, each of a different color.&amp;nbsp; So I'm trying to set up a routine that takes the active part, copies an object from the assy to the part, saves 3 copies of different colors, and then creates an assy of each of those 3 parts.&amp;nbsp; I have code to perform almost all of these tasks but I'm stuck trying to bring them together.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My guess is if I can figure out how to&amp;nbsp;run macros on a part&amp;nbsp;from within the Assy I can do the rest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Dec 2014 16:32:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-do-i-run-code-on-a-part-within-an-assembly/m-p/5446360#M121159</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-17T16:32:50Z</dc:date>
    </item>
  </channel>
</rss>

