Run commands from the “Text Commands” panel

As mentioned in this article already, you can run registered Fusion 360 commands programmatically as well.

You can also do it without creating a script or add-in, by using the “Text Commands” panel:

TextCommandsPanel

In this case we are using Python, so make sure that the appropriate radio button is selected:

RunCcommand

import adsk.core, adsk.fusion
app = adsk.core.Application.get()
ui = app.userInterface
cmdDefs = ui.commandDefinitions
cmdDef = cmdDefs.itemById("DragKnifeAddInMenuEntry")
cmdDef.execute()

As mentioned in the article I linked to above, you can get a list of all the commands that were added to the UI and find out the ID of the CommandDefinition you want to run.
You can also get it by listing the name and id of all the registered CommandDefinitions:

ListCommands

import adsk.core, adsk.fusion
app = adsk.core.Application.get()
ui = app.userInterface
cmdDefs = ui.commandDefinitions
result = ""
for cmdDef in cmdDefs:
result += "n" + cmdDef.name + ", " + cmdDef.id
print(result) 

PS: after typing the line of “result += …” you’ll have to press enter twice to get out of the for loop section


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading