RevitAPI: Revit文件打开被升级之后,Document.IsModified却返回False?


有个客户用新的Revit打开一个旧的文件,那么文件会被升级,升级之后,他认为Document.IsModified应该返回True,但实际上,返回值却是False.


If we useApplication.OpenDocumentFile to open a previous Revit version RFA family (i.ewe open a Revit 2013 family from Revit 2015),the family is correctly convertedto Revit 2015 format but Document.IsModified is falseIthink that in this case Document.IsModified should be true as the family hasbeen obviously modified (upgrade to a new Revit format)


对此我们开发部的同事Arnošt做出的解释是:

升级之后,该文件是一个和旧文件信息相同的新的文件,从Revit的角度看,并没有任何从用户那边来的修改,所以返回False应该是期望的行为。


Document.IsModified was correct to be returning False, since when you open a 2013 document on a newer version of Revit, from the Revit perspective, the document has not been modified by the end user. It has become a new Document with the information of the Old one. If you open a document that upgrades,it would prompt the user to save in the new format before closing even if nothing else (beside the upgrade) was modified.This being the reason on why the IsModified property will return False. The API just mimics the behavior of the modification.


或许我们有其他的办法。

我们知道Application.VersionName是用来拿当前Revit的版本信息的。

而另外一个类BasicFileInfo可以通过SavedInVersion属性获取当时保存该文档的Revit的版本信息。

我们通过比较这两个值是不是一样就可以判断这个文档是否被升级了。示例代码如下:

var verionName = RevitApp.VersionName; //<==Autodesk Revit 2015
if(File.Exists(RevitDoc.PathName))
{
    var info = BasicFileInfo.Extract(RevitDoc.PathName);
    var docVer = info.GetDocumentVersion();
    var savedInVersion = info.SavedInVersion; //<==Autodesk Revit 2014
    if (verionName != savedInVersion)
    {
        // should be an upgraded document!
    }
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值