Overview

The IFC EXPRESS library ifcbim has functions to control the IFC version used by an exchange file. These functions are defined in ifclib_init.h, which is brought in with the EXPRESS class definitions by the ifc_schema.h header file.

When reading, the schema of a file is parsed into the IfclibSchemaType enum returned by ifclib_get_schema(). The original string value is always available through the ifclib_get_schema_name() function. A detailed read example is available.

When writing a file, use ifclib_put_schema() to set the AP schema in the Part 21 header section, or call ifclib_get_schema_name() to set the exact name string. If no schema is set, the file will use the "IFC4" schema name. A detailed write example is available.

The library can change how some types are read or written depending on the schema. For example, when writing as IFC2x3, the library will omit attributes that were added in later versions. The details for each schema are described below.

IfclibSchemaType (enum)

enum IfclibSchemaType {
ifclib_schema_none,		// new file, no schema set
    ifclib_schema_ifc2x2,	// IFC2x2
    ifclib_schema_ifc2x3,	// IFC2x3
    ifclib_schema_ifc4,		// IFC4
    ifclib_schema_ifc4x1,	// IFC4x1
    ifclib_schema_ifc4x2,	// IFC4x2
    ifclib_schema_ifc4x3,	// IFC4x3
    ifclib_schema_other		// Unrecognized schema name
};

The IfclibSchemaType enumeration is used to identify different IFC versions in the functions described below. The values are sorted into ascending release order, so the newest is always the highest value. The "other" value is last because any unknown newer release should be handled as the most recent.

Schema Macros

#define IFCLIB_SCHEMA_MERGED
#define IFCLIB_SCHEMA_HAS_IFC2X2
#define IFCLIB_SCHEMA_HAS_IFC2X3
#define IFCLIB_SCHEMA_HAS_IFC4
#define IFCLIB_SCHEMA_HAS_IFC4X1
#define IFCLIB_SCHEMA_HAS_IFC4X2
#define IFCLIB_SCHEMA_HAS_IFC4X3

These macros simplify conditional code that may wish to probe capabilities or need to work with older versions of the IFC BIM library. There is a symbol for each of the IFC versions that is supported.

ifclib_get_schema()

IfclibSchemaType ifclib_get_schema (
	RoseDesign * d
	);

The ifclib_get_schema() function returns the IfclibSchemaType schema identifier which has been recognized for a RoseDesign. See Reading Files for more discussion

RoseDesign * d;

switch (ifclib_get_schema (d)) {
case ifclib_schema_none: 
	printf (==> no schema set\n);  
	break;

case ifclib_schema_ifc4: 
	printf (==> IFC4 file\n);  
	break;

case ifclib_schema_ifc4x1: 
	printf (==> IFC4x1 file\n);  
	break;

case ifclib_schema_ifc2x3: 
	printf (==> IFC 2x3 file\n);  
	break;

case ifclib_schema_ifc2x2:
	printf (==> IFC 2x2 file\n);  
	break;

case ifclib_schema_other: 
	printf (==> Other type of file \n);  
 	break;
}

ifclib_get_schema_name()

const char * ifclib_get_schema_name (
	RoseDesign * d
	);

The ifclib_get_schema_name() function returns the original schema name string found in the STEP Part 21 file. You can use this string to get additional information when the schema name was not recognized by the library (ifclib_schema_other). See Reading Files for more discussion

RoseDesign * d;

printf (Original schema name: %s\n, ifclib_get_schema_name (d));

ifclib_init()

void ifclib_init();
The ifclib_init() function must be called at the start of your application to initialize the additional code for reading older IFC files. This function also acts as a "force load" function that makes sure all of the classes are present. See Setup and Conventions for more discussion.

#include <ifc_schema.h>

int main(int argc, char* argv[])
{
    ifclib_init();

    // body of program
}

ifclib_p21_set_schemas()

RoseErrorCode ifclib_p21_set_schemas (
	RoseDesign * design, 
	ListOfString * all_schemas
	);

This is an internal function that should not be called by user code. The ifclib_init() function registers it with the RoseP21Parser::set_schemas_fn hook to process the FILE_SCHEMA() information in a Part 21 file and assign a IfclibSchemaType value.

ifclib_put_schema()

void ifclib_put_schema (
	RoseDesign * d, 
	IfclibSchemaType ap
	);

The ifclib_put_schema() function changes the IfclibSchemaType schema identifier associated with a RoseDesign. This value is examined when writing the FILE_SCHEMA() section of a STEP Part 21 file. See Writing Files for more discussion

RoseDesign * d;

// Write design using IFC4 schema
ifclib_put_schema (d, ifclib_schema_ifc4);
d-> saveAs ("test_2x4.ifc");

// Declare file schema to be IFC 2x3
ifclib_put_schema (d, ifclib_schema_ifc2x3);
d-> saveAs ("test_2x3.ifc");

// Declare file schema to be IFC 2x2
ifclib_put_schema (d, ifclib_schema_ifc2x2);
d-> saveAs ("test_2x2.ifc");

ifclib_put_schema_name()

void ifclib_put_schema_name (
	RoseDesign * d, 
	const char * ap
	);

You should use the ifclib_put_schema() function described above to specify the schema identifier that is used for the FILE_SCHEMA() section of a STEP Part 21 file.

Only use the ifclib_put_schema_name() function if you need to specify a different schema identifier string than what is produced using the enum values.

RoseDesign * d;

// Write using IFC4 name without release candidate identifier
ifclib_put_schema_name (d, IFC4);
d-> saveAs (test_2x4final.ifc);

ifclib_schema()

RoseDesign * ifclib_schema();

The ifclib_schema() function returns the RoseDesign containing the compiled EXPRESS data-dictionary definitions for the merged AP schema. This is used internally, user code should rarely need this.

ifclib_schema_context()

RoseAPContext * ifclib_schema_context (
    IfclibSchemaType ap
    );

RoseAPContext * ifclib_schema_context (
    const char * nm
    );

The ifclib_schema_context() functions are used internally, user code should rarely need them.

Thes functions return the RoseAPContext instances corresponding to a particular schema enum value or name string. These context objects used to identify the schema within the ROSE library when using merged data-dictionary definitions.