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:
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:
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.
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
Posted by: Account Deleted | November 04, 2011 at 05:53
Dear Nitin,
Sorry, no idea.
Cheers, Jeremy.
Posted by: Jeremy Tammik | November 04, 2011 at 06:41
hello sir,
how to get .rfa thumbnails in windows
Posted by: sachin | February 01, 2013 at 02:54
plzz help
Posted by: sachin | February 01, 2013 at 02:55
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 :)
Posted by: Mustafa Salah | February 04, 2013 at 11:51
redbolt.com/blog is no longer available. Any chance for the full code?
Posted by: Randall Toepfer | July 22, 2013 at 03:31
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.
Posted by: Jeremy Tammik | August 30, 2013 at 08:20