ODA IFC SDK Developer's Guide > Basic Concepts of IFC SDK Usage > Work with Header Sections and Models
Work with IFC Models and Header Sections

When you have a valid instance of the OdIfcFile class, you can manage the header section and model objects of the IFC database.

To get access to the IFC database header section:

  1. Retrieve the repository object:
    
    OdDAI::RepositoryPtr  pRepository = pDb->getRepository();
            
  2. Get the header section object from the repository object and check whether it is valid:
    
    OdDAI::OdHeaderSectionPtr headerSection = pRepository->getHeaderSection();
    
    if (headerSection.isNull())
    {
      ODA_ASSERT(0 && "Header is not valid.");
      throw OdError(eNullEntityPointer);
    }
            
  3. Initialize the header section:
    
    headerSection->initialize();
            
  4. Add the IFC file description to the header section:
    
    OdDAI::OdFileDescriptionAuto* fileDescription = getHeaderFromSection<OdDAI::OdFileDescriptionAuto, OdDAI::kFileDescription>(headerSection);
    OdArray<OdAnsiString> descriptionCollection;
    descriptionCollection.push_back("ViewDefinition [CoordinationView]");
    fileDescription->setDescriptionAggr(descriptionCollection);
    fileDescription->setImplementationLevel("2;1");
            
  5. Add the IFC filename and its timestamp:
    
    OdDAI::OdFileNameAuto* fileName = getHeaderFromSection<OdDAI::OdFileNameAuto, OdDAI::kFileName>(headerSection);
    fileName->setName("TestFile.ifc");
    fileName->setTimeStamp("2019-02-23T12:17:26");
            
  6. Define the schema of the IFC file:
    
    OdDAI::OdFileSchemaAuto* fileSchema = getHeaderFromSection<OdDAI::OdFileSchemaAuto, OdDAI::kFileSchema>(headerSection);
    OdArray<OdAnsiString> schemCollection;
    schemCollection.push_back("IFC2X3");
    fileSchema->setSchemaIdentifiersAggr(schemCollection);
            

To proceed with any operation for an IFC model, you need a smart pointer to its object within an IFC database. To get it, use a model provider object from the OdDAI interface:


OdDAI::Utils::ModelProviderRO  modelProvider(pDb->getRepository());
OdIfc::OdIfcModelPtr model = modelProvider.model<OdIfc::OdIfcModel>();

if (model.isNull() || model->underlyingSchemaName().find("IFC2X3") != 0)
{
  ODA_ASSERT(0 && "Model is not valid.");
  throw OdError(eNullEntityPointer);
}
    

Using the smart pointer returned by the model() method of the repository object, you can work with the IFC model using the OdDAI interface.

See Also

Initialization and Deinitialization.

Work with an IFC Database.

Library Dependencies of IFC SDK

Download IFC SDK

Basic Concepts of IFC SDK Usage

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