Hi @mohammadkhader698 .
We made a simple sample.
# Fusion360API Python script
import traceback
import adsk.fusion
import adsk.core
_app: adsk.core.Application = None
_ui: adsk.core.UserInterface = None
_handlers = []
class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: adsk.core.CommandCreatedEventArgs):
adsk.core.Application.get().log(args.firingEvent.name)
try:
global _handlers
cmd: adsk.core.Command = adsk.core.Command.cast(args.command)
inputs: adsk.core.CommandInputs = cmd.commandInputs
onDestroy = MyCommandDestroyHandler()
cmd.destroy.add(onDestroy)
_handlers.append(onDestroy)
onExecute = MyExecuteHandler()
cmd.execute.add(onExecute)
_handlers.append(onExecute)
inputs.addTextBoxCommandInput(
'txtOutIpt',
'text',
'Outside',
1,
True
)
# https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-38a0b5b9-9339-4c4e-b113-130877c99497
grpIpt: adsk.core.GroupCommandInput = inputs.addGroupCommandInput(
'grpIptId',
'Group Input Test'
)
grpChildIpts: adsk.core.CommandInputs = grpIpt.children
grpChildIpts.addTextBoxCommandInput(
'txtInIpt',
'text',
'Inside',
1,
True
)
except:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
class MyExecuteHandler(adsk.core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: adsk.core.CommandEventArgs):
adsk.core.Application.get().log(args.firingEvent.name)
class MyCommandDestroyHandler(adsk.core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: adsk.core.CommandEventArgs):
adsk.core.Application.get().log(args.firingEvent.name)
adsk.terminate()
def run(context):
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
cmdDef: adsk.core.CommandDefinition = _ui.commandDefinitions.itemById(
'test_cmd'
)
if not cmdDef:
cmdDef = _ui.commandDefinitions.addButtonDefinition(
'test_cmd',
'Test',
'Test'
)
global _handlers
onCommandCreated = MyCommandCreatedHandler()
cmdDef.commandCreated.add(onCommandCreated)
_handlers.append(onCommandCreated)
cmdDef.execute()
adsk.autoTerminate(False)
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))