Highlighting Parts in Sub-Assmeblies

Highlighting Parts in Sub-Assmeblies

Anonymous
Not applicable
676 Views
2 Replies
Message 1 of 3

Highlighting Parts in Sub-Assmeblies

Anonymous
Not applicable

Guys,

 

I'm having a problem highlighting parts within a sub assembly.  A simple structure to demonstarte this issue would be:

 

TopLevel.iam

         |

        SubAssy.iam

                 |

                 ChildPart1.ipt

                 ChildPart2.ipt

 

Using this structure I wish to highligh ChildPart1.ipt, howver my vba macro code below doesn't seem to work (nothing happens):

 

    Public Sub Highlight()
        Dim SubAssy As Inventor.AssemblyDocument
        Dim ChildPart1 As Inventor.ComponentOccurrence
        Dim highlightSet As Inventor.highlightSet
       
        Set SubAssy = ThisApplication.ActiveDocument.ReferencedDocuments(1)
        Set ChildPart1 = SubAssy.ComponentDefinition.Occurrences(1)
       
        Set highlightSet = SubAssy.CreateHighlightSet()
       
        highlightSet.Color = ThisApplication.TransientObjects.CreateColor(255, 255, 255)
        highlightSet.Color.Opacity = 0.8
       
        highlightSet.AddItem ChildPart1
    End Sub

 

Can anyone provide any help? 

 

Many thanks,

 

Adrian.

0 Likes
Accepted solutions (1)
677 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Anyone got any ideas?  I still can't seem to get this working, in a nutshell I just want the highlighting to work as it does in the Model browser, when you hover over an item in the model browser it highlights it in the assembly even if its within a sub-assembly...

 

Again, any help would be greatly appreciated.

 

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

If anyone is interested (or facing the same issue) I've figured out the answer.  You need to add component occurence proxy objects to the highlightset not the sub component occurence objects themselves.  This can be done by first returning the component occurences from the root assembly then returning the suboccurences from those.

 

e.g.

 

Dim topHighlightSet As Inventor.highlightSet

Public Sub Highlight()
    Dim topLevel As Inventor.AssemblyDocument
    Dim subAssy As Inventor.ComponentOccurrence
    Dim childPart1Occurence As Inventor.ComponentOccurrenceProxy
    
    Set topLevel = ThisApplication.ActiveDocument
    Set subAssy = topLevel.ComponentDefinition.Occurrences.Item(1)
    Set childPart1Occurence = subAssy.SubOccurrences(1)
    
    Set topHighlightSet = topLevel.CreateHighlightSet()

    topHighlightSet.Color = ThisApplication.TransientObjects.CreateColor(255, 255, 255)
    topHighlightSet.Color.Opacity = 0.8
    topHighlightSet.AddItem childPart1Occurence
    
End Sub