ODA BimRv SDK supports importing a Collada file into a .rvt or .rfa file. The import module is a single support module for ODA BimRv SDK, and it is available in dynamic form for Windows, Linux, and macOS (x64 version). More information about Collada is at http://opencollada.org/.
The following components are available:
ODA BimRv SDK supports importing the geometry of 3D objects, lights, and materials. There are five properties and one method available for importing Collada (.dae) files to .rvt or .rfa files. The ColladaPath property provides the filename of the .dae file to be imported. The Database property sets the OdBmDatabase object, where the .dae file is imported. The StoreMethod property sets how imported objects are stored — as B-Rep objects or poly-mesh objects. The UsePrimitives property defines whether primitives are used for mapping of materials. The ConsoleInfo property defines output information at the console. After the properties are set, the .dae file can be imported using the import() method:
virtual ImportResult import();
Where ImportResult is an enumeration with the following values:
Identifier | Error description |
---|---|
success | Import finished successfully. |
fail | Import failed: Internal import error. |
bad_file | Import failed: Wrong format of the import .dae file. |
bad_database | Import failed: Invalid database pointer or corrupted database. |
ODA BimRv SDK provides two abstract classes that can be inherited by classes that implement their own algorithm of the Collada import: OdColladaImport and ColladaImportModule.
The import process commonly consists of five steps:
For Collada import module creation, the method loadModule() of the odrxDynamicLinker object must be called. The loadModule() method returns a smart pointer to the import module (import module object is an instance of the class inherited from the ColladaImportModule class). Then call the create() method of the import module object to get a smart pointer to the importer instance (an instance of the class inherited from the OdColladaImport).
Additionally, the function createImporter() defined in the TbColladaImport.h file can be used for creation of the Collada importer object. When using this function, there is no need to create a Collada import module because createImporter() creates it by itself.
The ColladaProperties class instance can be used to specify properties of the import process:
// pCmdCtx is the pointer to the command contexts
OdSmartPtr pIO = pCmdCtx->userIO();
// Path of the target Collada file
OdString path = pIO->getFilePath(OD_T("Enter file name:"), OdEd::kGfpForOpen, OD_T("Collada file to load"),
OD_T("dae"), OdString::kEmpty, OD_T("Design Web Format (*.dae)|*.dae|"));
if (path.isEmpty())
return;
// Create importer and import properties
OdColladaImportPtr importer = createImporter();
OdRxDictionaryPtr pProps = importer->properties();
// Target database
pProps->putAt(OD_T("Database"), pCmdCtx->baseDatabase());
// Source Collada(.dae) file
pProps->putAt(OD_T("ColladaPath"), OdRxVariantValue(path));
// Store method
pProps->putAt(OD_T("StoreMethod"), OdRxVariantValue(static_cast(pIO->getKeyword(
OD_T("Where to store the imported geometry,\n in the B-Rep (0) or in the PolyMesh (1) [0/1] <0>:"),
OD_T("0 1"), 0))));
// Start import
importer->import();
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|