Revit API注册事件

start
using Autodesk.Revit.DB.Events;
//http://revit.haotui.com
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
public class App : IExternalApplication
{
    public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)
    {
        application.ControlledApplication.DocumentChanged += new EventHandler<DocumentChangedEventArgs>(app_Doc_Change);

        return Autodesk.Revit.UI.Result.Succeeded;
    }

    public Autodesk.Revit.UI.Result OnShutdown(UIControlledApplication application)
    {
        return Autodesk.Revit.UI.Result.Succeeded;
    }

    public void app_Doc_Change(object sender, DocumentChangedEventArgs args)
    {
        Document doc = args.GetDocument();
        TaskDialog.Show("info", doc.PathName);
    }
}
end
posted @ 2014-02-27 12:15  大气象  阅读(1843)  评论(0编辑  收藏  举报
http://www.tianqiweiqi.com