Populate Fusion 360 "Favorites" Material Library Using A Python Script

Populate Fusion 360 "Favorites" Material Library Using A Python Script

isocam
Collaborator Collaborator
329 Views
1 Reply
Message 1 of 2

Populate Fusion 360 "Favorites" Material Library Using A Python Script

isocam
Collaborator
Collaborator

Can anybody help?

 

Is it possible to populate Fusion 360 "Favorites" material library using a python script?

 

For example, add new materials to the library.

 

Many thanks in advance!

 

Darren

0 Likes
330 Views
1 Reply
Reply (1)
Message 2 of 2

BrianEkins
Mentor
Mentor

Here's a small sample that adds to the materials to the Favorites list.

 

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        lib = app.materialLibraries.itemByName('Fusion 360 Material Library')

        aluminum = lib.materials.itemByName('Aluminum 7075')
        app.favoriteMaterials.add(aluminum)

        gold = lib.materials.itemByName('Gold')
        app.favoriteMaterials.add(gold)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com