Creating a custom command dialog then running a text command causes Fusion 360 to crash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm writing a script that creates a custom command dialog to prompt the user to enter some information. Then when the user clicks OK, the script needs to run a text command to create a Coil based on the information entered by the user in the previous dialog. The issue is that this workflow causes Fusion 360 to crash.
It looks like maybe there is some issue with the second command dialog (the created with a "Commands.Start" text command) clashes with the previous command dialog. Should the first command maybe cleaned up somehow before running the second one?
I've created the following bare-bone script to reproduce the issue. Warning: if you run this as-is then it'll likely crash Fusion 360 as it does for me. It is specifically the last line ("app.executeTextCommand(u'Commands.Start Extrude')") that causes the crash.
Do you know what's causing this and how to fix it or work around it?
Thanks!
Julien
import adsk.core, adsk.fusion, traceback
app = adsk.core.Application.get()
ui = app.userInterface
handlers = []
def run(context):
cmdDef = ui.commandDefinitions.itemById('myCmd')
if not cmdDef:
cmdDef = ui.commandDefinitions.addButtonDefinition('myCmd', 'myCmd', 'myCmd')
onCommandCreated = MyCommandCreatedHandler()
cmdDef.commandCreated.add(onCommandCreated)
handlers.append(onCommandCreated)
cmdDef.execute()
adsk.autoTerminate(False)
class MyCommandDestroyHandler(adsk.core.CommandEventHandler):
def notify(self, args):
adsk.terminate()
class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
def notify(self, args):
cmd = adsk.core.Command.cast(args.command)
onExecute = MyCommandExecuteHandler()
cmd.execute.add(onExecute)
handlers.append(onExecute)
onDestroy = MyCommandDestroyHandler()
cmd.destroy.add(onDestroy)
handlers.append(onDestroy)
inputs: adsk.core.CommandInputs = cmd.commandInputs
inputs.addTextBoxCommandInput('my_text', 'Some text', 'abcd', 1, False)
class MyCommandExecuteHandler(adsk.core.CommandEventHandler):
def notify(self, args):
# WARNING: Starting a new text command causes Fusion 360 to crash
app.executeTextCommand(u'Commands.Start Coil')