This topic describes how to import Autodesk® Navisworks® data to the IFC format.
To get access to the functionality for importing NWD files to IFC, load the following:
Binary library: Nv2Ifc.tx
.
Source Code Location: Exchange/Exports/Nv2Ifc
.
Binary library: Dwg2Ifc.tx
.
Source Code Location: Exchange/Imports/Dwg2Ifc
.
There are two abstract classes that describe the interface for conversion of data from BimNv format to IFC format:
OdNv2IfcModule
— Interface of the BimNv-to-IFC conversion module.
An example of this interface implementation is represented with the OdNv2IfcModuleImpl
class.
OdIfcExport
— Interface for an object that provides the BimNv-to-IFC conversion functionality.
This interface contains the doExport()
method which should contain the conversion implementation in inherited classes.
Conversion properties can be retrieved through a properties()
method call.
An example of this interface implementation is represented with the OdIfcExporter
class.
The OdIfcExportProperties
class stores and handles the set of conversion properties.
Add the following include and define declarations to your application source code to get access to the BimNv-to-IFC conversion functionality:
#include "OdaCommon.h"
#include "NwHostAppServices.h"
#include "StaticRxObject.h"
#include "NwDatabase.h"
#include "RxDynamicModule.h"
#include "DynamicLinker.h"
#include "ExSystemServices.h"
#include "diagnostics.h"
#include "ExPrintConsole.h"
#include "ModuleNames.h"
#include "../Exchange/Exports/Nv2Ifc/Include/IfcExport.h"
#include "../Exchange/Exports/Nv2Ifc/Include/IfcExportProperties.h"
#define STL_USING_STREAM
#define OD_HAVE_FSTREAM_FILE
#define STL_USING_STRING
#include "OdaSTL.h"
For static configurations, use the set of DECLARE/DEFINE_STATIC
macro instances:
#if !defined(_TOOLKIT_IN_DLL_)
ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdDbRootModuleObject);
ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(NwDbModule);
ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdSDAIModule);
ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdIfcCoreModule);
ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdIfc4Module);
ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdIfcGeomModuleImpl);
ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdIfcBrepBuilderModule);
ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdNv2IfcModuleImpl);
ODRX_BEGIN_STATIC_MODULE_MAP()
ODRX_DEFINE_STATIC_APPMODULE(OdDbRootModuleName, OdDbRootModuleObject)
ODRX_DEFINE_STATIC_APPMODULE(sNwDbModuleName, NwDbModule)
ODRX_DEFINE_STATIC_APPMODULE(OdSDAIModuleName, OdSDAIModule)
ODRX_DEFINE_STATIC_APPMODULE(OdIfcCoreModuleName, OdIfcCoreModule)
ODRX_DEFINE_STATIC_APPMODULE(OdIfc4ModuleName, OdIfc4Module)
ODRX_DEFINE_STATIC_APPMODULE(OdIfcGeomModuleName, OdIfcGeomModuleImpl)
ODRX_DEFINE_STATIC_APPMODULE(OdIfcBrepBuilderModuleName, OdIfcBrepBuilderModule)
ODRX_DEFINE_STATIC_APPMODULE(OdNw2IfcModuleName, OdNv2IfcModuleImpl)
ODRX_END_STATIC_MODULE_MAP()
#endif
It is assumed that the following classes are declared and defined for implementation of the conversion:
OdExNwSystemServices
class which implements platform-dependent functionality for the conversion process.
class OdExNwSystemServices : public ExSystemServices
{
public:
OdExNwSystemServices() {}
};
This class is inherited from the
ExSystemServices
class.
MyNwServices
class which implements functionality for host application services.
class MyNwServices : public OdExNwSystemServices, public OdNwHostAppServices
{
protected:
ODRX_USING_HEAP_OPERATORS(OdExNwSystemServices);
};
Also, there are three variables that store the necessary information for the import process:
sNvFile
— Contains the full path to the input BimNv file.
sIfcFile
— Contains the full path to the output IFC file.
sDictionaryFile
— Contains the full path to the dictionary file.
The dictionary file stores the correlation between entities from the input BimNv database and the output IFC file.
OdString sNvFile;
OdString sIfcFile;
OdString sDictionaryFile;
You can handle the import process by using the properties in the table below:
Parameter Name | Parameter Description |
---|---|
IFC Schema Version
|
IFC schema version for the output IFC file. Imported data is written to the file according to the specified schema version. |
IfcFilePath
|
The full path to an output IFC file should be created as a result of the conversion operation. |
Database
|
A smart pointer to an object of the BimNv database to import data from. |
Dictionary
|
A conversion map that contains the correlation between entities in the input BimNv database and the output IFC file. |
To use the import functionality in your IFC SDK-based application:
OdStaticRxObject <MyNwServices> svcs;
#if !defined(_TOOLKIT_IN_DLL_)
ODRX_INIT_STATIC_MODULE_MAP();
#endif
odrxInitialize(&svcs);
::odrxDynamicLinker()->loadModule(sNwDbModuleName, false);
try ... catch()
section for handling errors:
try
{
}
catch (const OdError& e) {
nRes++;
odPrintConsoleString(L"\nException Caught: %ls\n", e.description().c_str());
}
catch (...)
{
nRes += 2;
odPrintConsoleString(L"\nUnknown Exception Caught\n");
}
All of the following code fragments are added to the try{}
section.
OdNwDatabasePtr pNwDb = svcs.readFile(sNvSource);
NV_IFC_EXPORT::OdNv2IfcModulePtr pModule = ::odrxDynamicLinker()->loadModule(OdNw2IfcModuleName, false);
auto pExport = pModule->create();
std::map < OdString, OdString > dictionary;
if (dictionaryFilePath.isEmpty())
return eNoFileName;
std::ifstream dictionaryFile(dictionaryFilePath.operator const char* ());
std::string key, value;
while (dictionaryFile)
{
if (dictionaryFile >> key)
{
if (dictionaryFile >> value)
{
dictionary[key.c_str()] = value.c_str();
}
}
}
NV_IFC_EXPORT::OdIfcExportPropertiesPtr pProperties = pExport->properties();
pProperties->put_SchemaVersion((OdInt16)kScmIfc4);
pProperties->put_Database(pNwDb);
pProperties->put_IfcFilePath(sIfcDestination);
pProperties->put_Dictionary(createRxWrapper(dictionary));
pExport->doExport();
::odrxDynamicLinker()->unloadUnreferenced();
::odrxUninitialize();
Deinitialization code should be placed outside the try{} catch()
section.
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|