Add base profiles and holes for fractional dimension bins#151
Open
mdorman wants to merge 3 commits intoStu142:masterfrom
Open
Add base profiles and holes for fractional dimension bins#151mdorman wants to merge 3 commits intoStu142:masterfrom
mdorman wants to merge 3 commits intoStu142:masterfrom
Conversation
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>
Owner
|
@mdorman Thanks for the contribution, sorry for the delay, it sounds great, I will take a look hopefully soon at what it produces. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bins with fractional
xGridUnits/yGridUnits(e.g. 2.5×1) already had their outer body sized correctly, butmake_complex_bin_baseandmake_bin_bottom_holesonly 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_channelgains optionalx_hole_pos/y_hole_posparameters so fractional cells can place channels at non-standard positions; defaults preserve the existing full-cell behaviour.2*MagnetHoleDistanceFromEdge + MagnetHoleDiameter(can't fit).xGridUnitsattribute) are unaffected.