LearnRevitAPI

Oct 23, 2024

Button Modes in pyRevit

I want to share a little secret in pyRevit, that many of you haven't even heard of. Did you know you can execute different code if you use:Regular ClickShift + ClickCTRL + ClickIf you hear this for the first time, let me tell you how it can benefit your tools.

Prefer Video? Click here to watch it.

Shift-Click

The idea for a Shift-Click is to provide alternative execution code or adjust the config for the script.

This gives you more options on how the script is executed or allow users to adjust settings of how the button is run.

You can try it out yourself on default pyRevit tools.
Try Minify Revit UI for example. This will give you a menu to configure what should be hidden in Revit.

Most importantly, it's not complicated.

Here is a simple snippet that you can use in your code to execute different code for Regular or Shift Clicks.

CTRL-Click

The idea for a CTRL + Click is to run the script in the DEBUG mode and allow you to print all debug messages and help you solve issues. But you can also use it for alternative execution mode.

In general, you don't have to delete all print statements after development. Instead you can print them only in the debug mode, so it's easier to test it later.


Let's update the previous snippet and add here the CTRL Click as well:

Summary

Now you can use these statements in your scripts to provide additional functionality or to have debug mode for yourself.

Either way, I think it's great to have this functionality for certain types of tools. I hope you will find it useful.

✨ Testimonial Highlight

Carlos Rothmann has recently tried my Free EF-pyRevit StarterKit and here is what he has to say:

You can also share your testimonial here.
Thanks in advance, it's 100% Appreciated.


P.S.

If you want to Learn Revit API but you don't want to waste time - follow my step by step roadmap and be a part of exclusive Revit API Community. Check out Learn Revit API Course.

You will get access to:

  • LearnRevitAPI Course

  • Exclusive Revit API Community

  • Upcoming WPF Course (in Nov)

  • Upcoming Python Course (TBA)

  • All Course Updates

Click Here to Join (Last chance to get Lifetime Access)

Enjoyed Newsletter?

Leave a Testimonial Here.

⌨️ Happy Coding!
Erik Frits

Join Newsletter

📩 You will be added to Revit API Newsletter

Join Us!

which is already read by 7400+ people!