10-20-2021
05:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-20-2021
05:17 AM
Try this code
Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim subAssembly As AssemblyDocument
'here declare your names - subassembly and part to hide
Dim subAssemblyName As String = "Subassembly B"
Dim subPartName As String = "Part 1"
Dim hide As Boolean = True 'this must be connected with your form
'maybe create a boolean parameter and put it in your form,
'then you can replace this "true" with your parameter value
For Each subOcc As ComponentOccurrence In oDoc.ComponentDefinition.Occurrences
If subOcc.Name.Contains(subAssemblyName) Then
subAssembly = subOcc.Definition.Document
Exit for
End If
Next
If subAssembly Is Nothing Then Return
For Each oOcu As ComponentOccurrence In subAssembly.ComponentDefinition.Occurrences
If oOcu.Name.Contains(subPartName) Then
If hide=True Then
oOcu.Visible = False
Else
oOcu.Visible = True
End If
Else
oOcu.Visible = True
End If
Next