Overview
The following utility functions initialize the merged AP library then query or set the application protocol schema used when reading/writing a STEP file.
These functions are defined in the stplib_init.h header file, which is brought in with all of the EXPRESS class definitions by the stp_schema.h header file.
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_ap242, // AP242
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_cad_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.
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.
Example
RoseDesign * d;
switch (stplib_get_schema (d)) {
case stplib_schema_none:
printf ("==> no schema set\n");
break;
case stplib_schema_ap203:
printf ("==> AP203 file\n");
break;
case stplib_schema_ap203e2:
printf ("==> AP203e2 file\n");
break;
case stplib_schema_ap214:
printf ("==> AP214 file\n");
break;
case stplib_schema_ap242:
printf ("==> AP242 file\n");
break;
case stplib_schema_other:
printf ("==> Other type of file \n");
break;
}
See Also
Reading AP203 / AP203e2 / AP214 / AP242 Files
stplib_get_schema_name()
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).
Example
RoseDesign * d;
printf ("Original schema name: %s\n", stplib_get_schema_name (d));
See Also
Reading AP203 / AP203e2 / AP214 / AP242 Files
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 schema. This function also acts as a "force load" function, so you do not need to call stp_schema_force_load() as with other ST-Developer AP libraries.
Example
#include <stp_schema.h>
int main(int argc, char* argv[])
{
stplib_init();
// body of program
}
See Also
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 the Merged CAD library used the deprecated add_schema_fn hook and a function called stplib_p21_schema_read() but these have been retired.
stplib_put_schema()
void stplib_put_schema ( RoseDesign * d, 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
Example
RoseDesign * d;
// 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");
// Write design using AP242 schema
stplib_put_schema (d, stplib_schema_ap242)
d-> saveAs ("test_ap242.stp");
See Also
Writing AP203 / AP203e2 / AP214 / AP242 Files
stplib_put_schema_name()
void stplib_put_schema_name ( RoseDesign * d, 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.