Questions Regarding the Table Command Input

Questions Regarding the Table Command Input

Anonymous
Not applicable
805 Views
3 Replies
Message 1 of 4

Questions Regarding the Table Command Input

Anonymous
Not applicable

Hello, I have a couple of question about the Table Command Input.

First question, why is it that after creating 4 tables with content, if I create any more tables, the ones after the fourth one are empty. For example, I try to create 7, but the last 3 are empty, like in the picture below.

Also, in order to select a table row, why do I have to click the top right corner of it to select it, versus clicking anywhere in the row/cell. It is hard, as it is a very small area to click.

fusion360image1.jpg

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

ekinsb
Alumni
Alumni
Accepted solution

I'm not able to reproduce the problems you described.  Below is my simple command dialog with eight tables.  I'm also able to select a row by selecting anywhere within a cell.

TableTest.png

 

 

Here's the full code of my test script:

 

import adsk.core, adsk.fusion, adsk.cam, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)
_handlers = []


# Event handler for the execute event.
class MyExecuteHandler(adsk.core.CommandEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            _ui.messageBox('Command executed.')
        except:
            if _ui:
                _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


# Event handler for the destroy event.
class MyDestroyHandler(adsk.core.CommandEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        adsk.terminate()
        

# Event handler for the commandCreated event.
class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            eventArgs = adsk.core.CommandCreatedEventArgs.cast(args)
            inputs = adsk.core.CommandInputs.cast(eventArgs.command.commandInputs)
    
            # Create the table.
            tableCount = 0
            textBoxCount = 0
            for i in range(8):               
                table = adsk.core.TableCommandInput.cast(inputs.addTableCommandInput('table' + str(tableCount), 'Inputs', 2, '1:1'))
                table.minimumVisibleRows = 3
                table.maximumVisibleRows = 3
                table.columnSpacing = 1
                table.rowSpacing = 1
                table.tablePresentationStyle = adsk.core.TablePresentationStyles.itemBorderTablePresentationStyle
                table.hasGrid = True                    
                tableCount += 1
                
                # Create a selection command input and add it to the table.
                for j in range(3):
                    text = inputs.addStringValueInput('texta' + str(textBoxCount), 'Text ' + str(textBoxCount), 'Text ' + str(textBoxCount))
                    text.isReadOnly = True
                    table.addCommandInput(text, j, 0, False, False)

                    text = inputs.addStringValueInput('textb' + str(textBoxCount), 'Text ' + str(textBoxCount), 'Some more text ' + str(textBoxCount))
                    text.isReadOnly = True
                    table.addCommandInput(text, j, 1, False, False)
                    textBoxCount += 1
        
            # Connect to command execute.
            onExecute = MyExecuteHandler()
            eventArgs.command.execute.add(onExecute)
            _handlers.append(onExecute)
            
            # Connect to the command terminate.
            onDestroy = MyDestroyHandler()
            eventArgs.command.destroy.add(onDestroy)
            _handlers.append(onDestroy)            
        except:
            if _ui:
                _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
        

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui  = _app.userInterface
        
        # Create a command.
        cmd = _ui.commandDefinitions.itemById('tableTest')
        if cmd:
            cmd.deleteMe()
            
        cmd = _ui.commandDefinitions.addButtonDefinition('tableTest', 'Table Test', 'Table Test', '')
        
        # Connect to the command create event.
        onCommandCreated = MyCommandCreatedHandler()
        cmd.commandCreated.add(onCommandCreated)
        _handlers.append(onCommandCreated)
        
        # Execute the command.
        cmd.execute()
        
        # Set this so the script continues to run.
        adsk.autoTerminate(False)

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

 

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 4

Anonymous
Not applicable

Thank you Brian, through your answer I solved my problem.
So, I was able to solve my problem by changing the 

table.minimumVisibleRows to 0
and table.maximumVisibleRows = len(MyList)

Thank you very much.

0 Likes
Message 4 of 4

kandennti
Mentor
Mentor

I am confused because the grid display is misaligned.
Fixed a part of the reference code.

 

・・・
class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
・・・
            tableCount = 0
            textBoxCount = 0
            for i in range(1): # **** here ****
                table = adsk.core.TableCommandInput.cast(inputs.addTableCommandInput('table' + str(tableCount), 'Inputs', 2, '1:1'))
                table.minimumVisibleRows = 3
                table.maximumVisibleRows = 20 # **** here ****
                table.columnSpacing = 1
                table.rowSpacing = 1
                table.tablePresentationStyle = adsk.core.TablePresentationStyles.itemBorderTablePresentationStyle
                table.hasGrid = True                    
                tableCount += 1
                
                # Create a selection command input and add it to the table.
                for j in range(20): # **** here ****
                    text = inputs.addStringValueInput('texta' + str(textBoxCount), 'Text ' + str(textBoxCount), 'Text ' + str(textBoxCount))
                    text.isReadOnly = True
                    table.addCommandInput(text, j, 0, False, False)
・・・

1.png

 

When maximumVisibleRows is set to a large value,
The display position of the grid will be greatly displaced.

 

Are there any countermeasures?

0 Likes