Can Pyrevit create a drop-down list button?

Hello;

Can I use Pyrevit to create a drop-down list box button like the out-of-box control shown below?

Sincerely;
Michelle

Drop Down List Button

Hi @Michelle,
Using a folder_name.pulldown folder containing your buttons (pushbutton, url, …) will do the trick

checkout the revision pulldown in pyrevit

look at the structure of the folders that will help you

Hello Jean-Marc;

If I understand your answer correctly, you are referring to this on the standard pyrevit toolbar:

This pulldown contains a list of buttons.

I am hoping for a list of checkboxes with info pulled from the current Revit file and/or session.

Can pyrevit “buttons” be made to look like checkboxes?

Sincerely;
Michelle

something close would be the smartbutton folder extension and you could use a icon for the state of the icon that looks like a check box: empty and ticked. Quick and easy but not a real check box BUT the behaviour would be similar.

foldername.pulldown → button1.smartbutton, button2.smartbutton, etc.

Hello;

Sorry to be so late to come back to this but real life (ie work) just keeps getting in the way.

I have created a pull-down as shown: (Note the print statements)
image

using smartbuttons and this script:

from pyrevit import script
from pyrevit.compat import winreg as wr
from pyrevit.coreutils.ribbon import ICON_MEDIUM


logger = script.get_logger()




# noinspection PyUnusedLocal
def __selfinit__(script_cmp, ui_button_cmp, __rvt__):
    on_icon = script_cmp.get_bundle_file('on.png')
    off_icon = script_cmp.get_bundle_file('off.png')
    print "Init"

    return True


def toggle_state():
   print "toggle state"

if __name__ == '__main__':
    toggle_state()

For this to be useful to me as a checklist, I need to have each of the button’s name and/or icon to change when the “TestList” pulldown is pushed and before the buttons are displayed.

Can PyRevit do this? Or should I look for another approach?

Sincerely;
Michelle

quick (note so quick to make as I did not know this area of the Reit API) sample code to change the display name of a button on the fly

  • replace the ‘YourRibbonPanelName’
  • replace ‘foo’ by the name you are looking for and ‘bar’ by the expected name change
from pyrevit import HOST_APP

uiapp = HOST_APP.uiapp

rp = uiapp.GetRibbonPanels('YourRibbonPanelName')

for panel in rp:
    for item in panel.GetItems():
        if item.Text == "foo":
            item.ItemText = "bar"

you can change the icon and add pushbutton on the fly from reading this example RevitSdkSamples/Ribbon.cs at master · jeremytammik/RevitSdkSamples · GitHub