Revit SDK 介绍:PrintLog 打印日志

前言

这个例子介绍了如何使用打印相关的事件。

内容

事件机制也是老生常谈了,Revit 提供了大量的可供注册的事件:Revit API:Events 事件总览

注册和 print 相关的事件:

// IExternalApplication.OnStartup
m_eventsReactor = new EventsReactor();
application.ControlledApplication.ViewPrinting += new EventHandler<Autodesk.Revit.DB.Events.ViewPrintingEventArgs>(m_eventsReactor.AppViewPrinting);
application.ControlledApplication.ViewPrinted += new EventHandler<Autodesk.Revit.DB.Events.ViewPrintedEventArgs>(m_eventsReactor.AppViewPrinted);
application.ControlledApplication.DocumentPrinting += new EventHandler<Autodesk.Revit.DB.Events.DocumentPrintingEventArgs>(m_eventsReactor.AppDocumentPrinting);
application.ControlledApplication.DocumentPrinted += new EventHandler<Autodesk.Revit.DB.Events.DocumentPrintedEventArgs>(m_eventsReactor.AppDocumentPrinted);

AppDocumentPrinting 中启动记录,在 AppDocumentPrinted 中输出执行时间。
AppViewPrinting 中启动记录,在 AppViewPrinted 中输出执行时间。

底层时间戳用了 .Net 的类 Stopwatch:

namespace System.Diagnostics
{
    public class Stopwatch
    {
        public static readonly long Frequency;
        public static readonly bool IsHighResolution;
        public Stopwatch();
        public bool IsRunning { get; }
        public TimeSpan Elapsed { get; }
        public long ElapsedMilliseconds { get; }
        public long ElapsedTicks { get; }
        public static long GetTimestamp();
        public static Stopwatch StartNew();
        public void Reset();
        public void Restart();
        public void Start();
        public void Stop();
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

极客BIM工作室

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值