Close

Relief for ODA Team in Ukraine

Learn more
ODA BimRv SDK
Export to a Collada File (.dae File)

ODA Platform supports exporting .rvt and .rfa files to a Collada format file (.dae file). ODA Platform uses a single Collada export module that is available in dynamic form for Windows, Linux, and macOS (x64 version). All source files are available in the release packages. More information about Collada is at http://opencollada.org/.

The following components are available:

  • TD_ColladaExport.tx — A .tx support module for Collada export.
    Location: Kernel\Exports\ColladaExport
    This module should be loaded by the user application to get access to Collada export functionality. The main exported class is “ColladaModule”.
  • ODA BimRv SDK Collada export example application — Contains sample call code for .rvt and .rfa files.
    Location: BimRv\Examples\BmColladaExportEx

Collada allows exporting the geometry of 3D objects, lights, and materials.

There are two methods available.

The first method exports all elements from the .rvt/.rfa file to a .dae file with the filename provided in pFileName:


    virtual OdResult exportCollada(OdBmDatabase *pDb, const OdString& pFileName, const ODCOLORREF* pPallete, int numColors = 256);
    

The second method exports a single element defined by pElem of pDb to a file with the filename provided in pFileName. The color palette used with the export should be posted via pPallete and numColors. This method is used for setting up the correct pallete for an export device:

virtual OdResult exportCollada(OdBmDatabase *pDb, const OdGiDrawable &pElem, const OdString& pFileName, const ODCOLORREF* pPallete, int numColors = 256);

Example Application

The command line format for the sample applications is:


    Usage: BmColladaExportEx < input file > < output file > [< element handle >]
      L"   < input file >    - .rfa or .rvt file
      L"   < output file >   - .dae file
      L"   < element handle > - OdDbHandle of an OdBmElement for export
    

The export process commonly consists of four steps:

  1. Creating the Collada export module.
  2. Creating a Collada exporter instance.
  3. Calling the exportCollada method of the Collada exporter object.
  4. Analyzing the result of the export process.
For example:

OdStaticRxObject < MyServices > svcs; // create a custom Services object
odrxInitialize(&svcs);             // initialize Runtime Extension environment

try
{
  // loading the Loader module to be able to read a .rfa/.rvt file
  ::odrxDynamicLinker()->loadModule(OdBmLoaderModuleName, false);
  
  // Get Database
  OdBmDatabasePtr pDb = svcs.readFile(sFileToExport);
  if (!pDb.isNull())
  {
    // loading the ColladaExport module to be able to export a .rfa/.rvt file to the COLLADA format
    ColladaModulePtr pColladaExportModule = odrxDynamicLinker()->loadModule(OdColladaExportModuleName);
    if (pColladaExportModule.isNull())
    {
      odPrintConsoleString(L"Cannot load module : ");
      odPrintConsoleString(OdColladaExportModuleName);
      return 2;
    }

    OdResult eResult = eInvalidInput;
    if (! hObjectToExport.isNull()) // if a handle is specified then export this object
    {
      OdGiDrawablePtr pDrawable = pDb->getObjectId(hObjectToExport).safeOpenObject();
      eResult = pColladaExportModule->exportCollada(pDb, *pDrawable, sDaeFileName, odcmAcadLightPalette(), 256);
    }
    else // else export full content of a file
      eResult = pColladaExportModule->exportCollada(pDb, sDaeFileName, odcmAcadLightPalette(), 256);

    if (eOk == eResult)
    {
      odPrintConsoleString(L"\nSuccessfully exported\n");
    }
    else
    {
      OdString sResult = OD_T("Error : ") + OdError(eResult).description();
      odPrintConsoleString(sResult);
      return 3;
    }
  }
  odPrintConsoleString(L"Done\n");
}
// display the error
catch (OdError& e)
{
  odPrintConsoleString(L"\nODA BimRv SDK Error: %ls\n", e.description().c_str());
}
catch (...) // Non-ODA BimRv SDK error
{
  odPrintConsoleString(L"\nUnknown Error.\n");
}
odrxUninitialize();
    

For viewing .dae files, you can use Collada viewing applications such as Blender.

See Also

Interaction with Other Formats

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.