Message 1 of 4
Not applicable
04-13-2016
08:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to access a selected item from a Text Drop down text box and use that as a key to a dictionary that will influence the input types I fill a second tab with.
However no item seems to be selected even though there was a change that activated the handler. How do I access the selected item in this list? Is it possible or are there work arounds?
Here are the handlers in m
class InputChangedHandler(adsk.core.InputChangedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
command = args.firingEvent.sender
cmdInput = args.input
if cmdInput.id == 'ObjectTypeSelection':
ui.messageBox('Input: {} changed event triggered for Object Selection'.format(command.parentCommandDefinition.id))
inputs = command.commandInputs
ui.messageBox("Input is valid: "+str(cmdInput.isValid))
objectItems = cmdInput.listItems
selection = None
for item in objectItems:
ui.messageBox(str(item.name)+"selected = "+str(item.isSelected))
if item.isSelected:
selection = item
break
ui.messageBox("selection: "+str(selection))
tabCmdInput2 = inputs.addTabCommandInput(commandIdOnPanel + '_tab_2', 'Define your ')
# tab1ChildInputs = tabCmdInput2.children
except:
if ui:
ui.messageBox('Input changed event failed: {}'.format(traceback.format_exc()))
class CommandExecuteHandler(adsk.core.CommandEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
command = args.firingEvent.sender
ui.messageBox('command: {} executed successfully'.format(command.parentCommandDefinition.id))
except:
if ui:
ui.messageBox('command executed failed: {}'.format(traceback.format_exc()))
class CommandCreatedEventHandlerPanel(adsk.core.CommandCreatedEventHandler):
def __init__(self):
super().__init__()
def notify(self, args):
try:
cmd = args.command
onExecute = CommandExecuteHandler()
cmd.execute.add(onExecute)
onInputChanged = InputChangedHandler()
cmd.inputChanged.add(onInputChanged)
# keep the handler referenced beyond this function
handlers.append(onExecute)
handlers.append(onInputChanged)
# Keep the handler referenced beyond this function
inputs = cmd.commandInputs
# Create tab input 1
tabCmdInput1 = inputs.addTabCommandInput(commandIdOnPanel + '_tab_1', 'Object Type Selection')
tab1ChildInputs = tabCmdInput1.children
dropDownCommandInput = tab1ChildInputs.addDropDownCommandInput('ObjectTypeSelection', 'Select an Object Definition', adsk.core.DropDownStyles.TextListDropDownStyle)
dropDownItems = dropDownCommandInput.listItems
for objType in {"Bolt":"stuff"}:
dropDownItems.add(objType, False)
ui.messageBox('Panel command created successfully')
except:
if ui:
ui.messageBox('Panel command created failed: {}'.format(traceback.format_exc()))y code. Bolt should be shown as selected.
Solved! Go to Solution.


