It's not the usual workflow but now in 2023 you have the selection changed event which also applies to project browser. The below prompts user to select from browser before adding a selection changed event.
The handler filters for the class of FamilySymbol* and shows a dialogue if the result yields more than 0 results.
Note that not every thing in the project browser is a FamilySymbol so ElementType class will cover more aspects such as system families.
You would have to continue execution in the handler and perhaps raise an external event to get an editable document status (I suspect the selection changed event doesn't give you that).
You can also use e.GetDocument below instead of casting sender 's' to UIApplication to get the Document.
Public Function Obj_220831a(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result
Dim IntUIApp As UIApplication = commandData.Application
Dim IntUIDoc As UIDocument = commandData.Application.ActiveUIDocument
Dim IntDoc As Document = IntUIDoc.Document
TaskDialog.Show("Select", "Pick family symbol from project browser")
AddHandler IntUIApp.SelectionChanged, AddressOf SelectionChanged
Return Result.Succeeded
End Function
Public Sub SelectionChanged(s As Object, e As Autodesk.Revit.UI.Events.SelectionChangedEventArgs)
Dim UIapp As UIApplication = s
Dim J As ISet(Of ElementId) = e.GetSelectedElements
Dim J0 As List(Of ElementId) = J.ToList
Dim FEC As New FilteredElementCollector(UIapp.ActiveUIDocument.Document, J0)
Dim F0 As New ElementClassFilter(GetType(FamilySymbol))
Dim Els As List(Of Element) = FEC.WherePasses(F0).ToElements
If Els.Count > 0 Then
TaskDialog.Show("Selection", Els(0).Name)
RemoveHandler UIapp.SelectionChanged, AddressOf SelectionChanged
End If
End Sub