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: 

Add Fusion 360 command to add in menu

1 REPLY 1
SOLVED
Reply
Message 1 of 2
brad.bylls
242 Views, 1 Reply

Add Fusion 360 command to add in menu

How can I add the 'Add Thread' Fusion command to my addin menu to make it more convenient for the user? 

Brad Bylls
1 REPLY 1
Message 2 of 2
BrianEkins
in reply to: brad.bylls

All commands, both the internal commands and those created by add-ins, exist internally as CommandDefinition objects. You can access all Command Definitions object through the UserInterface.commandDefinitions property which returns a CommandDefinitions object.  This lets you traverse over all of the existing commands, or if you know the ID of the command you want you can use the itemById method to get a specific CommandDefinition.  The ID for the Thread command is "FusionThreadCommand".

 

To find out the name of a specific command, I used the script below to write out a list of all the existing commands.  Using the "Find" command in a text editor will usually let you quickly find the command and its ID.

 

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

        result = ''
        cmdDef = adsk.core.CommandDefinition.cast(None)
        for cmdDef in ui.commandDefinitions:
            result += cmdDef.name + ', ' + cmdDef.id + '\n'

        output = open('C:/Temp/FusionCommands.txt', 'w')
        output.writelines(result)
        output.close()

        ui.messageBox('Finished writing to "C:/Temp/FusionCommands.txt"')
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

With the CommandDefinition you've obtained you can create a button for it, the same as you do for any commands you create.

 

---------------------------------------------------------------
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