Get Part Colour Using Python

Get Part Colour Using Python

isocam
Collaborator Collaborator
662 Views
1 Reply
Message 1 of 2

Get Part Colour Using Python

isocam
Collaborator
Collaborator

Can anybody help???

 

Is it possible, using Fusion 360 API, to get the parts "Colour" property (for testing only) and show the colour in a message box?

 

Many thanks in advance!!!!

 

Darren

0 Likes
Accepted solutions (1)
663 Views
1 Reply
Reply (1)
Message 2 of 2

Rushikesh.kadam
Autodesk
Autodesk
Accepted solution

@isocam here is a code to get the appearance of each body present in a file.


import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        design = adsk.fusion.Design.cast(app.activeProduct)
        for comp in design.allComponents:
           for body in comp.bRepBodies:
                ui.messageBox(f"Component: {comp.name}\nBody: {body.name}\nAppearance: {body.appearance.name}")
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

------------------------------------------------------------------------------------------------------------------------------

If my reply was helpful, please click the "Accept as Solution" button. It helps others get the answer quickly! A "Like" is always welcomed.




Rushikesh Kadam
Senior QA Engineer
Quality Assurance
Autodesk, Inc.