Overview

The STEP EXPRESS library stp_aim has functions to control the application protocol schema used by a STEP file. These functions are defined in stplib_init.h, which is brought in with the EXPRESS class definitions by the stp_schema.h header file.

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

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

The library can change how some deprecated types are read or written depending on the schema. For example, when writing as AP203, some "applied" assignment types are written with a "cc_design" prefix. The details for each schema are described below.

StplibSchemaType (enum)

enum StplibSchemaType {
    stplib_schema_none,		// new file, no schema set
    stplib_schema_ap203,	// AP203, original
    stplib_schema_ap203e2, 	// AP203, second edition
    stplib_schema_ap214, 	// AP214
    stplib_schema_ap224,	// AP224
    stplib_schema_ap232,	// AP232
    stplib_schema_ap238,	// AP238, STEP-NC
    stplib_schema_ap238e2,	// AP238, second edition
    stplib_schema_ap240,	// AP240
    stplib_schema_ap242, 	// AP242, first and second edition
    stplib_schema_other 	// Unrecognized schema name
};

The StplibSchemaType enumeration is used to identify different APs in the functions described below. The values of this enum correspond to the APs supported by this library. The merged EXPRESS schema used by the library is named "step_merged_ap_schema", but when reading and writing STEP P21 files, schema names are used that correspond to one of the published STEP APs.

The headers also define a STPLIB_SCHEMA_HAS_AP2xx symbol for each schema in the enum to indicate to the preprocessor that it is supported by the library.

Schema Macros

#define STPLIB_SCHEMA_MERGED
#define STPLIB_SCHEMA_HAS_AP203
#define STPLIB_SCHEMA_HAS_AP203E2
#define STPLIB_SCHEMA_HAS_AP214
#define STPLIB_SCHEMA_HAS_AP224
#define STPLIB_SCHEMA_HAS_AP232
#define STPLIB_SCHEMA_HAS_AP238
#define STPLIB_SCHEMA_HAS_AP238E2
#define STPLIB_SCHEMA_HAS_AP240
#define STPLIB_SCHEMA_HAS_AP242
#define STPLIB_SCHEMA_HAS_AP242E2
#define STPLIB_SCHEMA_HAS_SMRL_V8

These macros simplify conditional code that may wish to probe capabilities or need to work with older versions of the STEP AIM library. There is a symbol for each of the application protocols that is supported. In recent years, SMRL version has also become of interest, so we include a symbol for that.

stplib_get_schema()

StplibSchemaType stplib_get_schema (
	RoseDesign * d
	);

The stplib_get_schema() function returns the StplibSchemaType schema identifier which has been recognized for a RoseDesign. This enum does not distinguish between different ASN/1 identifiers sometimes found in AP214 files, but you can get the original schema name string with the stplib_get_schema_name() function. See Reading Files for more information.

Example

RoseDesign * d;

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

case stplib_schema_ap203: 
	printf (==> AP203 original file\n);  
	break;

case stplib_schema_ap203e2: 
	printf (==> AP203e2 file\n);  
	break;

case stplib_schema_ap214:
	printf (==> AP214 file\n);  
	break;

case stplib_schema_ap224:
	printf (==> AP224 file\n);  
	break;

case stplib_schema_ap232:
	printf (==> AP232 file\n);  
	break;

case stplib_schema_ap238:
	printf (==> AP238 STEP-NC file\n);  
	break;

case stplib_schema_ap238e2:
	printf (==> AP238e2 STEP-NC file\n);  
	break;

case stplib_schema_ap240:
	printf (==> AP240 file\n);  
	break;

case stplib_schema_ap242:
	printf (==> AP242 file\n);  
	break;

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

stplib_get_schema_name()

const char * stplib_get_schema_name (
	RoseDesign * d
	);

The stplib_get_schema_name() function returns the original schema name string found in the STEP Part 21 file. You can use this string to examine the ASN/1 identifiers sometimes found in AP214 files, or get additional information when the schema name was not recognized by the library (stplib_schema_other). See Reading Files for an example and more information.

RoseDesign * d;

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

stplib_init()

void stplib_init();

The stplib_init() function must be called at the start of your application to initialize handling of STEP files with the merged AP schema. This function also acts as a "force load" function, so you do not need to call stp_schema_force_load() as with other EXPRESS class libraries.

See Setup and Conventions for more information on application structure.

#include <stp_schema.h>

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

    // body of program
}

stplib_p21_set_schemas()

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

This is an internal function that is not called by user code. The stplib_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 StplibSchemaType value.

Early versions of this library used add_schema_fn and stplib_p21_schema_read() functions but these have been retired.

stplib_put_schema()

void stplib_put_schema (
	RoseDesign * design, 
	StplibSchemaType ap
	);

The stplib_put_schema() function changes the StplibSchemaType schema identifier which is associated with a RoseDesign. This value will be examined when writing the FILE_SCHEMA() section of a STEP Part 21 file and also used when writing instances using deprecated types from older schemas. See Writing Files for details on the different schemas.

RoseDesign * d;

// Write design using AP242 schema
stplib_put_schema (d, stplib_schema_ap242)
d-> saveAs (test_ap242.stp);

// Write design using AP203 schema
stplib_put_schema (d, stplib_schema_ap203);
d-> saveAs (test_ap203.stp);

// Write design using AP203 second edition schema
stplib_put_schema (d, stplib_schema_ap203e2);
d-> saveAs (test_ap203e2.stp);

// Write design using AP214 schema
stplib_put_schema (d, stplib_schema_ap214);
d-> saveAs (test_ap214.stp);

stplib_put_schema_name()

void stplib_put_schema_name (
	RoseDesign * design, 
	const char * ap
	);

You should use the stplib_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 stplib_put_schema_name() function if you need to specify a different schema identifier string than what is produced using the enum values. You can use this to specify ASN/1 identifiers for AP214 files. As long as the string begins with "AUTOMOTIVE_DESIGN" it will still be recognized as the stplib_schema_ap214 enum.

RoseDesign * d;

// Write using AP214 first edition ASN/1 qualified name
stplib_put_schema_name (d, AUTOMOTIVE_DESIGN {1 0 10303 214 1 1 1});
d-> saveAs (test_ap214e1.stp);

// Write using AP214 second edition ASN/1 qualified name
stplib_put_schema_name (d, AUTOMOTIVE_DESIGN {1 0 10303 214 2 1 1});
d-> saveAs (test_ap214e2.stp);

// Write using AP214 third edition ASN/1 qualified name
stplib_put_schema_name (d, AUTOMOTIVE_DESIGN {1 0 10303 214 3 1 1});
d-> saveAs (test_ap214e3.stp);

stplib_schema()

RoseDesign * stplib_schema();

The stplib_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.

stplib_schema_context()

RoseAPContext * stplib_schema_context (
    StplibSchemaType ap
    );

RoseAPContext * stplib_schema_context (
    const char * nm
    );

The stplib_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.