Changing Component Pattern Visibility.

Changing Component Pattern Visibility.

herrwolf1
Enthusiast Enthusiast
1,696 Views
5 Replies
Message 1 of 6

Changing Component Pattern Visibility.

herrwolf1
Enthusiast
Enthusiast

Hello,

     I'm trying to create a custom "Design View Representation". Is there a way to determine if a leaf occurrence is part of a component pattern? Whether or not that capability is available, how do you change the visibility state of a given pattern?

 

Thank you

 

Eric.

0 Likes
1,697 Views
5 Replies
Replies (5)
Message 2 of 6

montylowe
Enthusiast
Enthusiast

Any Luck On this one?

 

0 Likes
Message 3 of 6

herrwolf1
Enthusiast
Enthusiast

Sure did.

 

Dim oOccs As ComponentOccurrencesEnumerator
Dim oOcc As ComponentOccurrence

 

oOccs = oAsmDef.Occurrences.AllReferencedOccurrences(oSubRefDoc)

 

For Each oOcc In oOccs

If oOcc.IsPatternElement Then

     Dim oCcPat As OccurrencePattern
     oCcPat = oOcc.PatternElement.Parent

     If oCcPat.Visible Then
          oCcPat.Visible = False
     End If
          Continue For
     End If

 

Enjoy,

 

0 Likes
Message 4 of 6

montylowe
Enthusiast
Enthusiast

Having issue with

 

oOccs = oAsmDef.Occurrences.AllReferencedOccurrences(oSubR​efDoc)

 

Where do you define these items?

oAsmDef

(oSubR​efDoc)

0 Likes
Message 5 of 6

herrwolf1
Enthusiast
Enthusiast

        ' Get the active assembly.
        Dim oAsmDoc As AssemblyDocument
        oAsmDoc = Application.ActiveDocument

        ' Get the assembly component definition.
        Dim oAsmDef As AssemblyComponentDefinition
        oAsmDef = oAsmDoc.ComponentDefinition

_____________________________________________

 

 ' Get the sub assembly referenced documents.

Dim oSubRefDocs As DocumentsEnumerator
oSubRefDocs = oRefDoc.AllReferencedDocuments

 

' Iterate through each sub component of the sub assembly.
Dim oSubRefDoc As Document
For Each oSubRefDoc In oSubRefDocs

 

0 Likes
Message 6 of 6

leblanc2024
Advocate
Advocate

For those interested... Here is a VBA version of the code above...

Public Sub PATTERNvis()

Dim oOccs As ComponentOccurrencesEnumerator
Dim oOcc As ComponentOccurrence

Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument

Dim oAsmDef As AssemblyComponentDefinition
Set oAsmDef = oAsmDoc.ComponentDefinition

Dim oSubRefDocs As DocumentsEnumerator
Set oSubRefDocs = oAsmDoc.AllReferencedDocuments

Dim oSubRefDoc As Document

For Each oSubRefDoc In oSubRefDocs
     Set oOccs = oAsmDef.Occurrences.AllReferencedOccurrences(oSubRefDoc)

     For Each oOcc In oOccs
     
          If oOcc.IsPatternElement Then
          
          Dim oCcPat As OccurrencePattern
          Set oCcPat = oOcc.PatternElement.Parent
          
          If oCcPat.VISIBLE = False Then
               oCcPat.VISIBLE = True
          End If
               'Continue For
          End If
     Next
Next

End Sub

 

Regards,
Ivon

"You don't know if you can unless you try!"
0 Likes