WPF interface and EventHandler

Hello everyone!
I want to automatically update my active non-modal WPF form every time, for example, I change the active view. At the moment I need to create a button and press it manually
Is it possible to achieve such an automatic refresh with pyrevit?

Thanks for help

@DmytroSE Take a look at this bundle in pyRevit Dev extension

@eirannejad many thanks, that helped a lot!
Somehow missed that example

If someone needs, here is what we need in the code:

1 Like

@DmytroSE This is great thanks for sharing here. The @revit.events.handle() decorator was something I started a while ago as a way of tying a python function to Revit handlers. I have only implemented these 4 events but more could also be added to revit/events.py module

1 Like

@eirannejad I found a little issue. When I run the WPF form with a smartbutton eventhandler(revit document opened) the @revit.events.handle() decorator is not working. Need to re-open my script manually
Here is a link:


and code:

Thanks for the example @DmytroSE , looks like it works for me too.
I’ve got some followup questions though.

  1. Is it normal that the window_closing function doesn’t output anything when I put a print statement in there? I wanted to check if it was called. Didn’t do anything

  2. What software do you use to design you xaml files? Right now I’m using VS, but I’m looking into a free opensource replacement.

You’re welcome! I use Sharp Develop, but it is very unstable and has many errors. So I don’t know what else to recommend

1 Like