Reported by users of ParametricText add-in as well: https://github.com/thomasa88/ParametricText/issues/47
It seems that full width is now enabled by default, or the possibility to show the name has been removed, as the name specified in addTableCommandInput() does not show up.
Fusion versions:
- 2.0.15291 x86_64
- 2.0.15293
Here is a reproduction using a modified version of the Command Inputs Sample script:
Error:
c:\Users\Thomas\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\Scripts\Command API Inputs sample
Failed:
Traceback (most recent call last):
File "C:/Users/Thomas/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/Command API Inputs sample/Command API Inputs sample.py", line 46, in notify
tableInput.isFullWidth = True
File "C:\Users/Thomas/AppData/Local/Autodesk/webdeploy/production/b266364513c09873dd62d7f39897939da3664358/Api/Python/packages\adsk\core.py", line 6144, in _set_isFullWidth
return _core.CommandInput__set_isFullWidth(self, value)
RuntimeError: 2 : InternalValidationError : control
Code:
#Author-Autodesk Inc.
#Description-Demo command input examples
import adsk.core, adsk.fusion, traceback
_app = None
_ui = None
_rowNumber = 0
# Global set of event handlers to keep them referenced for the duration of the command
_handlers = []
# Event handler that reacts to when the command is destroyed. This terminates the script.
class MyCommandDestroyHandler(adsk.core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
# When the command is done, terminate the script
# This will release all globals which will remove all event handlers
adsk.terminate()
except:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
# Event handler that reacts when the command definitio is executed which
# results in the command being created and this event being fired.
class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
# Get the command that was created.
cmd = adsk.core.Command.cast(args.command)
# Connect to the command destroyed event.
onDestroy = MyCommandDestroyHandler()
cmd.destroy.add(onDestroy)
_handlers.append(onDestroy)
# Get the CommandInputs collection associated with the command.
inputs = cmd.commandInputs
# Create table input
tableInput = inputs.addTableCommandInput('table', 'Table Name', 3, '1:1:1')
tableInput.isFullWidth = True
except:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
print('Failed:\n{}'.format(traceback.format_exc()))
def run(context):
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
# Get the existing command definition or create it if it doesn't already exist.
cmdDef = _ui.commandDefinitions.itemById('cmdInputsSample')
if not cmdDef:
cmdDef = _ui.commandDefinitions.addButtonDefinition('cmdInputsSample', 'Command Inputs Sample', 'Sample to demonstrate various command inputs.')
# Connect to the command created event.
onCommandCreated = MyCommandCreatedHandler()
cmdDef.commandCreated.add(onCommandCreated)
_handlers.append(onCommandCreated)
# Execute the command definition.
cmdDef.execute()
# Prevent this module from being terminated when the script returns, because we are waiting for event handlers to fire.
adsk.autoTerminate(False)
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
edit: getter is also broken:
Failed:
Traceback (most recent call last):
File "C:/Users/Thomas/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/Command API Inputs sample/Command API Inputs sample.py", line 46, in notify
_ui.messageBox(str(tableInput.isFullWidth))
File "C:\Users/Thomas/AppData/Local/Autodesk/webdeploy/production/b266364513c09873dd62d7f39897939da3664358/Api/Python/packages\adsk\core.py", line 6135, in _get_isFullWidth
return _core.CommandInput__get_isFullWidth(self)
RuntimeError: 2 : InternalValidationError : control
My workaround:
# Fusion 2.0.15291 breaks isFullWidth. Exception: RuntimeError: 2 : InternalValidationError : control
# Bug: https://forums.autodesk.com/t5/fusion-360-api-and-scripts/bug-update-now-throws-exception-setting-isfullwidth-on/m-p/11725404
try:
table_input.isFullWidth = True
except RuntimeError:
pass