Match part color to another part in assembly

Match part color to another part in assembly

k14348
Advocate Advocate
356 Views
1 Reply
Message 1 of 2

Match part color to another part in assembly

k14348
Advocate
Advocate

Sub MatchColor()

Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oOcc1 As ComponentOccurrence
Set oOcc1 = ThisApplication.CommandManager.Pick(kAssemblyLeafOccurrenceFilter, "Org part")

Dim oAppear1 As Asset
Set oAppear1 = oOcc1.Appearance

MsgBox (oAppear1.DisplayName)

Dim oOcc2 As ComponentOccurrence
Set oOcc2 = ThisApplication.CommandManager.Pick(kAssemblyLeafOccurrenceFilter, "Repli Part")

Dim oAppear2 As Asset
Set oAppear2 = oAppear1
End Sub

 

Can anybody  help to complete this code.???

Hope u understand what i need.  (match occ1 color to occ2 color)

 

Thank you,

k

 

0 Likes
Accepted solutions (1)
357 Views
1 Reply
Reply (1)
Message 2 of 2

tdant
Collaborator
Collaborator
Accepted solution

Try this:

 

Sub SetAppearance()
    Dim occ1 As ComponentOccurrence
    Set occ1 = ThisApplication.CommandManager.Pick(kAssemblyLeafOccurrenceFilter, "Select an occurrence to copy appearance")
    
    Dim occ2 As ComponentOccurrence
    Set occ2 = ThisApplication.CommandManager.Pick(kAssemblyLeafOccurrenceFilter, "Select an occurrence to paste appearance")
    
    On Error GoTo ErrHandler
    occ2.Appearance = occ1.Appearance
    Exit Sub
    
ErrHandler:
    MsgBox ("Original appearance is invalid, please select another")
End Sub