I've gone through the page you mentioned previously.
But what I'm trying to do is get the toolbarPanel of the Active workspace and add a split button to it, with a main command definition shown and a couple of other command definitions in the drop down. I've done the list of command definitions as you told me but I am getting the error "Internal validation: res".
This ONLY happens when I'm using the "addSplitButton" method, like so: newPanel.controls.addSplitButton(buttonExample, additionalDefinitions, False)
However, if I use the "addCommand" method, it works perfectly fine, for each command definition in the list, like so: newPanel.controls.addCommand(buttonExample)
So, I think it is how you said, the Split Button functionality is not supported?
Source Code:
def run(context):
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
# Get the UserInterface object and the CommandDefinitions collection.
app = adsk.core.Application.get()
ui = app.userInterface
cmdDefs = ui.commandDefinitions
# Create a button command definition.
# Get the existing command definition or create it if it doesn't already exist.
buttonExample = _ui.commandDefinitions.itemById('MyButtonDefId')
if not buttonExample:
buttonExample = cmdDefs.addButtonDefinition('MyButtonDefId', 'Sample Button',
'Sample button tooltip')
buttonExample2 = _ui.commandDefinitions.itemById('MyButtonDefId2')
if not buttonExample2:
buttonExample2 = cmdDefs.addButtonDefinition('MyButtonDefId2', 'Sample Button2',
'Sample button tooltip2')
buttonExample3 = _ui.commandDefinitions.itemById('MyButtonDefId3')
if not buttonExample3:
buttonExample3 = cmdDefs.addButtonDefinition('MyButtonDefId3', 'Sample Button3',
'Sample button tooltip3')
# Connect to the command created event.
onCommandCreated = MyCommandCreatedHandler()
buttonExample.commandCreated.add(onCommandCreated)
buttonExample2.commandCreated.add(onCommandCreated)
buttonExample3.commandCreated.add(onCommandCreated)
_handlers.append(onCommandCreated)
# Get the ADD-INS panel in the model workspace.
addInsPanel = ui.allToolbarPanels.itemById('SolidScriptsAddinsPanel')
# Add the button to the bottom.
buttonControl = addInsPanel.controls.addCommand(buttonExample)
# Make the button available in the panel.
buttonControl.isPromotedByDefault = True
buttonControl.isPromoted = True
additionalDefinitions = []
additionalDefinitions.append(buttonExample2)
additionalDefinitions.append(buttonExample3)
ActiveWorkspace = ui.activeWorkspace
WorkspacePanels = ActiveWorkspace.toolbarPanels
newPanel = WorkspacePanels.itemById('UTEPPanel3')
if not newPanel:
newPanel = WorkspacePanels.add('UTEPPanel3', 'UTEP PANEL2')
#newPanel.controls.addSplitButton(buttonExample, additionalDefinitions, False) #GIVES ME RuntimeError 2: InternalValidationError: res
newPanel.controls.addCommand(buttonExample)
newPanel.controls.addCommand(buttonExample2)
newPanel.controls.addCommand(buttonExample3)