Unable to get command dialoge boxes to appear...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello.
I am first of all not a programmer , but more of a script kiddie, i can read code and understand it mostly but do not know how to troubleshoot it well, so, Copilot AI...
I tried to make some add-ins but i always fail to generate the command dialogue windows.
In the below case, i have
1. Created a .py file and .manifest file
2. Use the create button to generate the folder in the addins folder for fusion 360.
3. I copy the files over to the addin folder and overwrite the default ones.
4. i run the script, nothing pops up. I want to figure out how to make the command dialoge boxes appear.
No errors, everything appear to launch, it is almost like they appear offscreen and is inaccessible.
I am on the free version of fusion.
SimpleCommandDialogAddIn.py
import adsk.core, adsk.fusion, traceback
# Global variables to keep references to event handlers
handlers = []
def run(context):
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Debug: Notify that the add-in is starting
ui.messageBox('Add-in is starting...')
# Create a command definition
cmd_def = ui.commandDefinitions.addButtonDefinition(
'SimpleCommandDialog', # Unique ID for the command
'Simple Command Dialog', # Display name of the command
'A simple test for command dialogs.', # Description of the command
'' # No icon
)
cmd_def.commandCreated.add(CommandCreatedHandler())
handlers.append(CommandCreatedHandler())
# Debug: Notify that the command definition was created
ui.messageBox('Command definition created.')
# Execute the command
cmd_def.execute()
# Debug: Notify that the command was executed
ui.messageBox('Command executed.')
# Keep the command definition alive
adsk.autoTerminate(False)
except Exception as e:
if ui:
ui.messageBox('Failed to run add-in:\n{}'.format(traceback.format_exc()))
def stop(context):
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Remove the command definition
cmd_def = ui.commandDefinitions.itemById('SimpleCommandDialog')
if cmd_def:
cmd_def.deleteMe()
ui.messageBox('Add-in stopped.')
except Exception as e:
if ui:
ui.messageBox('Failed to stop add-in:\n{}'.format(traceback.format_exc()))
class CommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Debug: Notify that the command dialog is being created
ui.messageBox('Command dialog is being created.')
# Get the command inputs
cmd = args.command
inputs = cmd.commandInputs
# Add a simple text box input
inputs.addTextBoxCommandInput(
'textBox', # Unique ID for the input
'Enter Text', # Label for the input
'', # Default value
1, # Number of rows
False # Multiline (False = single line)
)
# Debug: Notify that the dialog was created
ui.messageBox('Command dialog created successfully.')
except Exception as e:
if ui:
ui.messageBox('Failed to create command dialog:\n{}'.format(traceback.format_exc()))
Manifest file:
SimpleCommandDialogAddIn.manifest
{
"id": "SimpleCommandDialogAddIn",
"name": "Simple Command Dialog Add-In",
"description": "A simple add-in to test command dialogs.",
"version": "1.0.0",
"author": "Your Name",
"company": "Your Company",
"supportedProducts": ["Fusion360"],
"minVersion": "2.0.0",
"maxVersion": "",
"parameters": {}
}
Both of these rests inside
AppData\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns\SimpleCommandDialogAddIn
after i created the addin folder with fusion.