BimRv SDK: Get Symbol Previews

Yury Lebedev

April 13, 2023

RVT and RFA files may contain previews for some symbols (e.g., a family), which can be extracted using the OdBmSymbol class.

Use the getPreviewImage() method to extract the preview image, if available. It takes an OdThumbnailImage object as a parameter and uses it for output. The previews are usually 128 x 128 PNG bitmaps which are stored in the bmp field of the OdThumbnailImage object.

Preview image data can be exported to a file or converted to an OdGiRasterImage object with the getRasterImage() method.

You may want to use the conversion in order to scale the image using the OdRxRasterServices class.

OdThumbnailImage preview;
if (pSymbol->getPreviewImage(preview) == eOk && preview.hasPng()) {
  auto pFile = odrxSystemServices()->createFile(exportDir + getPreviewFileName(pSymbol),
    Oda::kFileWrite, Oda::kShareDenyReadWrite, Oda::kCreateAlways);
  pFile->putBytes(preview.png.getPtr(), preview.png.size());
}

You can also try this functionality in ODA Bim App by running two commands:

  • BmAllSymbolsPreview saves all detected symbol preview images to a source file directory with filenames generated from symbol names and their IDs.
  • BmSymbolPreview exports the symbol preview image of the currently selected element or the element found by an entered ID to a specified file; the file is created with the same rules as in the first command.