Skip to content

feat(exchange): export_step_in for bodies in a unit other than metres - #35

Merged
aka-blackboots merged 5 commits into
OpenGeometry-io:mainfrom
Bas-Automation-Services:feat/step-model-unit
Nov 20, 2026
Merged

aka-blackboots merged 5 commits into
OpenGeometry-io:mainfrom
Bas-Automation-Services:feat/step-model-unit

Conversation

@Basnederveen

@Basnederveen Basnederveen commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What

export_step takes a body's coordinates as metres and scales them to the file unit. A body built in millimetres had no way to say so: exporting it as millimetres multiplied every coordinate by 1000, so a 100 mm plate came out 100 m wide.

export_step_in(brep, model_unit, unit) takes the unit the body is built in ("metre" or "millimetre") and scales from it to the file unit once. export_step(brep, unit) keeps its behaviour and delegates with model_unit = "metre".

  • Each unit is its length in millimetres, reduced to one factor: metre to millimetre multiplies by 1000 (the same digits as before), millimetre to metre divides by 1000, and equal units are untouched.
  • The file unit check and its message are unchanged; an unknown model unit is InvalidGeometry too.
  • export_bodies gets the model unit as a parameter. StepOptions has modelUnit (default "metre"), so OpenGeometry.exportStep({ nodes, unit: 'millimetre', modelUnit: 'millimetre' }) writes a 100 mm plate unscaled from JavaScript.
  • export_ifc_body_in(brep, model_unit, conversion) does the same for the IFC body. It scales to metres through placed, with the geometric tolerance, exchange error bound and fitting budget scaled alike, so length_unit: "metre" holds for a millimetre body. export_ifc_body delegates with "metre". WorldGraph::export_ifc_body(og_id, model_unit) and OpenGeometry.exportIfcBody(node, { modelUnit }) pass it through.
  • Scale lives in exchange/unit.rs, shared by both exports. An unknown model unit is InvalidParameter in the world graph and in JavaScript.
  • The default is "metre" everywhere, so existing exports are unchanged.

Tests

  • step_oracle::ifc_body: a millimetre model's IFC body is a thousandth of the metre body (points, tolerance and bound), and unknown model units are refused. step_oracle::placed: a millimetre world model exported to millimetres writes the metre-to-metre digits. Node tests check both from JavaScript.
  • exchange::step::tests has five tests, one per behaviour, on a 100 x 50 x 9 mm plate with millimetre accuracy: millimetre to millimetre writes coordinates unchanged (digit for digit the metre export, except the SI_UNIT prefix), millimetre to metre divides by 1000 (the corner is written as 0.1, 0.05, 0.009), a metre body to millimetres still scales by 1000, and unknown file or model units are refused.
  • npm run check without CI=true on Windows x86_64: fmt and clippy are clean. Rust tests give 947 passed, 6 failed, 1 ignored; the 6 are the stored-fixture and digest comparisons that already failed on that machine before this PR. Every npm step passes except build-example, which hits a Windows path error in vite. Details are in the review reply.

Files

  • main/opengeometry/src/exchange/step/mod.rs
  • main/opengeometry/src/exchange/unit.rs
  • main/opengeometry/src/exchange/step/tests.rs
  • main/opengeometry/src/exchange/mod.rs
  • main/opengeometry/src/exchange/ifc_body/mod.rs
  • main/opengeometry/src/world_graph/export.rs
  • main/opengeometry/src/world_graph/export_ifc.rs
  • main/opengeometry/src/bindings/world_graph/ifc_body.rs
  • main/opengeometry-three/src/export/export-step.ts, ifc-body.ts, opengeometry.ts
  • tests: tests/step_oracle/ifc_body.rs, placed.rs, opengeometry-three/tests/node/export-step.test.mjs, ifc-body.test.mjs
  • docs: README.md, docs/opengeometry/api/export.mdx, guides/export-step.mdx, guides/ifc-exchange-body.mdx

🤖 Generated with Claude Code

export_step takes a body's coordinates as metres and scales them to the
file unit. A body built in millimetres had no way to say so: exporting
it as millimetres multiplied every coordinate by 1000 (a 100 mm plate
came out 100 m wide).

export_step_in(brep, model_unit, unit) takes the unit the body is built
in ("metre" or "millimetre") and scales from it to the file unit once.
export_step keeps its behaviour and delegates with model_unit = "metre".
The scale is a fixed table, so metre bodies export the same digits as
before. export_bodies takes the model unit; the world graph passes
"metre".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VFZvqx1RmXzPtbL9VXP4H7

@aka-blackboots aka-blackboots left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are inline, tagged by severity.

The test run in the description used CI=true, which skips the golden and stored STEP comparisons. Please run npm run check from main/ without it and paste the result.

…aviour

Each length unit is now its size in millimetres, reduced to a single
factor: metre to millimetre still multiplies by 1000 (same digits as
before), millimetre to metre divides by 1000 instead of multiplying by
1e-3, and equal units leave coordinates untouched. A 9 mm thickness is
written as 0.009 rather than 0.009000000000000001.

The millimetre tests build their plate with an accuracy scaled to
millimetres and check the written SI_UNIT and corner points. The one
combined test is split into five, one per behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Basnederveen

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The fixes are in 4efe153 and I've replied inline. The two High items need your decision on where the model unit should live; the options are in the thread on exchange/step/mod.rs.

npm run check without CI=true (Windows x86_64):

  • opengeometry Rust: fmt and clippy are clean. cargo test --offline --all-targets --no-fail-fast gives 893 passed, 6 failed, 1 ignored. All 6 failures fail the same way on the commit before 4efe153 on this machine. They are stored-fixture and digest comparisons that this PR doesn't touch:

    • booleans: wc_subtract::the_wc_pan_shell_minus_its_six_arc_bowl_opening_is_the_recorded_prismatic_result
    • cases: tessellation::primitive_tessellation_matches_stored_fixtures, matrix::boolean_support_matrix_matches_stored_outcomes_and_handlers, batch::batch_subtraction_matches_stored_brep_and_handlers
    • golden: every_golden_scene_matches_the_recorded_golden_for_this_target
    • step_oracle: ifc_body::ifc_bodies_of_the_matrix_results_match_the_2_0_18_digests

    The other 44 step_oracle tests pass, including the bit-for-bit membership checks.

  • These pass: test-support fmt, clippy and test; test:wasm, build, worker-bundle, lint:check, typecheck, check:source, check:cycles, check:duplicates, test:bindings, test:node and test:performance.

  • build-example fails in vite on Windows, unrelated to this PR: [vite:build-html] The "fileName" or "name" properties of emitted chunks and assets must be strings that are neither absolute nor relative paths, received "../../../../../../../Repositories/.../analytic-boolean-operations.html".

verify.mjs itself doesn't run on Windows. It names its log files after the step (.check/rust:opengeometry:fmt.log), and Windows file names can't contain :. It also spawns npm without a shell, which gives spawn npm ENOENT. I patched both locally to get the results above; neither patch is in this PR. I can open a separate PR for them if you'd like.

Basnederveen and others added 2 commits November 17, 2026 06:44
export_ifc_body_in(brep, model_unit, conversion) scales a body built in
millimetres to metres through placed(), with the geometric tolerance,
exchange error bound and fitting budget scaled alike; export_ifc_body
delegates with "metre". The Scale helper moves from exchange/step to
exchange so both exports share it.

StepOptions gets modelUnit (default "metre") and WorldGraph::export_ifc_body
takes the model unit, so OpenGeometry.exportStep({ modelUnit }) and
OpenGeometry.exportIfcBody(node, { modelUnit }) reach it from JavaScript.
Metre bodies export exactly as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mintlify

mintlify Bot commented Nov 17, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 067bd7d.

Approve preview

@Basnederveen

Copy link
Copy Markdown
Contributor Author

Option 1 is in 067bd7d, after a merge of 3.0.1 main. Details are in the two threads.

npm run check without CI=true (Windows x86_64):

  • opengeometry Rust: fmt and clippy are clean. Tests give 947 passed, 6 failed, 1 ignored. The 6 failures are the same six stored-fixture and digest comparisons as last time, which this PR doesn't touch.
  • Every other step passes except build-example (the vite path error on Windows) and typecheck, which only fails on the local shell patch that verify.mjs needs to run on Windows. Without that patch, npm run typecheck passes.

@aka-blackboots

Copy link
Copy Markdown
Contributor

Great work @Basnederveen. Thank you for the contribution!

@aka-blackboots
aka-blackboots merged commit 61c05b1 into OpenGeometry-io:main Nov 20, 2026
1 check passed
Basnederveen added a commit to Bas-Automation-Services/OpenGeometry that referenced this pull request Nov 20, 2026
…integration/3.0

Scale now lives in exchange/unit.rs as upstream has it; step/unit.rs is gone and
step/wrapped.rs imports the shared one. add_surfaces keeps the integration-only
fitting budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants