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

Hi @goran.nilssonRSJCU 

If the partnumber you're looking for is always a part you could try this rule :slightly_smiling_face:

Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oPnr As String = InputBox("Part number: ", "Enter part number", "PARTNUMBER")
Dim Msg As String = "Part exists in: " & vbCrLf
Dim oList As New List(Of String)
Dim partExists As Boolean = False
For Each oOcc As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences.AllLeafOccurrences
	If oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = oPnr
		partExists = True
		Try
			If oList.Contains(oOcc.ParentOccurrence.Name) = False Then oList.Add(oOcc.ParentOccurrence.Name)

		Catch
			'Part is in top level assembly
			If oList.Contains(oAsm.DisplayName) = False Then oList.Add(oAsm.DisplayName)
		End Try
	End If
Next
If partExists = True
For Each oItem As String In oList
	Msg = Msg & oItem & vbCrLf
Next
MessageBox.Show(Msg, "Sub-assemblys containing part", MessageBoxButtons.OK)
Else
MessageBox.Show("Cant find part with partnumber: " & oPnr, "Sub-assemblys containing part", MessageBoxButtons.OK)	
End If