Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Highlighting Parts in Sub-Assmeblies

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
AB.ViewOnly
558 Views, 2 Replies

Highlighting Parts in Sub-Assmeblies

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.

2 REPLIES 2
Message 2 of 3
AB.ViewOnly
in reply to: AB.ViewOnly

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.

 

Message 3 of 3
AB.ViewOnly
in reply to: AB.ViewOnly

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

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report