Open Revit OLE Storage

One of the valuable spoils of the AEC DevCamp last week in Waltham is the following stand-alone utility created by David S. Echols of

H&A Architects & Engineers
for
opening and analysing the contents of the Revit structured OLE storage file streams.

We initially discussed this internal RVT and RFA file structure when presenting the Python utility to read the


RVT or RFA file version
without
starting up and loading the file into Revit.
It is also of interest to read the


RVT and RFA thumbnail image
stored
in the file.

Now Dave has submitted this great little utility that goes much further in reading and parsing the information available in the structured file data, providing access to the thumbnail image and items such as the following from the sample file rac_advanced_sample_project.rvt provided with Revit Architecture 2011:

  • 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

Here is an example of the result of parsing the RAC sample file rac_basic_sample_project.rvt:

OpenRevitOleStorage utility showing structured file storage data from rac_basic_sample_project.rvt

Here is Dave’s description of this utility and the associated source code:

<

p style=”color:darkblue”>Attached is a zip file of my OLE Storage test project.
It does not have any references to the Revit API assemblies, so you should be able to extract the files, open the project and run it.
Select the file you want to open and the BasicFileInfo will be displayed in the Text area.
If there is a preview image, it will be displayed to the right of the text area.
This is course provided as-is.

Here is
OpenRevitOleStorage.zip
containing the complete source code and Visual Studio solution for this stand-alone utility.

Obviously, as Dave points out, you make use of this utility or the provided code at your own risk.
Its use is completely unsupported, has nothing to do with the Revit API, and can change at any time.

Addendum

Here is a question that came up just a couple of days later, so I thought I would add it to this post, for completeness’ sake:

Question: Here is a longstanding issue I have had with Revit – how to test externally for file version?

We automate some processes and start Revit to do it, therefore it would be very helpful to understand what version the file is that we are attempting to open!

One problem with Revit is that there is no way to determine the version of a Revit project file outside (or inside) of Revit. On opening the file, Revit immediately upgrades an older file with no way to stop the process from happening. We even thought of storing information in an external SQL database about what version of Revit each file is utilizing. We moved away from a similar method with AutoCAD projects, though, because of the issues it presented.

Answer: A Revit project is stored as a compound storage file, which consists of streams and storages. Storages are like folders, and can contain their own substreams and substorages.

At the top level, as of a few releases ago, one stream is BasicFileInfo. If interpreted as Unicode, it is roughly human-readable and lists some information about the model. This includes the build of Revit used to save the model.

This information was added so that out own support and development teams could quickly take a peek at a model and see what build it was saved in, and also whether it has worksharing enabled, since that information is also stored.


Comments

9 responses to “Open Revit OLE Storage”

  1. Mike Caraker Avatar
    Mike Caraker

    Has anyone taken this a step further to actually pull out information about the drawing elements inside the Revit file? Primarily I’d like to look for a particular family inside a file and pull out a quanitity for use elsewhere.

  2. Dear Mike,
    I do not believe that is possible. The accessible data only includes metadata of the kind listed above, and all the model data is contained in one single large stream the internal of which are not accessible.
    You could do what you wish from within a Revit add-in, either analysing a file opened by the user in the GUI or any other Revit file opened invisibly in the background via the API.
    Cheers, Jeremy.

  3. Martin Schmid Avatar
    Martin Schmid

    For 2012, it looks like a minor change needs to be made. In BasicFileInfo.cs, in ParseDetailInfo() the string “CENTRALFILEPATH” needs to be changed to “CENTRALMODELPATH”.

  4. Dear Martin,
    Wow, great, thank you for the important and useful info!
    Do you have an updated version to share with us?
    I could simply add it to the post above, or create a new post for the 2012 version, if you think that is worthwhile…
    Cheers, Jeremy.

  5. Has anyone looked at upgrading this for the 2013 and 2014 versions of Onebox?

  6. Dear Jeff,
    Nope, not that I am aware of.
    I would have expected it to be trivial.
    Have you tried running it on Revit 2014 files?
    Do you encounter any issues with that?
    Cheers, Jeremy.

  7. Jeremy,
    Sorry for the late response but I got pulled off onto something else again. I have it opening the file, giving me the preview image and file name and that’s were it stops. I don’t get the build info, central file info, etc. I made the following changes and I am sure I am just missing something simple.
    Added System.Xaml for the Markup.IUriContext since I am working with .NET 4.0
    Added Revit to ProductType.cs (I may have this wrong)
    Added the associated if line to BasicFileInfo.cs

  8. Also to note is that when I step through the app line by line I do see it pull the unicodeData but when it starts to break it apart is were it appears to be breaking down.

  9. Dear Jeff,
    Now it is my turn to apologise for the delay in replying.
    Congratulations on the progress.
    Have you completed it yet, or are you still stuck somewhere?
    I will gladly publish the updated version.
    Cheers, Jeremy.

Leave a Reply to Martin SchmidCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading