Skip to content

fix(freecad): build boolean parts and export only final shapes - #577

Open
kevin9327 wants to merge 1 commit into
HKUDS:mainfrom
kevin9327:fix/freecad-boolean-export
Open

kevin9327 wants to merge 1 commit into
HKUDS:mainfrom
kevin9327:fix/freecad-boolean-export

Conversation

@kevin9327

Copy link
Copy Markdown

Description

Two defects from #468 in the FreeCAD harness's macro generator (utils/freecad_macro_gen.py).

A: part boolean never produced geometry. parts.boolean_op stores the result in project["parts"] with type set to cut/fuse/common and params.base_id/tool_id. _gen_parts only knew primitives, so the result was written out as # WARNING: Unknown part type 'cut'. (_gen_boolean_ops reads a separate boolean_ops list that part boolean doesn't fill.) _gen_parts now emits Part::Cut / Part::Fuse / Part::Common for these parts, looking up the operands by id. The operands are always earlier parts, so they already exist at that point.

B: export included intermediate shapes. _gen_export collected every object with a valid Shape, so boolean operands and every PartDesign feature solid were exported along with the final result. It now skips objects with a non-empty InList, meaning objects another object consumes (boolean operands, features inside a Body, the Body's origin). Standalone parts are still exported as before.

Measured with real FreeCAD 1.1.4 (freecadcmd) on the repro from the issue (40×30×20 box minus an r=6 cylinder, expected 24000 − π·6²·20 = 21738.05 mm³):

path before after
part add ×2 + part boolean cut 27391.4 mm³ (box + cylinder, no cut) 21739.0 mm³
body additive-box + subtractive-cylinder 67478.0 mm³, 1052 triangles 21739.0 mm³, 520 triangles

These match the numbers in the issue.

Fixes #468 (defects A and B; I didn't touch the secondary notes 4–6).

Type of Change

  • Bug Fix: fixes incorrect behavior

Testing

  • TestIntermediateFiles::test_boolean_part_emits_freecad_boolean: the macro builds Part::Cut with the right Base/Tool (no FreeCAD needed).
  • TestFreeCADBackend::test_export_boolean_cut_stl_is_the_cut_solid and test_export_body_stl_excludes_intermediate_features: export to STL and check the mesh volume against the expected solid.
  • All three fail before the change and pass after (with FREECAD_PATH pointing at FreeCAD 1.1.4). The full cli_anything/freecad/tests suite gives 109 passed, 6 skipped.

I used an AI assistant to help write this change. I reproduced both defects with real FreeCAD and checked the fix and tests myself.

part boolean stores its result in project parts with type cut/fuse/common,
but the macro generator only emitted primitives, so the boolean object was
never created. The exporter also collected every shape in the document,
so boolean operands and PartDesign feature solids were exported on top of
the final result.

Fixes HKUDS#468
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-17T15:25:42.595536Z 478bbec PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the existing-cli-fix Fixes or improves an existing CLI harness label Oct 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

existing-cli-fix Fixes or improves an existing CLI harness

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: freecad - part boolean produces no geometry, and export emits intermediate shapes instead of the final result

1 participant