how do I run code on a part within an assembly?

how do I run code on a part within an assembly?

Anonymous
Not applicable
472 Views
0 Replies
Message 1 of 1

how do I run code on a part within an assembly?

Anonymous
Not applicable

I have this ilogic routine

InventorVb.RunMacro("DocumentProject", "Color", "ChangeColor","red")

 However I want it to run this macro

 

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

 within the part itself. 

 

Ultimately I need to save 3 versions of a file in an assy, each of a different color.  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.  I have code to perform almost all of these tasks but I'm stuck trying to bring them together. 

 

My guess is if I can figure out how to run macros on a part from within the Assy I can do the rest.

 

0 Likes
473 Views
0 Replies
Replies (0)