Skip to content

Parametric: IGES export and import - #259

Merged
jelveh merged 8 commits into
mainfrom
pariges-nov30/iges
Nov 30, 2026
Merged

jelveh merged 8 commits into
mainfrom
pariges-nov30/iges

Conversation

@jelveh

@jelveh jelveh commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Adds IGES export and import to Parametric, in response to a user asking whether Parametric can write IGES.

No change to the geometry kernel's WebAssembly: the bundled OpenCascade build has no IGES translator, so the translator is written in TypeScript on top of the bindings already there. The download grows only by the new JavaScript.

Export (File › Export IGES…, parts and assemblies)

  • Every face is written as a trimmed NURBS surface (144 over 128). Planes, cylinders, cones, spheres, tori, and surfaces of revolution and extrusion become exact rational B-splines. B-spline surfaces are copied. Offset surfaces are interpolated within 1e-8 of the model size.
  • Each boundary (142) has both its model-space curves (110 lines, 126 B-splines) and the same loop in the surface's parameter space, with PREF 3. Readers can use either.
  • Reversed faces are written with U reversed, so every surface normal points outward.
  • Assemblies: each component is a 402 group named with a 406 and coloured with a 314. Grouped faces are logically dependent, so readers take them once.
  • Surface bodies are included, as for STEP.

Import (Open, Import…, Insert Component, drag and drop: .igs / .iges)

  • Reads 144/142, 143/141, bounded planes (108), untrimmed surfaces, B-rep solids (186 with 514/510/508/504/502), subfigures (308/408) and 124 transforms.
  • Curves: 100, 102, 104, 106, 110, 112, 126. Surfaces: 108, 114, 118, 120, 122, 128, 190–198.
  • Units come from the global section, so inch files come in in mm. Blanked entities are left out unless everything is blanked.
  • The faces go to the kernel as STEP, so its reader computes parameter-space curves and repairs small gaps. Loose faces are then sewn: first at the file's resolution, then at up to 0.1 mm (and at most 0.1% of the model) if edges are still open. Closed shells become solids, and a shell inside another becomes a hollow.
  • B-spline surfaces that are really planes, cylinders, cones, spheres or tori come in as those. B-spline curves that are really lines or arcs come in as those too. This keeps holes, fillets and edges usable for sketches, dimensions and mates.
  • Import stores the result as a regular STEP import feature, so nothing changes in the part file format.
  • Faces that can't be read are counted in a warning. A model that doesn't close into a solid imports as surfaces, with a warning.

Refactor

  • The STEP read and write helpers moved from build.ts to kernel/stepfile.ts, and FeatureError moved to kernel/errors.ts, so the IGES module can use them without a circular import. build.ts re-exports both, and STEP behaviour is unchanged.

Testing

  • tests/iges.test.ts (24 tests) covers:
    • NURBS maths: exact arcs and revolutions, clamping, degree elevation, fitting.
    • File layout: 80 columns, sequence numbers, terminate line, Hollerith strings across lines, other delimiters, D exponents.
    • Each entity family listed above.
    • Kernel round trips of the built-in examples and spline parts: volume within 1e-7 of the original, same face count, analytic faces recovered.
    • Fixtures written by another IGES writer (OpenCascade's, from a plate in inches, a B-rep plate, a loft and a revolved spline).
    • Assembly groups, names and colours; surface bodies; voids; error messages.
  • Exports were also checked with an independent IGES reader (OpenCascade 7.7 via OCP). The files were read once using only the model-space curves and once using only the parameter-space curves. Both ways, they sewed into closed shells with volumes within 1e-7 of the original. The one exception is the model-space-only reading of a sphere: the poles have no model-space edge, so that reader can't close it; it closes in the other modes.
  • The importer was run on a 22-file corpus written by that reader's writer, in both trimmed-surface and B-rep modes (fillets, cones, tori, spheres, lofts, revolved and extruded splines, two-body files, a hollow solid, inch units). Volumes matched within 2e-9. It was also run on two public sample files from another CAD system: one imports as a closed solid; the other (a bearing) stays open, as it does with OpenCascade's own reader.
  • E2E: IGES added to the export cancellation and rolled-back-sketch tests, the file-picker accept list, and the import race tests. New tests open an exported IGES as a new part, import an inch IGES into a part, and refuse a non-IGES file.
  • tsc --noEmit and the full unit suite pass.

Not included: writing B-rep solids (186) on export. Trimmed surfaces are what most CAD systems read and write by default.

Export writes every face as an exact trimmed NURBS surface (144/128) with
each boundary in model space and in the surface's parameter space; assemblies
become named, coloured groups. Import reads trimmed, bounded, analytic and
untrimmed surfaces, B-rep solids and subfigures, hands the faces to the
kernel's STEP reader, sews them into solids (inner shells become hollows) and
recovers planes, cylinders, cones, spheres, tori, lines and arcs from
B-splines. No change to the WebAssembly kernel.

The STEP read/write helpers move to kernel/stepfile.ts and FeatureError to
kernel/errors.ts so the IGES module can share them.
Shelling a smooth loft outwards leaves zero-area sliver faces where the
rounds meet; an exported part carried them, and the importer read them back
as stray surface bodies and specks of solid (with a 'does not close into a
solid' warning) instead of one hollow solid.
Whether a closed shell lies inside another was decided by intersecting the
two solids, and each hollow was cut out with a boolean. On spline surfaces
each boolean took seconds (an outward-shelled loft took 7 s to import, almost
all of it in two booleans) and the cut lost accuracy; a multi-body file with
parts inside a larger body's box paid one boolean per part.

Nesting is now decided from a few of the inner shell's vertices (a distance of
zero to the outer solid), and a hollow is the outer shell with the inner one
turned inwards, checked by volume, with the boolean kept as the fallback.
When the tenfold steps from the file's resolution ended exactly on the
coarsest tolerance (0.1 mm, or 0.1% of a model whose size is a power of ten
of the resolution), a model that stayed open was sewn at it a second time,
which is the slowest step of reading a large open model.
…spheres

A B-spline surface read as a plane, cylinder, cone, sphere or torus took the
exact surface's axis from the order of a few sample points, so its normal
could be the other way round from the B-spline's. Boundaries run
counterclockwise about the file's surface, so the kernel then kept the rest of
the surface instead of the face: harmless on open surfaces, but on a torus or
sphere the rest is a valid face too. The swelling handle of a public sample
hammer came in as two whole tori 270 m across (volume 1.2e16 mm3 instead of
2.06e11).

Each recognised surface's normal is compared with the B-spline's, and a face
on one turned the other way is written with its sense reversed (B-rep faces
too).
…tive

The check on a B-spline curve's weights could never be true (it ran only when
the curve had no weights), and surfaces had none. A single curve or surface
with a zero or negative weight wrote NaN into the converted model, and the
whole file failed with 'The STEP file contains no geometry'. Such a face is
now skipped and counted in the import warning, and the rest comes in.
…does

Inserting an IGES file as an assembly component dropped the import's notes:
a file whose surfaces do not close into a solid became a surface component
with no word, while Open and Import warned. It also showed nothing while the
file was read. The insert now shows 'Reading <file>...' and the same warning,
from one shared message.
… part

The fine tolerance came from the file's resolution (at least 0.1 micrometre,
at most 0.01 mm) whatever the model's size, and the coarse one took the size
as at least 1 mm. A part a fraction of a millimetre across lost faces: a
public bearing sample (0.1 mm) came in with 211 of its 213 faces, and the
same part exported and read again with 49, in 30 pieces, because its file's
resolution (0.0009 mm) is close to the length of its smaller edges.

Both tolerances are now at most 0.1% of the model's real size; parts of
10 mm and more are read as before.
@jelveh
jelveh merged commit e213ec4 into main Nov 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant