Hi @MarkBrouwersY48AV -San.
Perhaps that is not possible.
It seems that the events of the Command object have a role to play, not simply a different timing when they occur.
It seems that it is only within the commandCreated event handler that the name property of IntegerSliderCommandInput can be changed, as in this case.
As an alternative, I created a sample.
The only way to do this is to prepare the IntegerSliderCommandInput corresponding to the ComboBox (DropDownCommandInput) in advance and show/hide it.
# Fusion360API Python script
import traceback
import adsk
import adsk.core as core
_app: core.Application = None
_ui: core.UserInterface = None
_handlers = []
CMD_INFO = {
'id': 'kantoku_test',
'name': 'test',
'tooltip': 'test'
}
_dDownIpt: core.DropDownCommandInput = None
_sliderA: core.IntegerSliderCommandInput = None
_sliderB: core.IntegerSliderCommandInput = None
_sliderC: core.IntegerSliderCommandInput = None
class MyCommandCreatedHandler(core.CommandCreatedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: core.CommandCreatedEventArgs):
core.Application.get().log(args.firingEvent.name)
try:
global _handlers
cmd: core.Command = core.Command.cast(args.command)
inputs: core.CommandInputs = cmd.commandInputs
onDestroy = MyCommandDestroyHandler()
cmd.destroy.add(onDestroy)
_handlers.append(onDestroy)
onInputChanged = MyInputChangedHandler()
cmd.inputChanged.add(onInputChanged)
_handlers.append(onInputChanged)
global _dDownIpt
_dDownIpt = inputs.addDropDownCommandInput(
"_dDownIptId",
"Choice",
core.DropDownStyles.TextListDropDownStyle
)
dDownItems: core.ListItems = _dDownIpt.listItems
dDownItems.add("A", True)
dDownItems.add("B", False)
dDownItems.add("C", False)
global _sliderA
_sliderA = inputs.addIntegerSliderCommandInput(
"_sliderAid",
"A",
0,
10,
)
global _sliderB
_sliderB = inputs.addIntegerSliderCommandInput(
"_sliderBid",
"B",
0,
10,
)
_sliderB.isVisible = False
global _sliderC
_sliderC = inputs.addIntegerSliderCommandInput(
"_sliderCid",
"C",
0,
10,
)
_sliderC.isVisible = False
except:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
class MyInputChangedHandler(adsk.core.InputChangedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: core.InputChangedEventArgs):
global _dDownIpt
if args.input != _dDownIpt: return
global _sliderA, _sliderB, _sliderC
selectName = _dDownIpt.selectedItem.name
if selectName == "A":
_sliderA.isVisible = True
_sliderB.isVisible = _sliderC.isVisible = False
elif selectName == "B":
_sliderB.isVisible = True
_sliderA.isVisible = _sliderC.isVisible = False
elif selectName == "C":
_sliderC.isVisible = True
_sliderA.isVisible = _sliderB.isVisible = False
class MyCommandDestroyHandler(core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args: core.CommandEventArgs):
core.Application.get().log(args.firingEvent.name)
adsk.terminate()
def run(context):
try:
global _app, _ui
_app = core.Application.get()
_ui = _app.userInterface
cmdDef: core.CommandDefinition = _ui.commandDefinitions.itemById(
CMD_INFO['id']
)
if not cmdDef:
cmdDef = _ui.commandDefinitions.addButtonDefinition(
CMD_INFO['id'],
CMD_INFO['name'],
CMD_INFO['tooltip']
)
global _handlers
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()))
If you want to create more flexible dialogs, we recommend using Palette or BrowserCommandInputs.
However, knowledge of html and javascript is required.