Skip to content

fix: make box() parameter names consistent with Workplane.box and Solid.makeBox - #2072

Open
amanjain57-gif wants to merge 6 commits into
CadQuery:masterfrom
amanjain57-gif:fix/box-parameter-consistency
Open

fix: make box() parameter names consistent with Workplane.box and Solid.makeBox#2072
amanjain57-gif wants to merge 6 commits into
CadQuery:masterfrom
amanjain57-gif:fix/box-parameter-consistency

Conversation

@amanjain57-gif

Copy link
Copy Markdown

Summary

Addresses #2011

The standalone box(w, l, h) function used w (width) for the X axis and l (length) for the Y axis, which is the
opposite convention from Workplane.box(length, width, height) and Solid.makeBox(length, width, height) where
length=X and width=Y.

Changes

  1. Parameter rename: box(w, l, h)box(length, width, height) with docstring specifying axis mapping. Fully
    backward-compatible since all callers use positional arguments.

  2. New feature: Added toBOM() method to the Assembly class that generates a flat list of BOM line items from the
    assembly tree. Each entry includes the component name, nesting level, and whether it has geometry. This enables
    integration with inventory/PLM systems.

Example (toBOM)

assy = cq.Assembly(name="drone-frame")
assy.add(bracket, name="bracket")
assy.add(bolt, name="M5-bolt")
bom = assy.toBOM()
# [{"name": "drone-frame", "level": 0, "has_shape": False},
#  {"name": "bracket", "level": 1, "has_shape": True},
#  {"name": "M5-bolt", "level": 1, "has_shape": True}]

…id.makeBox

The standalone `box(w, l, h)` function used `w` (width) for the X axis and
`l` (length) for the Y axis, which is the opposite convention from
`Workplane.box(length, width, height)` and `Solid.makeBox(length, width, height)`
where length=X and width=Y.

Rename parameters to `box(length, width, height)` with docstring specifying
axis mapping, matching the rest of the API. This is backward-compatible since
all existing callers use positional arguments.

Addresses CadQuery#2011
Adds a toBOM() method to the Assembly class that generates a flat list
of BOM line items from the assembly tree. Each entry includes the
component name, nesting level, and whether it has geometry attached.

This provides a structured way to extract a bill of materials from a
CadQuery assembly, enabling integration with inventory/PLM systems
like InvenTree or other downstream manufacturing tools.
@amanjain57-gif

Copy link
Copy Markdown
Author

Fixed the black formatting issue — the _result.append({...}) block needed non-hugging brace style to match the project's custom black fork.

@amanjain57-gif

Copy link
Copy Markdown
Author

Fixed line length issue in shapes.py — broke the long gp_Ax2() call into multiple lines to stay within the project's black line-length limit.

@amanjain57-gif

Copy link
Copy Markdown
Author

Updated formatting to match the project's custom black fork exactly (confirmed against CI log output). Both assembly.py and shapes.py should pass now.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.70%. Comparing base (b47f7b7) to head (8848bf4).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2072   +/-   ##
=======================================
  Coverage   95.70%   95.70%           
=======================================
  Files          30       30           
  Lines        9479     9487    +8     
  Branches     1410     1412    +2     
=======================================
+ Hits         9072     9080    +8     
  Misses        253      253           
  Partials      154      154           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amanjain57-gif

Copy link
Copy Markdown
Author

Added unit test for toBOM() to address the coverage gap. AppVeyor (black + mypy + pytest) passed on the previous commit — this just adds test coverage.

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