Fusion 360 Python Script - Get The Drawings Root Component (Assembly or Part)

Fusion 360 Python Script - Get The Drawings Root Component (Assembly or Part)

isocam
Collaborator Collaborator
167 Views
0 Replies
Message 1 of 1

Fusion 360 Python Script - Get The Drawings Root Component (Assembly or Part)

isocam
Collaborator
Collaborator

Can anybody help?

 

I need to know, using a Fusion 360 Python script, if a detail drawing contains an assembly or a part.

 

I have the following code....

 

if isinstance(doc,adsk.drawing.DrawingDocument):
ui.messageBox("DRAWING IS OPENED", 'Fusion 360', 0, 3)


#doc = app.activeProduct

rootComp = doc.rootComponent

allOccurrences = rootComponent.allOccurrences


DocumentType = 'D'

 

if allOccurrences.count > 0:
DocumentType = 'A'

 

ui.messageBox(DocumentType, 'Fusion 360', 0, 3)

 

return

 

Can anybody tell me if the code is correct?

 

If not, please can you update it?

 

Many thanks in advance!

 

Darren

0 Likes
168 Views
0 Replies
Replies (0)