Search STEP Tools Web Support

Overview

When reading files, use the stplib_get_schema() function to query the schema that a file identified itself as. It will return a StplibSchemaType enum value for the schema, as used when writing files. If the type is "other", the stplib_get_schema_name() function can be used to get the original schema name string. Using these functions, you can process files described by any of the STEP CAD APs using a single application.
StplibSchemaType stplib_get_schema (
    RoseDesign * design
    );

char * stplib_get_schema_name (
    RoseDesign * design
    );
The code below reads each of the files produced by the writing example and prints out some identifying schema information. It also prints a list of instances found in the file and the C++ class name of each. Note that with the AP203 file, assignments are read as instances of the modern "applied" classes.
#include <stp_schema.h>

void print_info (RoseDesign *d)
{
    printf ("==> schema name: %s\n", stplib_get_schema_name (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;
    }

    RoseCursor objs;
    RoseObject * obj;
    objs.traverse(d);

    while ((obj=objs.next()) != 0) {
	printf ("\t#%lu instance of %s\n", obj-> entity_id(), obj->className());
    }
}

void main()
{
    stplib_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_ap203e2.stp"));
    print_info (ROSE.findDesign ("test_ap214.stp"));
    print_info (ROSE.findDesign ("test_ap242.stp"));
}
The code will print the following output:
Using null pointer
==> schemaname: step_merged_cad_schema
==> no schema set
Using new design
==> schemaname: step_merged_cad_schema
==> no schema set
Reading: .\test_default.stp
==> schemaname: STEP_MERGED_CAD_SCHEMA
==> Other type of file
	#19 instance of cartesian_point
	#18 instance of applied_approval_assignment
	#17 instance of applied_certification_assignment
	#16 instance of applied_contract_assignment
	#15 instance of applied_date_and_time_assignment
	#14 instance of applied_person_and_organization_assignment
	#13 instance of applied_security_classification_assignment
	#12 instance of applied_document_reference
	#11 instance of product_context
	#10 instance of product_definition_context
Reading: .\test_ap203.stp
==> schemaname: CONFIG_CONTROL_DESIGN
==> AP203 file
	#19 instance of cartesian_point
	#18 instance of applied_approval_assignment
	#17 instance of applied_certification_assignment
	#16 instance of applied_contract_assignment
	#15 instance of applied_date_and_time_assignment
	#14 instance of applied_person_and_organization_assignment
	#13 instance of applied_security_classification_assignment
	#12 instance of applied_document_reference
	#11 instance of product_context
	#10 instance of product_definition_context
Reading: .\test_ap203e2.stp
==> schemaname: AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF
==> AP203e2 file
	#19 instance of cartesian_point
	#18 instance of applied_approval_assignment
	#17 instance of applied_certification_assignment
	#16 instance of applied_contract_assignment
	#15 instance of applied_date_and_time_assignment
	#14 instance of applied_person_and_organization_assignment
	#13 instance of applied_security_classification_assignment
	#12 instance of applied_document_reference
	#11 instance of product_context
	#10 instance of product_definition_context
Reading: .\test_ap214.stp
==> schemaname: AUTOMOTIVE_DESIGN
==> AP214 file
	#19 instance of cartesian_point
	#18 instance of applied_approval_assignment
	#17 instance of applied_certification_assignment
	#16 instance of applied_contract_assignment
	#15 instance of applied_date_and_time_assignment
	#14 instance of applied_person_and_organization_assignment
	#13 instance of applied_security_classification_assignment
	#12 instance of applied_document_reference
	#11 instance of product_context
	#10 instance of product_definition_context
Reading: .\test_ap242.stp
==> schemaname: AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF
==> AP242 file
	#19 instance of cartesian_point
	#18 instance of applied_approval_assignment
	#17 instance of applied_certification_assignment
	#16 instance of applied_contract_assignment
	#15 instance of applied_date_and_time_assignment
	#14 instance of applied_person_and_organization_assignment
	#13 instance of applied_security_classification_assignment
	#12 instance of applied_document_reference
	#11 instance of product_context
	#10 instance of product_definition_context