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 EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com