Revit二开 自动保存

做项目的时候,很多时候忘记保存,项目突然崩溃,一夜回到解放前,白做一早上甚至一天的工作,那种酸爽,CNM~~~~!所以做一个自动保存功能,设定间隔时间实现自动保存文件。
直接上才艺:

设置功能-自动保存

在这里插入图片描述

代码如下:

   string oldDateTime = null;
  public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication app = commandData.Application;
            UIDocument uidoc =  app.ActiveUIDocument;
            Document doc = app.ActiveUIDocument.Document;
                 
            oldDateTime = DateTime.Now.ToShortTimeString();
            app.Idling += new EventHandler<IdlingEventArgs>(idleupdate);
            return Result.Succeeded;
        }
        public void idleupdate(object sender, IdlingEventArgs eventArgs)
        {
            UIApplication uIApplication = sender as UIApplication;
            Document doc = uIApplication.ActiveUIDocument.Document;
            string minu = "30";//保存间隔时间

            var issametime = DateTime.Now.ToShortTimeString() == DateTime.Parse(oldDateTime).AddMinutes(minu.ToDouble()).ToShortTimeString();

            if (issametime)
            {
                using (Transaction transaction = new Transaction(doc, "自动保存"))
                {
                    doc.Save();
                    eventArgs.SetRaiseWithoutDelay();
                }
               
                oldDateTime = DateTime.Now.ToShortTimeString();
            }
        }

在这里插入图片描述
在这里插入图片描述

分享一个自制Revit插件,本人是个BIM工程师,该插件是根据自己做工程一些经验和对插件功能的频繁度,自己整合开发功能,初衷是提高效率。
目前MagicTools的功能包括通用功能、土建、机电、审图、出图功能。还有好多功能都想做,如果有好的需求也可以提,后续有新增继续增加上去,努力弄个实用的插件,希望能帮到真正有需要的BIMer。
如有需要的可以加企鹅群:630552940

插件下载地址,免费试用
链接:https://pan.baidu.com/s/1GDnHeWwZ5r_HrnT3Mo7twA?pwd=jhlt
提取码:jhlt

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值