STEP Tolerance Sample Program
The TOLERANCE sample program demonstrates how to create STEP GD&T dimensions, datums, and tolerances. This program reads a simple file with geometry for a block and hole, then applies dimensions, datums, and tolerances to the faces.
To simplify this demonstration, the faces are found using previously assigned representation item names. A more sophisticated program would probably get the faces by having the user pick them from a 3D display.
The functions defined by the program are as follows. These can be pasted into other applications as needed. The make_callout() function defines a shape_aspect callout to identify a particular face on the part. You can also build a callout with many faces if needed.
The make dimension functions associate callouts with a dimension value and plus/minus tolerance. We provide a functions for distance between two callouts and diameter size dimensions. Other size dimensions are also possible.
The make tol functions apply flatness, position, and perpendicularity tolerances to callouts, with datums as needed. You can extend these functions to define tolerances for angularity, circular runout, coaxiality, concentricity, cylindricity, line profile, parallelism, roundness, straightness, surface profile, symmetry, and total runout.
make_flatness_tol() make_position_tol() make_perpendicularity_tol()
The datums functions define a datum from a face and then add them to tolerances where appropriate.
The sample data set is AP214, but the program reads any kind of STEP data (AP203, AP214, etc) and saves as the AP schema that it is linked with. If the input file has any data not supported by the AP schema, it will be ignored. Below we have provided versions of the program for use with AP203 second edition, AP214, and STEP-NC AP238.
Source and output
Project files (right-click to save)
- AP203e2: [VC++ 2005 Project] [VC++ 6 Project] [Mac/Unix Project]
- AP214: [VC++ 2005 Project] [VC++ 6 Project] [Mac/Unix Project]
- AP238: [VC++ 2005 Project] [VC++ 6 Project] [Mac/Unix Project]
Below is a pre-built command line executable that make one tolerance. It reads a file called "maketol_in.stp" and looks for a face with the name "pos face", then creates a position tolerance of 0.001mm on it. If any faces are named "a datum", "b datum", or "c datum", they will be attached as the respective datums.
An AP214 and AP203e2 version of the exec are provided. Before you run them, install the ST-Runtime support files using the installer below: