Skip to content

Add base profiles and holes for fractional dimension bins#151

Open
mdorman wants to merge 3 commits intoStu142:masterfrom
mdorman:fractional-base
Open

Add base profiles and holes for fractional dimension bins#151
mdorman wants to merge 3 commits intoStu142:masterfrom
mdorman:fractional-base

Conversation

@mdorman
Copy link
Copy Markdown

@mdorman mdorman commented Mar 21, 2026

Bins with fractional xGridUnits/yGridUnits (e.g. 2.5×1) already had their outer body sized correctly, but make_complex_bin_base and make_bin_bottom_holes only generated base profiles and magnet/screw holes for the integer portion of the layout. The fractional remainder strip had a flat bottom with no chamfer, sometimes making such bins unstable in fractional baseplates. I think this change completes the bin-related half of the request at #78, in that it extends #129 to also produce fractional bases. It produces results consistent with the OpenSCAD Gridfinity Extended project.

To address this, this change alters the code so that after tiling the integer layout, it will iterate over each fractional strip (X edge, Y edge, and corner if both axes are fractional) and generate a correctly-dimensioned base profile or hole set for it.

The chamfer/vertical/chamfer profile math is unchanged — only the cell dimensions passed to it differ — so the interlocking geometry is correct on all four sides of each fractional strip.

Implementation notes:

  • _make_single_cell_base_profile/_make_single_cell_holes: extracted helpers that produce per-cell geometry for any (x, y) cell size, used for both full and fractional cells.
  • _fractional_strip_specs: generator that yields (x_size, y_size, vecs) for each fractional strip, keeping the coordinate arithmetic in one place and out of both callers.
  • magnet_hole.remove_channel gains optional x_hole_pos/y_hole_pos parameters so fractional cells can place channels at non-standard positions; defaults preserve the existing full-cell behaviour.
  • Holes are skipped for fractional strips narrower than 2*MagnetHoleDistanceFromEdge + MagnetHoleDiameter (can't fit).
  • Custom-shape bins (no xGridUnits attribute) are unaffected.

mdorman and others added 3 commits March 21, 2026 15:42
Bins with fractional xGridUnits/yGridUnits (e.g. 2.5×1) already had
their outer body sized correctly, but make_complex_bin_base and
make_bin_bottom_holes only generated base profiles and magnet/screw
holes for the integer portion of the layout. The fractional remainder
strip had a flat bottom with no chamfer, making such bins unstable in
fractional baseplates.

Fix: after tiling the integer layout, iterate over each fractional
strip (X edge, Y edge, and corner if both axes are fractional) and
generate a correctly-dimensioned base profile or hole set for it.

The chamfer/vertical/chamfer profile math is unchanged — only the
cell dimensions passed to it differ — so the interlocking geometry
is correct on all four sides of each fractional strip.

Implementation notes:
- _make_single_cell_base_profile / _make_single_cell_holes: extracted
  helpers that produce per-cell geometry for any (x, y) cell size,
  used for both full and fractional cells.
- _fractional_strip_specs: generator that yields (x_size, y_size, vecs)
  for each fractional strip, keeping the coordinate arithmetic in one
  place and out of both callers.
- magnet_hole.remove_channel gains optional x_hole_pos/y_hole_pos
  parameters so fractional cells can place channels at non-standard
  positions; defaults preserve the existing full-cell behaviour.
- Holes are skipped for fractional strips narrower than
  2*MagnetHoleDistanceFromEdge + MagnetHoleDiameter (can't fit).
- Custom-shape bins (no xGridUnits attribute) are unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The old test compared vol(2.75x1) > vol(3.0x1) with magnet holes, reasoning
that the integer bin has more base cells → more holes → less volume. This is
wrong: both bins have 12 holes (the 2.75 fractional strip at 31.5mm exceeds
min_size so gets holes), but 3.0x1 has more solid material, so vol(3.0) is
always larger.

Replace with a test that directly measures the intent: the 2.75x1 bin (strip
wide enough for holes) should have more volume removed by holes than a 2.5x1
bin (strip at 21mm < min_size, no fractional holes). This correctly verifies
that hole placement in fractional strips works.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fractional cells require full Clearance on all sides so they fit
independently into half-pitch grid slots. This means the per-cell
clearance creates an inherent ~0.085mm CoG asymmetry for fractional
bins (a 21mm strip loses the same 0.5mm clearance as a 42mm cell,
breaking exact mass symmetry). The places=3 tolerance (0.001mm) was
unachievable without changing geometry that must stay correct.

Switch to delta=0.1 with a comment explaining the root cause.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Stu142
Copy link
Copy Markdown
Owner

Stu142 commented Apr 5, 2026

@mdorman Thanks for the contribution, sorry for the delay, it sounds great, I will take a look hopefully soon at what it produces.

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