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: 

Run press pull command with script.

1 REPLY 1
SOLVED
Reply
Message 1 of 2
thomas_vijf
463 Views, 1 Reply

Run press pull command with script.

Hello,

 

i have made a script that selects all cylindrical faces in a body, after wich i manualy press the 'press/pull' command button in the ribbon so i can change the fillet size.

I was wondering if there is a way to fire that press/pull button in the end of the script.

 

#Update SelectionSets
        cmd = ui.commandDefinitions.itemById('UpdateSelectionGroupCmd')
        cmd.execute()

I found this snippet to press the 'update selectionset' button. 

I hope there is something simmilar to execute other standard button commands.

 

Thanks.

-Thomas

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

You can start any command, including those added by add-ins, by accessing the related CommandDefinition object and executing it.  The trick is finding the CommandDefinition.  Here's a little script that can help with that.  It creates a file that contains a list of all the commands defined in your copy of Fusion 360.

 

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:
            if result == '':
                result = cmdDef.name + ', ' + cmdDef.id
            else:
                result += '\n' + cmdDef.name + ', ' + cmdDef.id

        output = open('c:\\temp\\FusionCommands.txt', 'w')
        output.writelines(result)
        output.close()
        ui.messageBox('Finished wrting to c:\\temp\\FusionCommands.txt')
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

After a quick search in the output file I find the line:

 

Press Pull, FusionPressPullCommand

This means you can use the following line to execute the Press Pull command in your program.

cmd = ui.commandDefinitions.itemById('FusionPressPullCommand')
cmd.execute()

 

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