The STEP Tools® software ships with C++ class libraries for STEP and IFC information models. You can start programming immediately, just by linking against the appropriate library. The easiest way to start is to use one of the sample programs we have provided for each library, then modify as needed.

If you prefer to start with a brand-new project, consult the guides below for the necessary settings:

The sections below describe some details to be aware of while writing your application. If we have not provided an EXPRESS class library for the schema you are working with we have instructions for generating a class library from scratch.

Include Files

Your code should include the EXPRESS class definitions, stp_schema.h for the STEP AP library classes, or ifc_schema.h for the IFC BIM classes. This is documented on the setup page for each library. If you are using a different library, like CIS/2, the header file may match the schema name, like structural_frame_schema.h.

#include <stp_schema.h>   /* in a STEP program */

#include <ifc_schema.h>   /* in an IFC program */

#include <structural_frame_schema.h>   /* in a CIS/2 program */

These header files bring in the rose.h header file for the ROSE Programming Library. Include rose_p28.h if you need Part 28 XML read/write support as described below.

Library Name Conventions

The STEP Tools® software include static libraries for each preinstalled schema under the lib installation directory. Separate sub-directories hold versions built with various compiler and architecture options. The ROSE_LIB environment variable may be set to one of these sub-directories for convenient use in Makefiles.

On Windows, static libraries have the .lib suffix, like stp_aim.lib or ifcbim.lib. On MacOS, Linux, and Unix, static libraries have the "lib" prefix and ".a" suffix, like libstp_aim.a or libifcbim.a so that you can use the -l linker flag like -lstp_aim or -lifcbim.

Windows DLL versions of the libraries use the dll.lib suffix, like stp_aimdll.lib or ifcbimdll.lib. Debug libraries use "dlld.lib" like stp_aimdlld.lib or ifcbimdlld.lib. The DLL files are in the dlls directory, which is pointed to by the ROSE_DLLDIR environment variable. See Linking to the DLLs for more information.

MacOS dynamic libraries use .dylib suffix, like libstp_aim.dylib or libifcbim.dylib. Linux and Solaris dynamic libraries use .so extension, like libstp_aim.so or libifcbim.so.

Class Name Conventions

The EXPRESS classes for STEP have the "stp_" prefix. So the class for the "product" EXPRESS definition is stp_product, the class for "cartesian_point" is stp_cartesian_point, and so on. This prefix makes it easier to identify the classes within your code and avoids symbol conflicts with other packages on names like "point" or "curve".

The IFC schema adopted a naming convention that includes the "Ifc" prefix in all of the definition names. It also uses case rather than underscores to distinguish words, so IFC has an IfcCartesianPoint definition. We use the name verbatim for C++ classes.

Complete lists of all classes for entities, complex entity combinations, aggregates, select types, and enumerations, can be found on the page for each schema.

Complex Entity Combinations

Complex entity combinations (sometimes called "AND/OR" instances) are instances with a set of types rather than a single type. This is just multiple inheritance, but the EXPRESS schema does not define an ENTITY for the combination. The ROSE library can fit these to the C++ classes that are available, and we can generate extra classes to simplify use with certain combinations.

The STEP libraries contain common combinations but this is usually handled by the extension functions for units, measures, and tolerances, which are the most common places these are used. The IFC schema does not use any of these, and in fact, only uses simple, single inheritance.

The C++ class name for one of these is made by concatenating the supertypes in alphabetic order with "_and_". See the class list for your schema for a complete list of the extra complex classes available.

In the Part 21 files, complex instances are written differently. Each supertype is called out in a parenthesized list along with the attributes defined by the super. The example below shows some complex instances used for unit definitions in STEP.

/* SI Units and Conversion-based units, complex instances */
#14= ( 	LENGTH_UNIT()

#15= (	NAMED_UNIT(*)

#16= (	CONVERSION_BASED_UNIT('degree',#18)

/* some normal instances */
#17= DIMENSIONAL_EXPONENTS (0.,0.,0.,0.,0.,0.,0.);
#18= MEASURE_WITH_UNIT (PLANE_ANGLE_MEASURE(0.01745329252),#15);

Force Link in main()

STEP Tools® libraries create new C++ instances indirectly when reading a STEP file, so some optimizing linkers do not realize that classes are used and omit them. Then you will get "Best Fit" warning messages when reading STEP files as the ROSE library tries to find a C++ class to hold the instance data.

You must call the stp_schema_force_load() function to force the linker to bring in all C++ classes. You only need to call this once, in your main() (or other always-present function).

#include <stp_schema.h>

int main(int argc, char* argv[])
    /* Force optimizing linkers to bring in all C++ classes */

    /* Rest of your application */
    . . .

For non-STEP AP schemas (like CIS/2 and IFC), and classes you generate from yourself, this function is named after the schema (<schema>_force_load()) and is defined in a separate header file (<schema>_ROSE_LOAD.h).

    #include <[schema-name]_ROSE_LOAD.h>   /* for a non-AP schemas */
    #include <structural_frame_schema_ROSE_LOAD.h>   /* CIS/2 */
    int main(int argc, char* argv[])
        . . .
    #include <ifc2x2_final_ROSE_LOAD.h>              /* IFC */
    int main(int argc, char* argv[])
        . . .

Part 28 XML Read/Write Support

STEP Tools® software applications read and write Part 21 text files. To also read and write STEP Part 28 Edition 2 XML exchange files (ISO 10303-28:2007), simply include the rose_p28.h header file then call rose_p28_init() at the start of your program to register the XML reader and writer. You must also link against the rosexml library.

From then on, your application will automatically recognize STEP Part 28 XML files when reading. By default, new files are written as Part 21 but you can switch to Part 28 XML by calling RoseDesign::format() with "p28" or "p28-raw" strings.

RoseDesign * d;
d-> format ("p21");
d-> save()  // write as Part 21 text

d-> format ("p28");
d-> save()  // write compressed Part 28 XML

d-> format ("p28-raw");
d-> save()  // write raw Part 28 XML

The "p21" format is the default and specifies a STEP Part 21 ASCII file, and the file will be given the ".stp" extension if none is specified.

The "p28" format specifies XML with zip compression to reduce size, and the file will be given the ".p28" extension if none is specified. If you run unzip on the result, you will see a single file called iso_10303_28.xml , which contains the raw XML.

The "p28-raw" format specifies XML without any compression, and the file will be given the ".xml" extension if none is specified.