0

I'm trying to use the revit api events on my iron python addins (using pyRevit to add the ribbon and pushbuttons) but I don't really understand what to do.

I found this piece of code but I couldn't make it work. For starters, I'd like to print "View activated" each time a view is activated

https://github.com/eirannejad/pyRevit/issues/201

from System import EventHandler, Uri
from Autodesk.Revit.UI.Events import ViewActivatedEventArgs, ViewActivatingEventArgs

def event_handler_function(sender, args):
   # do the even stuff here

# I'm using ViewActivating event here as example.
# The handler function will be executed every time a Revit view is activated:
__revit__.ViewActivating += EventHandler[ViewActivatingEventArgs](event_handler_function)

Thanks,

G-BC
  • 101
  • 1
  • 10

2 Answers2

1

You can look a the Revit SDK sample Events/EventsMonitor. It shows you how to subscribe to many Revit events in C#, including ViewActivating. The subscription mechanism and functionality is identical in all .NET languages.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
-1

have you checked the latest documentation?

According to the wiki, you just need to create a .py/.cs file under a folder named hook and name the file as the event you want to use.

Pablo D.
  • 26
  • 4