0

我正在尝试在我的 Iron python 插件上使用 revit api 事件(使用 pyRevit 添加功能区和按钮),但我真的不明白该怎么做。

我找到了这段代码,但我无法让它工作。对于初学者,我想在每次激活视图时打印“视图已激活”

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)

谢谢,

4

2 回答 2

1

您可以查看 Revit SDK 示例Events/EventsMonitor。它向您展示了如何在 C# 中订阅许多 Revit 事件,包括ViewActivating. 所有 .NET 语言的订阅机制和功能都是相同的。

于 2020-03-07T19:57:34.537 回答
-1

你检查过最新的文档吗?

根据 wiki,您只需在名为 hook 的文件夹下创建一个 .py/.cs 文件,并将该文件命名为您要使用的事件。

于 2020-03-06T18:55:26.540 回答