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:
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);
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:
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.
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|