Python API TableCommandInput not displaying correctly

Python API TableCommandInput not displaying correctly

Anonymous
Not applicable
680 Views
2 Replies
Message 1 of 3

Python API TableCommandInput not displaying correctly

Anonymous
Not applicable

I am having an issue with the TableCommandInput in the Python API not displaying correctly when it has more than one row and a toolbarCommandInput. I have confirmed on the API forum that the code is working correctly for other people.

 

I am on:

MacOS 10.15.2

Fusion 2.0.7036

 

#Fusion360API Python script

import adsk.core, adsk.fusion, traceback

_ui  = None
_handlers = []

class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            cmd = adsk.core.Command.cast(args.command)
            inputs = cmd.commandInputs
            
            onDestroy = MyCommandDestroyHandler()
            cmd.destroy.add(onDestroy)
            _handlers.append(onDestroy)

            table = inputs.addTableCommandInput('table', '', 4, "")

            for i in range(4):
                for j in range(4):
                    ci = table.commandInputs.addTextBoxCommandInput("tb{}{}".format(i, j), "", "{} . {}".format(i, j), 1, True)
                    table.addCommandInput(ci, i, j)

            button = table.commandInputs.addBoolValueInput('button', 'Button', False, '', True)
            table.addToolbarCommandInput(button)

        except:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

            
class MyCommandDestroyHandler(adsk.core.CommandEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            adsk.terminate()
        except:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def run(context):
    try:
        app = adsk.core.Application.get()

        global _ui
        _ui = app.userInterface
        
        cmdDef = _ui.commandDefinitions.itemById('table_test')
        if cmdDef:
            cmdDef.deleteMe()

        cmdDef = _ui.commandDefinitions.addButtonDefinition('table_test', 'table_test', 'table_test')

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

 

 

0 Likes
Accepted solutions (1)
681 Views
2 Replies
Replies (2)
Message 2 of 3

JeromeBriot
Mentor
Mentor
Accepted solution

Hello,

 

No need to duplicate your discussion. The first one is in the good forum (i.e. API forum).

Be patient. Someone at Autodesk will surely add this to the bug tracking system.

People here are less concerned by coding issues.

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Ok I am sorry. When looking for the place to report bugs, this forum was suggested. Since it seems to be a bug and not a question about using the API I thought putting it here would be right.

0 Likes