Troubles with Table CommandInputs

Anonymous

Troubles with Table CommandInputs

Anonymous
Not applicable

I am having an issue where, when I have toolbarCommandInputs and more than one row in the table, everything except the first row piles up in the bottom left corner.

 

table1 = group2.children.addTableCommandInput('table1', '', 4, "3:1:2:3")
table1.minimumVisibleRows = 4
table1.maximumVisibleRows = 8

updateTable(table1, [[[1,2,3], [1], 2, True, 105]])

boolValue2 = table1.commandInputs.addBoolValueInput('boolValue2', 'New', False, '', True)
table1.addToolbarCommandInput(boolValue2)

boolValue3 = table1.commandInputs.addBoolValueInput('boolValue3', 'Delete', False, '', True)
table1.addToolbarCommandInput(boolValue3)


def updateTable(table, shapes):
    selected = table.selectedRow

    table.clear()

    for i, s in enumerate(shapes):
        dd = table.commandInputs.addDropDownCommandInput('dropDownTable{}'.format(i), '', 0)
        dd.listItems.add("Flat", s[2]==0, '')
        dd.listItems.add("Cylinder", s[2]==1, '')
        dd.listItems.add("Sphere", s[2]==2, '')
        dd.listItems.add("Plane", s[2]==3, '')
        dd.listItems.add("Line", s[2]==4, '')
        dd.listItems.add("Point", s[2]==5, '')
        table.addCommandInput(dd, i, 0)

        bv = table.commandInputs.addBoolValueInput('boolValueTable{}'.format(i), 'Auto', True)
        bv.value = s[3]
        table.addCommandInput(bv, i, 1)

        tb = table.commandInputs.addTextBoxCommandInput('textBoxTable{}'.format(i), '', '{} ({})'.format(len(s[0])+len(s[1]), len(s[0])), 1, True)
        table.addCommandInput(tb, i, 2)

        fs = table.commandInputs.addFloatSpinnerCommandInput('floatSpinnerTable{}'.format(i), '', '', 0, 100000, 5, s[4]) 
        table.addCommandInput(fs, i, 3)

    table.selectedRow = selected
0 Likes
Reply
Accepted solutions (1)
770 Views
6 Replies
Replies (6)

kandennti
Mentor
Mentor

Hi edidos.

 

I created a script like this to reproduce the problem.
However, the problem could not be reproduced.

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

            table1 = inputs.addTableCommandInput('table1', '', 4, "3:1:2:3")
            table1.minimumVisibleRows = 4
            table1.maximumVisibleRows = 8

            updateTable(table1, [
                [[1,2,3], [1], 0, True, 105],
                [[1,2,3], [1], 1, True, 105],
                [[1,2,3], [1], 2, True, 105],
                [[1,2,3], [1], 3, True, 105],
                [[1,2,3], [1], 4, True, 105],
                [[1,2,3], [1], 5, True, 105]])

            boolValue2 = table1.commandInputs.addBoolValueInput('boolValue2', 'New', False, '', True)
            table1.addToolbarCommandInput(boolValue2)

            boolValue3 = table1.commandInputs.addBoolValueInput('boolValue3', 'Delete', False, '', True)
            table1.addToolbarCommandInput(boolValue3)

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

def updateTable(table, shapes):
    selected = table.selectedRow

    table.clear()

    for i, s in enumerate(shapes):
        dd = table.commandInputs.addDropDownCommandInput('dropDownTable{}'.format(i), '', 0)
        dd.listItems.add("Flat", s[2]==0, '')
        dd.listItems.add("Cylinder", s[2]==1, '')
        dd.listItems.add("Sphere", s[2]==2, '')
        dd.listItems.add("Plane", s[2]==3, '')
        dd.listItems.add("Line", s[2]==4, '')
        dd.listItems.add("Point", s[2]==5, '')
        table.addCommandInput(dd, i, 0)

        bv = table.commandInputs.addBoolValueInput('boolValueTable{}'.format(i), 'Auto', True)
        bv.value = s[3]
        table.addCommandInput(bv, i, 1)

        tb = table.commandInputs.addTextBoxCommandInput('textBoxTable{}'.format(i), '', '{} ({})'.format(len(s[0])+len(s[1]), len(s[0])), 1, True)
        table.addCommandInput(tb, i, 2)

        fs = table.commandInputs.addFloatSpinnerCommandInput('floatSpinnerTable{}'.format(i), '', '', 0, 100000, 5, s[4]) 
        table.addCommandInput(fs, i, 3)

    table.selectedRow = selected
            
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()))

I believe the fastest way to solve the problem is to publish code that reproduces the problem.

 

1 Like

Anonymous
Not applicable

I am very sorry for not testing it on its own. I thought that no other part of the script would be in any way related to the table but I seem to be wrong. Here is a Link  to a repo containing the script and the required libraries. I was not able to attach it as a zip.

0 Likes

Anonymous
Not applicable

I have copied your test into a new script and it reproduced the same Issue.

I will add OS and version info as this may be a Fusion360 bug. 

 

Screenshot 2019-12-13 at 13.53.16.png

 

0 Likes

Anonymous
Not applicable

I was hoping to edit the main post but can't figure out how:

 

OS: macOS 10.14.5

Fusion: 2.0.7029

0 Likes

kandennti
Mentor
Mentor
Accepted solution

The source code of the link destination is amazing. I am looking forward to the completion of the add-in.

 

This is the state I tried here. (win10 64bit home)

1.png

Unfortunately, we could not reproduce the problem.

 

 

It may be irrelevant, but I used TableCommandInput when I made this add-in in the past.
https://github.com/kantoku-code/Fusion360-TSplineBodyDoorway 
The reason is unknown, but since the display was incorrect with the combination of "TableCommandInput" and "TextBoxCommandInput" at this time, there was an experience that the display became correct when changed to "StringValueCommandInput".

1 Like

Anonymous
Not applicable

Thank you.

This is the workaround I am using now since there were other problems with text boxes, like when there are more rows than can be displayed at once. String inputs seem to have problems as well, the read-only does not seem to work reliably. I am now undoing any changes to the string input in the input changed handler. It feels acceptable for now, I hope all these things get fixed eventually. I will accept this as a solution since it seems to be the best workaround at this moment.

 

I believe this add-in will be very useful for working with STL's I hope to release an initial working version in a few weeks.

1 Like