Fusion doesn't differentiate between a part and an assembly, so it's up to us to define what a part or assembly is.
The pure definition is a part is a component that only contains bodies and not any occurrences. An assembly is a component that only contains occurrences and no bodies. Anything else is some kind of a part and assembly hybrid. Here's some code that determines this.
def determineDocumentType():
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
root = design.rootComponent
if root.occurrences.count > 0 and root.bRepBodies.count > 0:
ui.messageBox('Document is a hybrid of assembly and part.')
elif root.occurrences.count > 0 and root.bRepBodies.count == 0:
ui.messageBox('Document is an assembly.')
elif root.occurrences.count == 0 and root.bRepBodies.count > 0:
ui.messageBox('Document is a part.')
elif root.occurrences.count == 0 and root.bRepBodies.count == 0:
ui.messageBox('Document is an empty part.')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com