When Or How does the MinifyUI icon change?


As a prelude to modifying the the MinifyUI tool that comes with PyRevit, I copied the MinifyUI directory and files to a branch of my custom PyRevit ribbon.

On opening a Revit file, I notice that both the icon on both the PyRevit ribbon and my own are black. If I then use the command on the PyRevit toolbar, the icon changes color. All well and good. And as expected. However the surprising thing is the icon on the copy of the MinifyUI button on my ribbon also changed color.

So my question is why? Is there event associated with my copy of the command that is being triggered? Or perhaps, both the original and the copy are sharing the same code in memory?

How can I prevent this from happening? Or on the other hand, exploit this behavior?


the minify ui state is a pyRevit Environment Variable. therefore the button in your tab controls it as well

you could trick it by changing the ENV VAR from MINIFYUI_ENV_VAR to something else in the minifyui.py python script located in your copy of the button (there might be some more changes, I haven’t tried it)

Hello Jean-Marc;

Thankyou for the quick response. I saw the reference in the script file about the environment variable but I think I must be missing something.

My understanding is that the process of the minifyUI icon goes like this:

  • {user pushes button on my ribbon} →
  • {PyRevit system catches that event and calls script located at “…\User Interface.panel\UI.stack\MinifyUI.smartbutton”} →
  • {the Script.py file in turn calls MinifyUI.py} →
  • {MinifyUI.py eventually gets to the function “toggle_minifyui” which changes the icon of the button that was pushed.

Yet, I notice that the icon of the button on the PyRevit ribbon also changed - this is a button that was NOT pushed by user. Therefore, the “toggle_minifyui” function for this button should not have been called. So why did the icon change? What am I missing?


Hmmm…I guess what I was missing was the name of the button. Changing the directory name broke the behavior I was seeing - the two buttons now act separately. Apparently, pyRevit (or maybe Revit) treats two buttons with the same name on different ribbons as sort-of, but not exactly, as the same object.

I’ll probably need to prefix my button names with something to avoid this issue and use the yaml file for the button title.


1 Like