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 asm As AssemblyDocument = ThisDoc.Document

Dim occ As ComponentOccurrence = Nothing

For Each selectedItem In asm.SelectSet
	Dim selectedOccurrence As ComponentOccurrence
	Try
		selectedOccurrence = selectedItem
		occ = selectedOccurrence
		Exit For
	Catch
		Continue For
	End Try
Next

If occ Is Nothing Then
	occ = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select FG component")
End If

If occ Is Nothing Then
	'Raise exception or return
	Return
End If

'...
MsgBox(occ.Name)