RVT and RFA Thumbnail Image

Here is a question that reappears pretty regularly.

Question:
How can I obtain the preview bitmap image or thumbnail from a Revit project or family file using the Revit API?

This is an example of the kind of image I am interested in:

RFA thumbnail preview bitmap image

Answer:
The topic of

getting your Revit thumbnails

was already been discussed by

Guy Robinson

in

Bolt out of the Red
,
but for completeness sake I will partially reiterate it here as well, since the query keep reappearing.

The Revit API does not provide any built-in support for this, but you can make use of generic Windows API functionality instead.
Revit project files use Windows structured storage to manage resources internally.
You can use the DocFile Viewer utility dfview.exe to look at the structured storage file contents.
Here is an example of a Revit project file with the preview image highlighted:

RVT file structured storage and preview image in dfview.exe

We had a short look at the internal RVT file structure when exploring how to extract the Revit build version from

RVT

and

RFA

files.

The thumbnail is a standard PNG file inserted into the Revit structured storage document.

To extract the preview thumbnail image, you can use the Windows

IExtractImage interface
.
Preview.dll is a shell plug-in, i.e. an object that implements this interface.
It is used by the Windows Shell Folders to extract preview images for “known” file types.
The preview extractor needs to register itself in the registry and implement the two following standard API functions:


STDMETHOD(GetLocation)(
LPWSTR pszPathBuffer,
DWORD cchMax,
DWORD *pdwPriority,
const SIZE *prgSize,
DWORD dwRecClrDepth,
DWORD *pdwFlags);
STDMETHOD(Extract)(HBITMAP*);

More details and sample code are available from

Guy’s post
.


Comments

7 responses to “RVT and RFA Thumbnail Image”

  1. Dear sir,
    I m able to get .jpg from .rfa but the dimensions, labels from rfa file are not coming into .jpg.
    Please help?
    Thanks & Regards,
    -Nitin

  2. Dear Nitin,
    Sorry, no idea.
    Cheers, Jeremy.

  3. hello sir,
    how to get .rfa thumbnails in windows

  4. plzz help

  5. Dear Sachin,
    This problem occurs when the Revit.FilePreview.dll is not register. In order to register it:
    In the strat menu -> start type the following:
    regsvr32 “C:\Program Files\Autodesk Revit Architecture 2010\Revit.FilePreview.dll”
    Note that the path could change depending on the version and flavor of your Revit.
    Now you should be able to preview your Revit family thumbnail in the file browser.
    I hope I could help :)

  6. redbolt.com/blog is no longer available. Any chance for the full code?

  7. Dear Randall,
    You can simply go have a look at this more recent sample instead:
    http://thebuildingcoder.typepad.com/blog/2010/06/open-revit-ole-storage.html
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading