整理(很多内容非原创,转载自网络)
链接来自 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,通过它也可以看到数据: