Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
I'm trying to turn off visibility for all part occurrences named "break representation" in a drawing document. Here's what I've come up with so far:
Sub HideBreakRepresentationsInDrawing() Dim Counter As Integer Counter = 0 If ThisApplication.Documents.Count <> 0 Then Dim Doc As DrawingDocument Set Doc = ThisApplication.ActiveDocument Else Call MsgBox("No open documents") Exit Sub End If Dim Sheets As Sheets Set Sheets = Doc.Sheets 'recurse all sheets in drawing document Dim Sheet As Sheet For Each Sheet In Sheets Dim Views As DrawingViews Set Views = Sheet.DrawingViews 'recurse views here 'recurse all drawing views in sheet Dim View As DrawingView For Each View In Views 'assumes the drawing view references an assembly If View.ReferencedDocumentDescriptor.ReferencedDocumentType = kAssemblyDocumentObject Then Dim RefDoc As AssemblyDocument Set RefDoc = View.ReferencedDocumentDescriptor.ReferencedDocument 'recurse all components in assembly referenced by view Call recurseOccurrences(RefDoc.ComponentDefinition.Occurrences, Counter) End If Next Next Call MsgBox(Counter) End Sub Function recurseOccurrences(Occurrences As ComponentOccurrences, Counter As Integer) Dim Occurrence As ComponentOccurrence For Each Occurrence In Occurrences If Occurrence.DefinitionDocumentType = kAssemblyDocumentObject Then 'found assembly, find subparts Call recurseOccurrences(Occurrence.SubOccurrences, Counter) ElseIf Occurrence.DefinitionDocumentType = kPartDocumentObject And InStr(LCase(Occurrence.Name), "break representation") Then 'do something to a part Occurrence.Visible = False Counter = Counter + 1 End If Next End Function
My counter returns 34, so I know the script is finding what I want it to find, but none of the part occurrences are affected. Does ComponentOccurrence.Visible = False not work in the drawing environment or something?
Solved! Go to Solution.