I'm having a problem highlighting parts within a sub assembly. A simple structure to demonstarte this issue would be:
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
Set ChildPart1 = SubAssy.ComponentDefinition.Occurrences(1)
Set highlightSet = SubAssy.CreateHighlightSet()
highlightSet.Color = ThisApplication.TransientObjects.CreateColor(255, 255, 255)
highlightSet.Color.Opacity = 0.8
Can anyone provide any help?
Solved! Go to Solution.
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.
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.
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
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register