Message 1 of 5
error - Method 'Visible' of object 'ComponentOccurrence' failed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm only a few months into Inventor, and I'm finding macros to help with reducing mouse clicks enabling "hidden" functionality. That said, I really want a way to show all components within an assembly with one click (or hotkey). I found a good solution on another post that works great most of the time, but it's having trouble with one of my assemblies, specifically when a particular View Representation is active. I get the following error: Method 'Visible' of object 'ComponentOccurrence' failed.
How do I resolve this error?
Here is my code (mostly borrowed from someone else here):
Sub ShowAllComponents()
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition
Set oAsmDef = oAsmDoc.ComponentDefinition
' Get all of the leaf occurrences of the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator
Set oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences
Dim oOcc As ComponentOccurrence
For Each oOcc In oLeafOccs
If oOcc.Visible = False Then
oOcc.Visible = True
End If
Next
End Sub