Command button is empty when isPromoted property is set to True

Command button is empty when isPromoted property is set to True

Anonymous
Not applicable
1,424 Views
3 Replies
Message 1 of 4

Command button is empty when isPromoted property is set to True

Anonymous
Not applicable

Hi,

 

I have another problem, this time with UI.

I'm making my own tool bar panel with single command button.

The problem is that when I set isPromoted value to True button appears in the Panel but it's empty. No icon, no tool tip, no action assigned to it. Just empty placeholder.

When I disable isPromoted then command button is availabe when I click on small arrow and it works as expected.

Is there any way to fix this and have button displayed in the panel?

 

buttonTheaExport = cmdDefs.addButtonDefinition('TheaExportDefIdPython', 'Export to Thea', 
                                                    'Export to Thea',
                                                    './/Resources//theaExport')
        
# Connect the command created event.
TheaExportCommandCreated = TheaExportCommandCreatedEventHandler()
buttonTheaExport.commandCreated.add(TheaExportCommandCreated)
handlers.append(TheaExportCommandCreated)

# Create new panel
theaPanel = ui.toolbarPanels.add('theaPanelId', 'Thea Render')
exportControl = theaPanel.controls.addCommand(buttonTheaExport, 'TheaExportCmdDefControl')        
exportControl.isPromoted = True
exportControl.isPromotedByDefault = True

 

0 Likes
Accepted solutions (1)
1,425 Views
3 Replies
Replies (3)
Message 2 of 4

david_reaume
Autodesk
Autodesk

grzyboo,

 

I cannot see anything wrong with your code in the context of the snippet you shared.  Can you post the entire script?

 

DaVeR

DaVeR
0 Likes
Message 3 of 4

zhijie.li
Alumni
Alumni
Accepted solution

Hi,

 

This is a known issue that the command id should be the same as the ButtonDefinition id, otherwise the promoted comand control will be blank because the command cannot be connected with the button definition in Fusion. Please try the following code:

 

buttonTheaExport = cmdDefs.addButtonDefinition('TheaExportDefIdPython​', 'Export to Thea',
                                                    'Export to Thea',
                                                    './/Resources//theaExport')
       
# Connect the command created event.
TheaExportCommandCreated = TheaExportCommandCreatedEventHandler()
buttonTheaExport.commandCreated.add(TheaExportComm​andCreated)
handlers.append(TheaExportCommandCreated)

# Create new panel
theaPanel = ui.toolbarPanels.add('theaPanelId', 'Thea Render')
exportControl = theaPanel.controls.addCommand(buttonTheaExport, 'TheaExportDefIdPython​')  # The id of the command is changed.
exportControl.isPromoted = True
exportControl.isPromotedByDefault = True

 

In our comming release, the design of the API method "addCommand" is changed. And then you doesn't need to set the id when "addCommand". And the command control's id will inherit from the button definition. So in our next release, you just need to call the function like this: exportControl = theaPanel.controls.addCommand(buttonTheaExport)

 

Sorry for inconvenience

 

Best regards,

Zhijie

Message 4 of 4

Anonymous
Not applicable
Thanks, now it works as expected.
0 Likes