Assembly export and viewer
arena assembly export-meshes writes every part of an assembly at one pose as its own glTF file,
with a manifest that holds the joint coordinate, the deviation, the requirement and the measured
gap. The web viewer in web/ loads such a manifest, labels each part with its id, and shows the
joint coordinate, the gap and the line between the two kernel witness points. The exporter is
src/tolerance_arena/assembly/export.py; the writer under it is meshes.export_meshes, the same
one that arena export-meshes uses for the pin. The evidence log is
docs/assembly-log/export-viewer.md.
Export a pose
A family at its planted parameters, or a STEP sidecar assembly, at one joint coordinate q and one
deviation delta:
arena assembly export-meshes --family hinged-flap-post --q 45 --delta-mm=-1.2 \
--output web/public/data/family-hinged-flap-post
arena assembly export-meshes --sidecar fixtures/assembly/hinge.assembly.yaml --q 85 --delta-mm=-0.5 \
--output web/public/data/step-hinge
| Option | Meaning |
|---|---|
--sidecar FILE or --family ID | Exactly one source. A sidecar is loaded with its STEP files and their hashes; a family is built at its planted parameters. |
--param NAME=VALUE | With --family only. Replaces one planted parameter; repeat for more. A repeated name, a missing value or an unknown name is refused. |
--q | Joint coordinate: degrees for a revolute joint, millimetres for a prismatic one. |
--delta-mm | Deviation in millimetres. A negative value is written --delta-mm=-1.2. |
--output DIR | The directory for the .glb files and manifest.json. |
--tessellation-mm | Linear tessellation tolerance. The default is the pin export's. |
--json | Print the manifest instead of the text summary. |
All of --q, --delta-mm and --output are required. Numbers are plain decimals: nan, inf,
4_5 and a leading space are refused. A pose outside the joint range or the deviation range, a
failed gap query, a part the viewer cannot name and an unwritable directory exit 2 with
refused: ... and write no file. The pose is checked and the gap is measured before the first
file is written.
The text output ends with the scope of the number: the gap is measured at this pose only, no verdict was computed and no other pose was measured.
The manifest
The top level is the pin export's: schema_version, unit (mm), view_frame (metres, +Y up,
right-handed), one cad_to_view matrix, conversion_reason, tessellation and pieces. Each
piece has name, file_name, sha256, unit, tessellation_tolerance_mm and the same matrix.
For an assembly the piece names are the part ids, in assembly order.
The pose block has "kind": "assembly" where the pin pose has fixture, angle_deg and
offset_mm:
"pose": {
"kind": "assembly",
"assembly_id": "...", "source": "...",
"joint": {"id", "type", "q", "unit", "range", "fixed_part", "moving_part", "axis", "origin_mm"},
"deviation": {"id", "part", "delta_mm", "range_mm", "direction"},
"requirement": {"id", "type", "parts", "minimum_mm"},
"measurement": {"distance_mm", "overlap", "witness_points_mm": {"first", "second"} or null}
}
source says where the assembly came from: a family and its version, or the sidecar file name with
its SHA-256. The witness points are CAD-frame millimetres in the world frame of the placed assembly.
When the parts touch or overlap the kernel witnesses are not a gap, so overlap is true,
distance_mm is 0 and witness_points_mm is null.
One conversion
The exporter writes each piece from a copy at C * L * C^-1, where L is the part's placement in
the CAD frame and C is the CAD to view rotation. The node in the glTF file therefore holds
C * L in metres: the manifest matrix has already been applied once, by the writer. The viewer
puts each loaded piece under a group with the identity (placeExportedPiece) and uses the manifest
matrix only for CAD-frame numbers that the manifest holds, which are the witness points. Applying
the matrix to a piece again would turn the parts a second time.
View a pose
The viewer reads data/NAME/manifest.json and data/NAME/FILE.glb from web/public/data/ and
serves the pose that the address names:
?pose=NAMEselects the directorydata/NAME.NAMEis one to 64 letters, digits,_,.or-and starts with a letter or a digit, so it cannot hold a slash, a scheme or a parent reference. Anything else showsinvalid_pose_nameand fetches nothing.- No parameter shows
data/pose, the committed pin sample, exactly as before.
Two assembly poses are committed: data/family-hinged-flap-post (a family) and data/step-hinge
(a STEP sidecar). Run npm run dev in web/ and open the address Vite prints with
?pose=step-hinge or ?pose=family-hinged-flap-post added.
For an assembly pose the page shows:
- one label per part in the scene, anchored above the part and reading its id;
- a Parts panel: each id with a colour swatch and what it is (moving or fixed part of a joint, the part the deviation moves, its position in the requirement), and the source;
- a Joint coordinate panel: the joint id and type,
qwith its unit and range, the axis and the point it passes through, and the deviation with its range; - a Measured gap panel: the distance, the requirement and its minimum, the two witness points, and a marker in the scene between them, a bar with a ball at each end.
The viewer computes no verdict. The minimum in the requirement is printed beside the gap; the page never says that the gap satisfies or violates it. When the parts overlap the page says so and draws no marker.
Refusals in the viewer
parseManifest refuses an assembly pose with invalid_assembly_pose and names the field:
a joint coordinate or deviation outside its range, a range that is reversed, a joint in the wrong
unit for its type, a requirement with fewer than two distinct parts or a minimum that is not
positive, a distance that the witness points do not span within 1e-6 mm, an overlap that carries a
distance or witness points, and a gap with no witness points. A part that the pose names and the
manifest does not list is missing_piece. A manifest without kind: "assembly" keeps the pin
rules, so it still needs a pin and an obstacle piece.
Limits
- One pose per export. The viewer does not move a joint; it shows the pose that was exported.
- The requirement type is
minimum_clearanceonly. - Four part colours exist (
--scene-pin,--scene-obstacle,--scene-part-c,--scene-part-d); a fifth part reuses the first. - The GLB vertices are 32-bit floats in metres, so a coordinate read from a mesh agrees with the CAD value to about 1e-4 mm, not to 1e-6 mm.