Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Table problems

Message 1 of 7
306 Views, 6 Replies

Table problems

Problem 1: As shown in the picture below, the input boxes do not line up properly with grid.

Nor do the words under "Plate" stay centered in the grid. They keep moving lower and lower.

Not a big deal but noticeable, and depending on the length of the list, it could be a problem.

Screenshot (56).png

























Problem 2: Next, I click on row 1 in the table, "CP Plate" then click a body in the mold base which fills in the blanks with the current part name and number.

I fill in the blanks with what I want the part number and name I want it to be.

When I am satisfied with my in put I click on row 2, "A Plate" and click on the A plate in the assembly.

Screenshot (58).png
























When I click on the next "A Plate", it fills in the blanks as before, but deletes row 1,

Every time I change rows and click a different plate, it deletes the previous plate no matter what order I have clicked on them.

Th following is the lines of code I believe is the problem.

213    if == 'body':
214        if table_input.selectedRow == -1:
215            ui.messageBox('Select one row to change.')
216        else:
217            selection_input = inputs.itemById('body')
218            rowSelection = table_input.selectedRow
219            row = rowSelection
220            plateSelection = selection_input.selection(0).entity.parentComponent
221            for i in range(1, len(moldPlatesList) - 1):
222                if i == rowSelection:
223                    _inputStringNum.value =
224                    _inputStringName.value = plateSelection.partNumber
225                    table_input.removeInput(rowSelection, 1)
226                    table_input.removeInput(rowSelection, 2)
227                    table_input.addCommandInput(_inputStringNum, rowSelection, 1, 0)
228                    table_input.addCommandInput(_inputStringName, rowSelection, 2, 0)

I have gone through debugging and do not see anything.

I have verified the value of rowSelection

I have to do lines 225 & 226 before 227 & 228 or I get an error message.

It just keeps looping through this same  code set.

This started with the Table section of code from the Add-in "CommandSample" by Patrick Rainsberry for Autodesk.

The entire code package is attached, just keep in mind that this is still in development and this is my stumbling point right now.

Any assembly will work, this is just being made for plastic injection mold assemblies.

Brad Bylls
Message 2 of 7
in reply to: brad.bylls

Hi @brad.bylls .


I too have had problems in the past, but could not find a way other than to stop the display of the grid.


Message 3 of 7

Hi @brad.bylls ,


I believe the rows misalignment problems is due to the TableCommandInput's rowSpacing property which is set to 1 pixel by default.

If you set to 0 pixels, it will look like so:



You just need to add one line to you table definition section:



Note 1: I strongly recommend you to use standard named enums instead of their assigned value, just for compatibility in future versions.   I'm taking about tablePresentationStyle's property value.

Note 2: if your .csv file is not changing dynamically (I mean, during the add-in running period) you can replace it by a .py file, defining the configuration as a dictionary inside it and importing it at the beginning of the code.  Then you'll have all configuration available in memory and you can get rid of all file reading operations.  Something like:


            'A Series': ('CP Plate','A Plate','B Plate','SU Plate','BCP Plate','ER Plate','EB Plate','Riser L','Riser R'),
            'B Series': ('A Plate','B Plate','BCP Plate','ER Plate','EB Plate','Reiser L','Riser R'),
            # ......



Hope this could help.


Best regards,

Jorge Jaramillo

Message 4 of 7

Thanks Jorge.

They both work good.

Brad Bylls
Message 5 of 7
in reply to: brad.bylls

I have included a video to explain my problem.

The code is included.

Thanks in advance.

Brad Bylls
Message 6 of 7

Hi @brad.bylls ,


You don't need to delete and re-create the command inputs; just changes its values like so:


def revise_row_to_table(table_input: adsk.core.TableCommandInput):
    global row, ROW_NUMBER, _inputStringNum, _inputStringName, tableInputs, plateSelection, \
        rowSelection, previousRow
    # Get the CommandInputs object associated with the parent command.
    tableInputs = adsk.core.CommandInputs.cast(table_input.commandInputs)
    selection_input: adsk.core.SelectionCommandInput = inputs.itemById('body')
    if selection_input.selectionCount:
        rowSelection = table_input.selectedRow
        # previousRow = rowSelection
        plateSelection = selection_input.selection(0).entity.parentComponent
        # for i in range(1, len(moldPlatesList) - 1):
        #     if i == rowSelection:
        # _inputStringNum.value = plateSelection.partNumber
        # _inputStringName.value =
        # table_input.removeInput(rowSelection, 1)
        # table_input.removeInput(rowSelection, 2)
        # table_input.addCommandInput(_inputStringNum, rowSelection, 1, 0)
        # table_input.addCommandInput(_inputStringName, rowSelection, 2, 0)
        input_num: adsk.core.StringValueCommandInput = table_input.getInputAtPosition(rowSelection,1)
        input_name: adsk.core.StringValueCommandInput = table_input.getInputAtPosition(rowSelection,2)
        input_num.value = plateSelection.partNumber
        input_name.value =

    # Increment a counter used to make each row unique.
    # ROW_NUMBER += 1
    # row += 1



It worked for me:




Hope this could help.



Jorge Jaramillo

Message 7 of 7


Thank you.

That works perfectly and I went and finished the app for the customer.

Brad Bylls

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report