Overview
The step.Design class manages the STEP data instances read from or written to an exchange file. Each Design instance contains a collection of step.Object instances, as well as information about the schema declared by an exchange file, origin information from the file header, and a dictionary mapping from anchor names (usually UUIDs) to STEP data instances.
Use the DesignCursor class to iterate over all objects of a particular type in the file.
This is the Python equivalent of the RoseDesign
class
in the C++ libraries.
Name Dictionary
Newer STEP files contain an ANCHOR section containing string names (usually UUIDs) associated with objects in the file. This capability was introduced by the third edition of the ISO 10303-21 (P21) in 2016 and looks like this. The new anchor section contains key / entity id pairs and comes before the data section:
ISO-10303-21; HEADER; FILE_DESCRIPTION( ... ); FILE_NAME( ... ); FILE_SCHEMA (('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF')); ENDSEC; ANCHOR; <6db46031-4fab-4838-824b-91cea43922e4>=#10; /* product_definition */ <3c9773de-5015-4c05-86b4-0e35a5bfd96f>=#7934; /* dimensional_size */ <305dc4d8-d6cd-4e44-89c7-9ad5476774cb>=#7922; /* cylindricity_tolerance */ <09c07753-38cf-4928-928f-4acd0e636247>=#7928; /* Simple Datum.1 - datum */ <f1ab2591-7e18-4898-90c4-a60ff7916774>=#7930; /* Simple Datum.2 - datum */ ... ENDSEC; DATA; #10=PRODUCT_DEFINITION('',' ',#12,#28); #11=PRODUCT_DEFINITION_SHAPE(' ',' ',#10); #12=PRODUCT_DEFINITION_FORMATION('',' ',#13); ... ENDSEC; END-ISO-10303-21;
You can use the index operator on the design with a string name,
and the keys()
function returns all of the names table,
so dict()
will cast the design into a dictionary.
D = step.find_design(part123.stp) # get object by ANCHOR value from STEP file (P21e3) obj = D['6db46031-4fab-4838-824b-91cea43922e4'] obj = D.find('6db46031-4fab-4838-824b-91cea43922e4') # print all of the UUID ANCHORs from STEP file PP.pprint (dict(D)) { '0098e447-15ab-44ac-b360-3d5fd4f7dcd3': <step.Object #7978 dimensional_location>, '04d1431a-9535-4ef6-a615-f00315a87548': <step.Object #8003 dimensional_location>, '09a905e5-da9c-44ab-aa9b-48689aafcd59': <step.Object #8018 dimensional_location>, '09c07753-38cf-4928-928f-4acd0e636247': <step.Object #7928 datum>, ...
arm_recognize()
def arm_recognize(self) -> int:
The arm_recognize() function identifies the ARM concepts in a STEP data set and returns the number found. Reading a file with open_project() does this automatically as part of its setup for the high-level APIs, so this function is only used when doing low-level things with find_design().
find()
def find(self, id: str | int) -> Object:
The find() function searches a design for a data object with
the given string ANCHOR name or integer entity id (#123). Finding by
string is the same as using a string key lookup on the design. The
function returns None
if the object can not be found.
D = step.find_design(part123.stp) # example from the name dictionary discussion above obj = D.find('6db46031-4fab-4838-824b-91cea43922e4') # find object #456 obj = D.find(456)
header_description()
def header_description(self) -> Object:
The header_description() function returns the description object from the header section of the STEP Part 21 exchange file. The file description object describes the contents of the exchange file, along with the version of ISO 10303-21 that was used to create it. The header_name() function returns the other commonly used header object.
The EXPRESS definition for the description object is shown below:
ENTITY file_description; description : LIST [1:?] OF STRING (256); implementation_level : STRING (256); END_ENTITY;
header_name()
def header_name(self) -> Object:
The header_name() function returns the description object from the header section of the STEP Part 21 exchange file. The file name object provides human-readable information about the exchange structure. It describes the person and systems that created the file. The header_description() function returns the other commonly used header object.
The EXPRESS definition for this object is shown below:
ENTITY file_name; name : STRING (256); time_stamp : STRING (256); author : LIST [1:?] OF STRING (256); organization : LIST [1:?] OF STRING (256); preprocessor_version : STRING (256); originating_system : STRING (256); authorisation : STRING (256); END_ENTITY;
The example below prints out all of the common header section information. In particular, the timestamp and originating system will give you an idea of when the file was created and what CAD system or other software was used to author the file.
D = step.find_design(somefile.stp) print (Name:, D.header_name().name) print (Time:, D.header_name().time_stamp) print (PreProc:, D.header_name().preprocessor_version) print (OrigSys:, D.header_name().originating_system) print () print (Author:, *D.header_name().author, sep=\n) print (Org:, *D.header_name().organization, sep=\n) print () print (Imp Level:, D.header_description().implementation_level) print (Description:, *D.header_description().description, sep=\n)
The following is some output produced from a test file created using CATIA.
Name: 7AJS9999-0001A_FOR_NC -.1.stp Time: 2021-03-22T17:08:33+00:00 PreProc: 3DEXPERIENCE Platform3DEXPERIENCE R2020x HotFix 6 OrigSys: 3DEXPERIENCE Platform STEP AP242 v1 Author: none Org: none Imp Level: 2;1 Description: CATIA V6 STEP CAx-IF Rec.Pracs.--- Model Styling and Organization---1.5--- 2016-08-15 CAx-IF Rec.Pracs.---Supplemental Geometry---1.0---2011-11-01 CAx-IF Rec.Pracs.---Representation and Presentation of Product Manufacturing Information (PMI)---4.0---2014-10-13 CAx-IF Rec.Pracs.--- Composite Materials ---3.4---2017-06-13 CAx-IF Rec.Pracs.--- Geometric and Assembly Validation Properties ---4.4---2016-08-17 CAx-IF Rec.Pracs.---Tessellated 3D Geometry---1.0---2015-12-17
name()
@overload def name(self) -> str: ... @overload def name(self, nm: StrOrBytesPath) -> str:
The name() function returns the base file name, without directory or extension, of the complete file path. It the function is called with a path-like object, it will change the name and return the new value. The update function accepts a full or partial file path. It will only change the file_directory() if one is given. It will change the file_extension() if given and will add a default one if neither the string nor the design have one.
The design constructor calls name() to initialize the filename for the design. Use path() to set the complete file path explicitly, without any additional behavior.
The path() access function returns the full path that is used when reading and writing designs
# name = gizmo, path = gizmo.stp D = step.find_design (gizmo.stp); # name = foobar, path = foobar.stp d.name(foobar); # name = there, path = /hello/there.new d.name(/hello/there.new); # Only changes the name part, dir and ext stay the same # name = baz, path = /hello/baz.new d.name(baz); # Changes the name and ext, dir stays the same # name = cheese, path = /hello/cheese.stp d.name(cheese.stp);
path()
@overload def path(self) -> str: ... @overload def path(self, nm: StrOrBytesPath) -> str:
The path() function returns the full path that is used when reading and writing the Design. It the function is called with a path-like object, it will change the path and return the new value.
schema_name()
@overload def schema_name(self) -> str: @overload def schema_name(self, name: str) -> None:
The 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 and the schema_type() function
returns OTHER
.
schema_type()
@overload def schema_type(self) -> SchemaType: @overload def schema_type(self, schema: SchemaType) -> None: class SchemaType(IntEnum): NONE # new file, no schema set AP203 # AP203, original AP203E2 # AP203, second edition AP214 # AP214, all editions AP224 # AP224 AP232 # AP232 AP238 # AP238, STEP-NC first edition AP238E2 # AP238, STEP-NC second and later editions AP240 # AP240 AP242 # AP242, all editions OTHER # Unrecognized schema name
The schema_type() function gets or sets the design schema type enumeration. This identifies the application protocol that the STEP file declares in its header section. 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 schema_name() function.
D = step.find_design(basic.stp) print (SCHEMA TYPE, D.schema_type()) print (SCHEMA NAME, D.schema_name()) SCHEMA TYPE SchemaType.AP203 SCHEMA NAME CONFIG_CONTROL_DESIGN D.schema_type(step.SchemaType.AP242) print (SCHEMA TYPE, D.schema_type()) print (SCHEMA NAME, D.schema_name()) SCHEMA TYPE SchemaType.AP242 SCHEMA NAME AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF { 1 0 10303 442 3 1 4 }