Parametric STEP (ISO 10303-55, -108, -111)
A STEP file from FreeCAD, as from most CAD systems, holds the finished shape: faces, edges and surfaces (ISO 10303-42), with nothing about how it was made. Change a dimension in the receiving system and there is nothing to change: the history, the sketch constraints and the parameters stayed behind.
ISO 10303 has parts for exactly that, and NX-Style writes and reads them:
| Part | What it carries |
|---|---|
ISO 10303-21 |
The file itself: header, data sections, instances (read and written in full, second edition) |
ISO 10303-11 |
EXPRESS, the language the schemas are written in: NX-Style reads the schemas and checks files against them |
ISO 10303-42, -43 |
Geometry, topology, solids, representations: the B-rep, and the profiles and picked edges of the history |
ISO 10303-55 |
The construction history: an ordered sequence of operations, picked edges and faces, and the dual model (history and B-rep in one file) |
ISO 10303-108 (with Cor.1 and Cor.2) |
Parameters, the expressions between them, geometric constraints, sketches |
ISO 10303-111 |
Feature operations on solids: blends, chamfers, shells, extrusions with trim conditions and draft |
ISO 10303-112 |
2D sketch commands: a Part 112 sketch from another system is evaluated into a FreeCAD sketch; on request, each sketch is also written as Part 112 commands (below) |
AP203, AP214, AP242 |
The application protocols: recognised from the file, and checked against their own long-form schemas once those are in the schema cache (below); the product structure (BOM) is read from any of them |
On the ribbon
Modeling › PMI tab › Exchange:
| Button | Does |
|---|---|
STEP with Parameters |
The selected Body (or Part solid, or sketch) as STEP AP242. OpenCASCADE writes the B-rep and the product structure, the file any CAD system opens; the history, sketches, constraints and spreadsheet parameters go into the same file. The Information window lists what went in, by part of ISO 10303, the result of the file check, and anything that could not be written. |
Import STEP with Parameters |
Rebuilds what such a file carries: a PartDesign Body (into the open part’s Body while it is empty, as after Ctrl+N; or Part CSG objects), its sketches with their constraints, a Parameters spreadsheet, and the expressions that tie them. When the file also has the B-rep, the rebuilt solid is compared with it. A file without parametric data comes in as its B-rep. |
Check STEP |
Any STEP file against ISO 10303-21 and the schemas of Parts 42, 43, 55, 108, 111 and 112, and against its application protocol’s schema when that is in the cache (tick Download the AP’s schema to get it once). The report names the AP and lists the product structure (BOM). |
STEP with Parameters has Also write each sketch as ISO 10303-112 commands: every sketch then also goes into the file as Part 112 modelling commands, paired with its constrained Part 108 form. It is off by default, because no edition of AP242 includes Part 112 (see the table below): a strict AP242 reader would not know those entities.
What is written
| FreeCAD | ISO 10303 |
|---|---|
Spreadsheet aliases (lengths, angles, numbers) |
|
An expression on a feature property or a sketch constraint, using those aliases |
A |
Sketch: lines, arcs, circles, points, construction geometry |
|
Coincident, Point on Object |
|
Horizontal, Vertical, Parallel, Perpendicular, Tangent |
|
Equal |
|
Distance, Horizontal/Vertical Distance |
|
Radius, Diameter, Angle |
|
Symmetric (about a line), Block |
|
A sketch attached to an origin plane, a datum plane or a planar face (Flat face) |
The sketch’s plane on the support’s plane: |
Pad, Pocket (length, two sides, symmetric, through all, taper) |
|
Pad, Pocket up to face, up to first, up to last, with an offset |
The same, its first trim condition the face reached (a |
Revolution, Groove (also up to face) |
|
Hole: simple (flat or drill point), counterbore, countersink, through all |
Per position of its sketch, in a nested sequence: |
Fillet, Chamfer |
|
Thickness |
|
Linear pattern, polar pattern, Mirrored, of one or more features |
A nested sequence of |
MultiTransform |
A nested sequence per step, holding the new placements of that step (it applied to all before it) |
Pipe (Standard mode, along a tangent-continuous sketch path, the profile normal to the path at its start) |
|
Draft, Loft, other Pipes and Holes, a pattern of holes or fillets, other features with a solid |
A hybrid step (55 5.2.2): a nested sequence whose rationale names the feature, with what was picked (drafted faces, neutral plane, the loft’s sketches) and the feature’s explicit solid ( |
Additive and subtractive primitives; Part Box, Cylinder, Cone, Sphere, Torus; Cut, Fuse, Common |
|
The whole history |
|
Some features have no entity in ISO 10303-42 or -111, and are written as hybrid steps: their result as an explicit solid, so that the history goes on past them.
Draft has none: EXTRUDED_FACE_SOLID_WITH_DRAFT_ANGLE drafts an extrusion as it is made, not chosen faces of a solid.
Loft has none: SECTIONED_SPINE leaves the shape between its sections undefined and is no solid.
A Pipe is Part 42’s sweep only in Standard mode along a planar, tangent-continuous path with the profile normal to it; Fixed, Frenet, Auxiliary or Binormal modes, several sections and corner transitions are hybrid steps.
Threaded, tapered and counterdrilled holes are hybrid steps too, and so is a pattern of holes or fillets (a replica needs a tool solid; Part 111’s own patterns of placed features are not used).
A system that does not know the step still gets its shape; NX-Style rebuilds Draft, Loft and Pipe steps as FreeCAD features from what they record (the rationale carries FreeCAD’s angle, mode or ruled flag), and stops at other hybrid steps.
No ISO 10303 attribute carries a draft angle, and hole radii and depths are lists, so expressions on those are not written.
The report names every hybrid step and anything else that was not written.
The placing of a hole points out of the hole entrance, as ISO 10303-111 4.4.22 defines it. Part 111’s offset of an up-to extent is unsigned; the side is taken from the reached extent, which goes in the extrusion’s depth. A sketch attached to an origin plane, or to a face that is found again on the rebuilt features by its geometry, comes back attached (Flat face, with the attachment offset that keeps it in place); other attachment modes, and supports that are not found, leave it placed where it was. Picked edges and faces are found again on the rebuilt solid by their geometry, which is what Part 55’s user-selected elements are for, and a hole’s sketch is the one whose circles sit at its positions.
Tutorial AL goes through it on the ribbon.
The round trip is tested in FreeCAD 1.1.4 (tests/fc_parametric_step.py): a plate with a constrained sketch, Pad, Fillet, Chamfer, a Pocket through all, a linear pattern and a Revolution; holes of each kind on sketches attached to a face; a Mirrored, a linear pattern of two features and a MultiTransform; extrusions up to a face, up to the first face and with an offset; a Draft followed by a Fillet, a Pipe, a Fixed-mode Pipe and a Loft; and a Part CSG tree.
Exported, checked (no errors), imported into a new document: the rebuilt solids equal the originals exactly, and still do after the same parameter change in both.
The holes, replicas and sweep are also built from the ISO definitions alone (Part 111’s segments and cones, Part 42’s sweep frame) and compared with FreeCAD’s.
Check STEP
python -m nxstyle.iso10303 check part.stp
python -m nxstyle.iso10303 entities part.stp
python -m nxstyle.iso10303 attributes PDGC_WITH_DIMENSION
Run from the NXStyle folder; no FreeCAD needed.
check reads the file (a Part 21 syntax error stops it with the place) and reports:
-
the header rules: the three header entities in order, the implementation level, the time stamp, the schema names, the data sections;
-
for every instance of an entity in the loaded schemas: unknown or abstract entities, missing or extra attributes,
$for an attribute that is not optional,*where nothing is derived (and its absence where a subtype re-derives the attribute), values of the wrong type down to enumeration values, SELECT alternatives, aggregate bounds and duplicates, references to missing instances or to instances of the wrong entity, complex instances that lack a supertype record, break a ONEOF or leave an abstract supertype without a subtype; -
every rule of the schemas, evaluated by an EXPRESS interpreter (
express_eval): the WHERE rules of each entity of an instance, supertypes included; the WHERE rules of the defined types its values have; aggregate bounds given by an attribute (LIST [1:segments]); the UNIQUE rules over the file; the cardinalities of INVERSE attributes; and the global RULEs. The schemas' own FUNCTIONs are run, with the built-in functions of ISO 10303-11 (TYPEOF, USEDIN, QUERY and the rest), derived and inverse attributes and entity constructors; -
the informal propositions of ISO 10303-108 that no rule states: an attribute reference names a real SCHEMA.ENTITY.ATTRIBUTE of the instance it points at and that holds a number, and every variational item is in a variational representation.
A value the file does not give is indeterminate, and only a rule that comes out FALSE is reported; UNKNOWN is not a violation (ISO 10303-11 9.2.2.2).
The check ends with a count, for example rules: 3177 evaluated, 0 violated, 0 not evaluated.
A rule is not evaluated, with the reason, when it calls a function the loaded schemas do not declare, when it would need the references of an entity they do not define (an AP’s own B-rep entities, if the AP’s schema is not in the cache), or when it runs past a step budget (2 million steps for a rule, 5 million for a global rule; on a large assembly, compatible_dimension can run past it).
Entities of other parts (an application protocol’s product structure, PMI) are counted, not checked, until the AP’s schema is in the cache.
--exp file.exp adds more EXPRESS, and then those are checked too.
Proved with an independent tool
STEPcode’s validator (p21read, built for the AP242 long form) reads what STEP with Parameters writes and reports no errors, except for one kind of instance it cannot read: the parameters, complex instances of 16 partial records (UNBOUND_VARIATIONAL_PARAMETER with MATHS_REAL_VARIABLE and its supertypes), on which it crashes inside its own complex-entity matcher.
With those written as simple parameters in a copy, it validates every other instance; the only two errors it then reports are the assignments whose expression is now no longer a numeric expression, which shows that it type-checks references.
A broken copy is rejected by both: a LINE whose point is a DIRECTION by STEPcode and by NX-Style, a circle with a negative radius by NX-Style only, because p21read checks form and not WHERE rules.
NIST’s STEP File Analyzer needs Windows; it was not run.
Application protocols
A STEP file is written to an application protocol (AP), named in its header.
NX-Style recognises AP203 (edition 1, CONFIG_CONTROL_DESIGN, and edition 2), AP214 (AUTOMOTIVE_DESIGN, with the version its object identifier gives) and AP242 (AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF).
An AP’s own entities, such as the product structure, the B-rep shape representations, PMI and presentation, are checked against the AP’s long-form schema once it is in the schema cache:
python -m nxstyle.iso10303 schema fetch AP242 # also AP203, AP203E2, AP214
python -m nxstyle.iso10303 schema add mim_lf.exp # any other long form, e.g. another AP242 edition
python -m nxstyle.iso10303 schema list
python -m nxstyle.iso10303 bom assembly.stp
fetch takes AP242’s long form from standards.iso.org (ISO/TS 10303-442 edition 7) and AP203 and AP214’s from the STEPcode project, compiles it and keeps it in the user’s cache folder (~/.cache/freecad-nxstyle/iso10303, %LOCALAPPDATA%\FreeCAD-NXStyle\iso10303; NXSTYLE_ISO10303_SCHEMAS overrides).
The cache holds one schema per name, so the AP242 editions replace each other; the last one added is the one used.
The schemas are not in this repository.
What the APs' long forms contain, counted entity by entity (the PMI column: ten entities semantic PMI rests on, such as datum_system, dimensional_size, limits_and_fits, position_tolerance; AP203 edition 2 and AP214 edition 3 lack the two of AP242’s datum reference frames, datum_system and datum_reference_compartment):
| Schema | Part 55 (15) | Part 108 (65) | Part 111 (52) | Part 112 (43) | PMI (10) |
|---|---|---|---|---|---|
AP203 edition 1 |
0 |
0 |
0 |
0 |
0 |
AP203 edition 2 |
12 |
3 |
49 |
0 |
8 |
AP214 edition 3 |
0 |
0 |
0 |
0 |
8 |
AP242 editions 2, 3 and current |
13 |
65 |
49 |
0 |
10 |
Everything STEP with Parameters writes for Parts 55, 108 and 111 is in AP242, and its files check without an error against AP242’s own schema. Part 112 is in none of them.
Tutorial AM checks a supplier’s assembly against AP242’s schema, reads its parts list, and rebuilds a sketch sent as Part 112 commands.
bom (and Check STEP) reads the product structure: products, their definitions and the next-assembly-usage occurrences, as the assembly tree with quantities and the parts list with the totals.
Lengths and plane angles are read in the file’s units (millimetres, metres, inches, radians, degrees: SI and conversion-based units); numbers inside expressions are taken as they are.
Where ISO 10303 contradicts itself
Writing data that every rule accepts, and evaluating every rule, turned up places where the standards cannot all be met at once. NX-Style’s choice in each case, and what the checker says about it. Where a rule cannot be met, its violation is a warning that says so, and only when the violation is that contradiction and nothing else; any other cause stays an error.
-
Sketch wrapper. The prose of ISO 10303-108 6.3.4 WR4 wants the variational wrapper of a sketch to have the sketch’s types, but
NEUTRAL_SKETCH_REPRESENTATIONonly admits points and curves as items (8.4.9), so it could hold no constraint. The wrapper is a plain shape representation. Its EXPRESS is a one-way difference, which the wrapper meets; the checker warns that the prose is not met. -
Constraints on shared geometry.
variational_representationWR2 (throughinvalidate_vrep_item) wants a constraint’s elements used by exactly the representations that use the constraint. But 6.3.4 WR1 makes the current result share the wrapper’s geometry, and WR3 keeps constraints out of it, so no constraint on a sketch’s own curves can pass. The same holds for a history’s bound parameters, whose feature is also in the procedural representation (55 4.3.3), and for a construction line used as a symmetry’s mirror, whichsymmetry_geometric_constraintWR1 forbids to be a reference element. Warning. -
Neutral sketch dimension. Cor.2 rewrites
neutral_sketch_representationWR1 to demand three-dimensional items, against the clause’s own statement ("the dimensionality … shall be 2") and the 2005 rule; as printed it is also ill-typed (AND binds tighter than IN). The dictionary takes it bracketed as the AP242 long form prints it; sketches stay two-dimensional, with a warning. -
Countersunk through holes. ISO 10303-111 writes
solid_with_stepped_round_hole_and_conical_transitionsWR2 with XOR where its statement reads "either a through hole or no more transitions than segments", so a through hole with no exit transition breaks it as printed. Warning. WR1 ofsolid_with_through_depressionlists the flat-bottom hole twice and omits the conical one; no bottom is written, as the text intends. -
Bound parameters. Cor.1 derives a bound parameter’s current value as
?, and ISO 10303-50’smember_ofmakes?a member of the generics space only, sovariational_parameterWR1 holds only with that space;maths_real_variableWR1 wants a space of reals. Bound parameters are therefore simple instances onELEMENTARY_SPACE(.ES_GENERICS.). They are never operands, only assigned to. -
Plain references. An unbound parameter in a variational representation must be used by a free-form constraint (
invalidate_vrep_item), whichEQUAL_PARAMETER_CONSTRAINTis not; a reference to a parameter is aFREE_FORM_ASSIGNMENTwhose expression is the parameter. A parameter that drives nothing cannot be a variational parameter at all (6.3.1 WR1 allows it in no other representation), so it is written as a named value (VALUE_REPRESENTATION_ITEM, ISO 10303-43), without its description. -
Sketch origin.
representation_mapWR1 (43) wants the map’s origin in the sketch’s context, but the sketch may hold only points and curves and its wrapper must hold exactly the sketch’s geometry; a plain representation in the sketch’s context holds the origin. -
ISO 10303-55 5.4.4 and 5.4.5 require a solid sequence to be a
SOLID_MODELand its elements to be geometric items, whichUSER_SELECTED_SHAPE_ELEMENTSis not; Part 55’s own example (annex E) writes both as simple instances. NX-Style writes complex instances that meet the rules. A procedural representation may only hold sequences (55 4.3.3), so parameters of the history wrap a shape representation that holds the sequence. -
ISO 10303-108 Cor.1 annex F writes the current value of a parameter untyped (
3.0), where ISO 10303-21 10.1.8 asks for a typed value, and uses parameters as operands ofMULT_EXPRESSION, which ISO 13584-20 narrows to numeric expressions. NX-Style writesMATHS_REAL(3.0)and parameters that are alsoMATHS_REAL_VARIABLE`s (ISO 10303-50). The examples of annex F also have slips: `#550names itself as its value space (for#540),#410uses#360(for#400), andUNBOUND_PARAMETER_SEMANTICSis the pre-corrigendum name ofUNBOUND_VARIATIONAL_PARAMETER_SEMANTICS. -
ISO 10303-112’s own example (4.2.2) uses
SKETCH_OPERATE_FILLET, which the schema does not define (the command iscreate_fillet, with seven attributes), and writes$for a sequence’s suppressed items, which is not optional. Its ellipse commands say the second semi-axis is "the projection onto the line defined by the first two points", which would lie along the first axis; NX-Style takes the distance from that line. A near point (near_point_relationship) is used by no representation item, sorepresentation_itemWR1 (43) wants it held by a representation of its own. -
ISO 10303-50’s
maths_simple_atomlistsmaths_numbertwice and omitsmaths_integer. ISO 10303-108 Cor.1 saysnon_negative_length_measure"has been moved to ISO 10303-41", but ISO 10303-41:2005 does not declare it (supplement.expdoes). -
Writers: OpenCASCADE names the protocol
'ap242_managed_model_based_3d_engineering'inAPPLICATION_PROTOCOL_DEFINITION, but every AP242 long form from edition 2 on requires'ap242_managed_model_based_3d_engineering_mim_lf'(ruleap242_application_protocol_definition_required); NX-Style corrects it in the B-rep it merges. AP214 edition 3’s long form makespresentation_style_assignmenta subtype offounded_itemand then forbids founded items other than three kinds (subtype_mandatory_founded_item), so every styled AP214 file breaks it.
The schemas
NXStyle/nxstyle/resources/iso10303/dictionary.json holds the schemas as the interpreter needs them: entities, supertypes, attributes and their types, short names, and the WHERE and UNIQUE rules, DERIVE expressions, INVERSE declarations, FUNCTIONs, RULEs and CONSTANTs. tools/iso10303_dictionary.py builds it from the parts themselves:
python tools/iso10303_dictionary.py --part 41=part41.pdf --part 42=part42.pdf --part 43=part43.pdf \
--part 50=part50.pdf --part 55=part55.pdf --part 108=part108.pdf --cor 108=cor1.pdf --cor 108=cor2.pdf \
--part 111=part111.pdf --part 112=part112.pdf --part 13584-20=iso13584-20.pdf
It takes the EXPRESS from between the *) and (* lines the parts print around it, drops page headers and footers, joins string literals a page layout split, applies Cor.1 (the renaming of model_parameter to variational_parameter, the replaced entities) and Cor.2, applies the one erratum it lists (the Cor.2 WR1 above, bracketed as AP242 prints it), and adds supplement.exp, the one declaration the parts leave out.
The result: 772 entities, 153 types, 286 functions, 29 constants, 577 entity and 28 type WHERE rules.
The parts' prose is not in this repository; their EXPRESS is, as it is in the AP242 long form ISO publishes at standards.iso.org for implementations.