Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1 REPLY 1
Reply
Message 1 of 2
isocam
85 Views, 1 Reply

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

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

1 REPLY 1
Message 2 of 2
BrianEkins
in reply to: isocam

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report