Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

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