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:ย 

Trouble removing item from TableCommandInput

Message 1 of 1
96 Views, 0 Replies

Trouble removing item from TableCommandInput

I have a table with some conditional commandInputs. In this example, clicking a checkbox should swap one textbox in the table for another. I'm doing this by removing the commandInput from the table via the removeInput method and then adding the new input to the table at that position. The following Python code should demonstrate the issue:


def command_created(args: adsk.core.CommandCreatedEventArgs๐Ÿ˜ž

    inputs = args.command.commandInputs

    global table
    global textBoxOn
    global textBoxOff

    table = inputs.addTableCommandInput('table', 'Table', 2, '1:1')
    toggleInput = inputs.addBoolValueInput('toggle', 'Toggle', True, '', True)

    textBoxOn = inputs.addTextBoxCommandInput('textBox_on', 'TextBox On', 'ON', 1, True)
    textBoxOff = inputs.addTextBoxCommandInput('textBox_off', 'TextBox Off', 'OFF', 1, True)

    table.addCommandInput(toggleInput, 0, 0, 0, 0)
    table.addCommandInput(textBoxOn, 0, 1, 0, 0)
    # Not adding textBoxOff because we don't want it in the table yet

    futil.add_handler(args.command.inputChanged, command_input_changed, local_handlers=local_handlers)
def command_input_changed(args: adsk.core.InputChangedEventArgs๐Ÿ˜ž
    global table
    global textBoxOn
    global textBoxOff

    if == 'toggle':
        table.removeInput(0, 1) # Should not delete the TextBox, only remove it from the table
        if adsk.core.BoolValueCommandInput.cast(args.input).value:
            table.addCommandInput(textBoxOn, 0, 1, 0, 0)
            table.addCommandInput(textBoxOff, 0, 1, 0, 0)
gives the error:

RuntimeError: 4 : An API Object refers to a deleted Object


This would make sense if the documentation for the removeInput method didn't explicitly state that removed inputs aren't deleted from the parent's commandInputs. Am I missing something? Or am I encountering a bug?




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

Post to forums  

Technology Administrators

Autodesk Design & Make Report