做项目的时候,很多时候忘记保存,项目突然崩溃,一夜回到解放前,白做一早上甚至一天的工作,那种酸爽,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