The current set of selected entities can be obtained through the UserInterface.activeSelections property. This is demonstrated in the code below that looks through the currence selections to see if any bodies are selected and then displays information about any selected bodies and any other entity types that were selected.
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
result = ''
for selection in ui.activeSelections:
selectedEnt = selection.entity
if selectedEnt.objectType == adsk.fusion.BRepBody.classType():
result += 'Selected Body: ' + selectedEnt.name + '\n'
else:
result += 'Other selection: ' + selectedEnt.objectType + '\n'
ui.messageBox(result, 'Selection Result')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))