To create a new IFC database, call the createDatabase() method of the customer service class instance declared in the
Ifc/Examples/Common/IfcExamplesCommon.h header file.
The MyServices class is based on the ExSystemServices and OdExIfcHostAppServices classes, which implement platform-based functionality for
IFC SDK based applications:
The createDatabase() method returns a smart pointer to the OdIfcFile object.
Using this smart pointer, call the readFile() method to load the contents of an IFC file to the created object.
OdStaticRxObject< MyServices > svcs;
OdString ifcFileName(argv[1]);
OdIfc::OdIfcFilePtr pDatabase = svcs.createDatabase(kScmUndefined);
OdResult res = pDatabase->readFile(ifcFileName);
if (res == eOk)
{
odPrintConsoleString(L"\nFile opened successfully.");
}
else
{
odPrintConsoleString(L"\nFile open error.");
}
To write the contents of an IFC file object, use the writeFile() method of the OdIfcFile object:
OdStaticRxObject < MyServices > svcs;
OdIfc::OdIfcFilePtr pDb = svcs.createDatabase();
if (!pDb.isNull())
{
//Add here some functionality for filling the header section and model objects
pDb->writeFile(szTargetFileName, true);
}