Revit API 开发(12): Revit 文件存储结构

整理(很多内容非原创,转载自网络)

链接来自 The Building Coder:
Open Revit OLE Storage
RVT File Version
RVT and RFA Thumbnail Image

主要问题

  • Revit 文件是什么结构?
  • 不启动 Revit,到底可以读取哪些内容?

Revit 文件结构

Revit 文件用的是一种微软提供的OLE存储格式,或者叫复合文件。
Microsoft Compound Document Files (also known as OLE structured storage).
如果想要自己写一个文件解析工具,可以参考微软提供的官方文档。
参考 The building Coder 的文章,通过解析,可以读到类似下面的数据:

  • DocType: Project
  • WorkSharing: NotEnabled
  • IsCentralFile: False
  • UserName: tammikj
  • CentralFilePath:
  • RevitBuild: Autodesk Revit Architecture 2011 (Build: 20100208_2115)
  • Product: Architecture
  • Platform: x86
  • BuildTimeStamp: 20100208_2115
  • LastSavedpath: C:\My Documents\BIM_UX_Team_Projects_2011\First Exp FT\Advanced Projects\RTM Files\rac_advanced_sample_project.rvt
  • OpenWorksetDefault: 3
    我本地的截图:
    在这里插入图片描述
    源代码可从网页上下载,OpenRevitOleStorage.zip
    查看源代码可知这里用了一下内部的,不完全公开的接口,必须用反射才能得到,System.IO.Packaging.StorageRoot
  protected object InvokeStorageRootMethod(StorageInfo storageRoot,
                                           string methodName,
                                           params object[] methodArgs)
  {
   //We need the StorageRoot class to directly open an OSS file.  Unfortunately, it's internal.
   //So we'll have to use Reflection to access it.  This code was inspired by:
   //http://henbo.spaces.live.com/blog/cns!2E073207A544E12!200.entry
   //Note: In early WinFX CTPs the StorageRoot class was public because it was documented
   //here: http://msdn2.microsoft.com/en-us/library/aa480157.aspx

   BindingFlags bindingFlags = BindingFlags.Static |
                               BindingFlags.Instance |
                               BindingFlags.Public |
                               BindingFlags.NonPublic |
                               BindingFlags.InvokeMethod;

   Type storageRootType = typeof(StorageInfo).Assembly.GetType("System.IO.Packaging.StorageRoot",
                                                               true,
                                                               false);
   //try
   //{
    object result = storageRootType.InvokeMember(methodName,
                                                 bindingFlags,
                                                 null,
                                                 storageRoot,
                                                 methodArgs);

    return result;
   //}
   //catch (Exception ex)
   //{
    
   // throw;
   //}
   return null;
  }

另外可以使用 Windows NT Structured Storage Docfile Viewer dfview.exe 来打开文件:
在这里插入图片描述

dfview.exe在本地没有找到,另外还有一个开源项目:https://github.com/ironfede/openmcdf,通过它也可以看到数据:
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

极客BIM工作室

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

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

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

打赏作者

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

抵扣说明:

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

余额充值