Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Command button is empty when isPromoted property is set to True

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
grzyboo
444 Views, 3 Replies

Command button is empty when isPromoted property is set to True

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

 

3 REPLIES 3
Message 2 of 4
david_reaume
in reply to: grzyboo

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
Message 3 of 4
zhijie.li
in reply to: grzyboo

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
grzyboo
in reply to: zhijie.li

Thanks, now it works as expected.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report