Message 1 of 6
Component Invisibility in Drawing Macro Trouble

Not applicable
06-01-2010
11:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
All,
I am working on a macro to try and make certain components invisible in a drawing view and am having a hangup with the code I am posting below. As I test the code I find that I can cause components to be suppressed, but cannot change their visibility. I have had success with this basic code on assemblies, but am having some trouble with the drawing files.
Can someone please point me in the right direction? Thanks and have a great day!
Public Sub Inventor_Automatic_Component_Invisibility()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDoc.ActiveSheet
Dim oAssyDoc As AssemblyDocument
Set oAssyDoc = oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
Dim oCompDef As Inventor.ComponentDefinition
Set oCompDef = oAssyDoc.ComponentDefinition
Dim oComponent As ComponentOccurrence
For Each oComponent In oCompDef.Occurrences
Select Case oComponent.Name
Case "Part1"
oComponent.Suppress
Case "Part2"
oComponent.Visible = False
Case "Part3"
oComponent.Suppress
End Select
Next
End Sub
I am working on a macro to try and make certain components invisible in a drawing view and am having a hangup with the code I am posting below. As I test the code I find that I can cause components to be suppressed, but cannot change their visibility. I have had success with this basic code on assemblies, but am having some trouble with the drawing files.
Can someone please point me in the right direction? Thanks and have a great day!
Public Sub Inventor_Automatic_Component_Invisibility()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDoc.ActiveSheet
Dim oAssyDoc As AssemblyDocument
Set oAssyDoc = oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
Dim oCompDef As Inventor.ComponentDefinition
Set oCompDef = oAssyDoc.ComponentDefinition
Dim oComponent As ComponentOccurrence
For Each oComponent In oCompDef.Occurrences
Select Case oComponent.Name
Case "Part1"
oComponent.Suppress
Case "Part2"
oComponent.Visible = False
Case "Part3"
oComponent.Suppress
End Select
Next
End Sub