Hi,
The XML extract that I sent you in the last message is how the Fusion UI Menus are defined; from there I extract the commands ID for the different selection priorities you find in the menu.
Then you can use that Command Definition Id to look for it and execute it (as you do when you create a command dialog where you first define a command definition and the execute it): I found two option to execute it. They are equivalent, so you can can choose any of them.
This is the source code with the two options:
import adsk, adsk.core, adsk.fusion, adsk.cam, traceback
app = adsk.core.Application.get()
def option_command_definition(cmdId : str) -> None:
cmd_def = app.userInterface.commandDefinitions.itemById(cmdId)
if cmd_def:
cmd_def.execute()
app.log(f'{cmdId} was toggled by CommandDefinition')
else:
app.log(f'Command definition "{cmdId}" not found!')
def option_text_command(cmdId: str) -> None:
ret = app.executeTextCommand(f'Commands.Start {cmdId}')
app.log(f'{cmdId} toggled by Text Command with result : {ret}')
def run(context) -> None:
try:
# Option 1 : by Command Definition
option_command_definition("SelectComponentPriorityCommand")
# Option 2 : by Text Command
# option_text_command("SelectComponentPriorityCommand")
except:
app.log('Failed:\n{}'.format(traceback.format_exc()))
adsk.terminate()
I hope this can help you.
Regards,
Jorge Jaramillo