Export PNG image of selected BIM element
MIT License
Revit C# .NET add-in that exports a list of PNG images of a selected BIM element from a list of specified view angles.
The goal is to export "images" of all of the family instances from a Revit model.
When we receive a new Revit model from a new project, and we want to quickly "categorize" all the family symbols there and understand what needs to be tracked and in which way.
Currently, we export all the family symbols to RFA files and look at those:
Problems:
FamilyInstance
and other element types.Another option would be to use some Python code (unrelated to Revit, on a computer where Revit is not installed) and just parse these RFA files.
Some possible way to go with this:
For instance, on one extreme, going away from Windows and the Revit desktop API completely, you could push the RVT model to Forge and isolate the individual family instances there, in the cloud, in the Forge viewer. Two of the advantages with that would be: A. everybody can see them, with zero installation requirements, directly in the browser. B. they can be rotated and zoomed directly in the browser, so you can view them from all angles interactively.
Within Revit, on Windows, with the .NET desktop API, a schedule similar to the one in your image can easily be generated.
Simply create a 3D view, isolate the family instance you wish to create a view of, rotate it into the required position and export a screen snapshot or an image file for it. If required, repeat for other viewing angles. Iterate over all the instances one by one to create all the required views. Put all the exported images together into the schedule as required. Disadvantage: fixed viewing angle.
If you have the gltf exporter up and running and doing what you need, you can also use that directly to generate all the gltf 3D data for all the instances and then render them as needed outside of Revit. In theory, here you could actually put real 3D gltf directly into the schedule and rotate each individual family instance inside its own cell.
We will explore option number 2, exporting the images directly from Revit.
Usage:
We use a fixed list to define the angles from which to generate the element views. The definition format doesn't really matter. I would go with:
In all cases, looking directly at the centre of the element (by bounding box centre).
Existing sample code:
Some implementation hints have been described by Alexander Ignatovich and The Building Coder in the article on exporting image and setting a default 3D view orientation.
Another sample of ExportImage
option settings is provided in the recent discussion on export image cutting off pixels.
If the background is important, the discussion on setting the view display background addresses that aspect.
The Building Coder samples includes the CmdExportImage
sample command that exports an image of a view.
Current implementation:
Currently, a single element is selected.
Separate snapshots of it are exported to PNG bitmaps based on a pre-defined list of view directions.
The views are created and set up from scratch in a transaction that is rolled back and aborted, so no modification is made to the model.
That is very time-consuming.
Possible enhancements:
Jeremy Tammik, The Building Coder, ADN Open, Autodesk Inc.
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.