Search STEP Tools Web Support

Overview

The STEP Ship Schema Library merges the definitions from AP215, AP216, AP218, and AP203 into a single EXPRESS schema and generated C++ class library. This allows applications to use C++ classes and easily read and write files from any of these APs.

A installer for the STEP Merged Ship Schema Library is available at the URL below. This installer is for use with ST-Developer v12 on the Win32 platform. Contact us if you have ST-Developer v12 and need a version for a different platform.

ftp://ftp.steptools.com/pub/stdev/stpship_12_0_win32.msi


Using the Library

The stpship class library is installed as shown below:

The classes belong to the "step_ship_schema" schema so we have added functions that query the AP that a file was read as and control the AP that a file identifies itself as when writing. You must call stpship_init() at the start of your application to initialize handling of STEP files with the merged schema.

void stpship_init();
Example:
#include <stp_schema.h>

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

    // body of program
}


Writing Files

When you create a new file, call the stpship_put_schema() function to identify the schema that should be written in the P21 header. If you do not call this, the file will identify its schema as "STEP_SHIP_SCHEMA", which no other application will recognize.

These schema control functions use the StpShipSchemaType enum to identify the APs. The stpship_schema_none value is used to indicate a design has just been created and not assigned an AP.

enum StpShipSchemaType {
    stpship_schema_none,  // new file, no schema set
    stpship_schema_ap203, 
    stpship_schema_ap215, 
    stpship_schema_ap216, 
    stpship_schema_ap218,
    stpship_schema_other, 
};


void stpship_put_schema (
    RoseDesign * design, 
    StpShipSchemaType schema_code
    );
The sample program below creates a design containing a single cartesian point and writes it out using each of the possible schemas:
#include <stp_schema.h>

void main()
{
    stp_schema_force_load();
    stpship_init();

    RoseDesign *d = new RoseDesign ("foo");

    stp_cartesian_point * p = pnewIn(d) stp_cartesian_point;

    // no proper AP, just step_ship_schema
    d-> saveAs ("test_default.stp");

    stpship_put_schema (d, stpship_schema_ap203);
    d-> saveAs ("test_ap203.stp");

    stpship_put_schema (d, stpship_schema_ap215);
    d-> saveAs ("test_ap215.stp");

    stpship_put_schema (d, stpship_schema_ap216);
    d-> saveAs ("test_ap216.stp");

    stpship_put_schema (d, stpship_schema_ap218);
    d-> saveAs ("test_ap218.stp");
}
The complete set of types are available to you, so it is possible to create files containing instances that are not appropriate for an AP, such as a non_manifold_surface_shape_representation in an AP203 file. To help, we have annotated the EXPRESS to indicate which APs support each definition.


Reading Files

When reading files, use the stpship_get_schema() function to query the schema that a file was read as. If the type is "other", the stpship_get_schema_name can be used to get schema name.
StpShipSchemaType stpship_get_schema (
    RoseDesign * design
    );

char * stpship_get_schema_name (
    RoseDesign * design
    );
The code below reads the files written by the previous example and prints out some identifying schema information:
#include <stp_schema.h>

void print_info (RoseDesign *d)
{
    printf ("==> schemaname: %s\n", stpship_get_schema_name (d));

    switch (stpship_get_schema (d)) {
    case stpship_schema_none:	printf ("==> no schema set\n");  break;
    case stpship_schema_ap203: 	printf ("==> AP203 file\n");  break;
    case stpship_schema_ap215: 	printf ("==> AP215 file\n");  break;
    case stpship_schema_ap216: 	printf ("==> AP216 file\n");  break;
    case stpship_schema_ap218:	printf ("==> AP218 file\n");  break;
    case stpship_schema_other:	printf ("==> Other type of file\n");  break;
    }
}

void main()
{
    stp_schema_force_load();
    stpship_init();

    printf ("Using null pointer\n");
    print_info (0);

    printf ("Using new design\n");
    print_info (new RoseDesign ("foo"));

    print_info (ROSE.findDesign ("test_default.stp"));
    print_info (ROSE.findDesign ("test_ap203.stp"));
    print_info (ROSE.findDesign ("test_ap215.stp"));
    print_info (ROSE.findDesign ("test_ap216.stp"));
    print_info (ROSE.findDesign ("test_ap218.stp"));
}
The code will print the following output:
Using null pointer
==> schemaname: step_ship_schema
==> no schema set
Using new design
==> schemaname: step_ship_schema
==> no schema set
Reading: .\test_default.stp
==> schemaname: STEP_SHIP_SCHEMA
==> Other type of file
Reading: .\test_ap203.stp
==> schemaname: CONFIG_CONTROL_DESIGN
==> AP203 file
Reading: .\test_ap215.stp
==> schemaname: SHIP_ARRANGEMENT_SCHEMA
==> AP215 file
Reading: .\test_ap216.stp
==> schemaname: SHIP_MOULDED_FORM_SCHEMA
==> AP216 file
Reading: .\test_ap218.stp
==> schemaname: SHIP_STRUCTURES_SCHEMA
==> AP218 file

AP203 Type Mappings

AP203 was one of the first APs so it uses conventions that have changed in the newer ship APs. For example, assignment subtypes created by the AP have the prefix "cc_design" in AP203, but "applied_" in all other APs. The names of select types used by the assignments have also changed. AP203 creates context subtypes but newer APs just use the context supertypes.

The merged schema and resulting class library uses the newer definitions and the library contains code to read and write AP203 files using the older definition names.

The table below shows the changes. When reading an AP203 file, an entity in the left column is will appear in memory as an instance of the type on the right. When writing a file as AP203, an instance of a type on the right will be written as the type on the left.

AP203 type Merged type and C++ class
cc_design_approval applied_approval_assignment
cc_design_certification applied_certification_assignment
cc_design_contract applied_contract_assignment
cc_design_date_and_time_assignment applied_date_and_time_assignment
cc_design_person_and_organization_assignment applied_person_and_organization_assignment
cc_design_security_classification applied_security_classification_assignment
cc_design_specification_reference applied_document_reference

The definitions below are SELECT types used by the assignments

approved_item approval_item
certified_item certification_item
classified_item security_classification_item
contracted_item contract_item
date_time_item date_and_time_item
person_organization_item person_and_organization_item
specified_item document_reference_item

The definitions below are context subtypes unique to AP203

mechanical_context product_context
design_context product_definition_context

Distributing Applications

Normally, applications built with ST-Developer must be distributed with ST-Runtime support files to operate properly. ST-Runtime contains compiled EXPRESS for all published APs, which are used for reading and writing STEP files.

Since the merged step ship schema is unique to this library, we have compiled the runtime support directly the stpship library so that ST-Runtime is not needed. Just copy your application to a new machine and it should run fine. This simplifies distributing your application and also saves us from creating an ST-Runtime version with the merged schema.