From cfb5cbee6c8c9c5d19c70b1c33cdb11a5ec56ad0 Mon Sep 17 00:00:00 2001 From: Diego Pereyra Date: Sat, 20 Sep 2025 15:15:34 -0300 Subject: [PATCH] Added --solid --- gfthings/Bin.py | 80 ++++++++++++++++++++++++----------------------- gfthings/gfbin.py | 17 +++++++++- 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/gfthings/Bin.py b/gfthings/Bin.py index 8dceee4..ceca53f 100644 --- a/gfthings/Bin.py +++ b/gfthings/Bin.py @@ -162,6 +162,7 @@ def __init__(self, width : int, depth : int, lip : bool = True, rotation: tuple[float, float, float] | Rotation = (0, 0, 0), label: bool = True, + solid: bool = False, align: Align | tuple[Align, Align, Align] = None, mode: Mode = Mode.ADD): import math @@ -188,46 +189,47 @@ def __init__(self, width : int, depth : int, magnet_depth=magnet_depth, align=(Align.CENTER, Align.CENTER, Align.MAX)) - inner_width = width * bin_size - bin_clearance*2 - wall_thickness*2 - inner_depth = depth * bin_size - bin_clearance*2 - wall_thickness*2 - with BuildSketch(faces().filter_by(Plane.XY).sort_by(Axis.Z)[-1]): - RectangleRounded(inner_width, inner_depth, - radius=outer_rad - bin_clearance - - wall_thickness) - - inner_height = wall_height - if width > 1 or depth > 1 or half_grid: - # For a bin that covers more than one square we need a floor - # to connect the squares. - inner_height -= wall_thickness - extrude(amount=-inner_height, mode=Mode.SUBTRACT) - - inner_front_centre = faces().filter_by(Plane.XY) \ - .sort_by(Axis.Z)[-2].edges().filter_by(Axis.X) \ - .sort_by(Axis.Y)[0]@0.5 - - # This fillet rounds off the floor of the bin nicely. - inner_fillet_rad=7.5/2 - wall_thickness - if inner_height == wall_height: - # It is it can also prevent the wall-base corner from being too thin. - inner_fillet_rad = max(inner_fillet_rad, wall_thickness) - if inner_fillet_rad: - fillet(faces().filter_by(Plane.XY).sort_by(Axis.Z)[-2].edges(), radius=inner_fillet_rad) - if divisions > 1: - dividors = divisions-1 - dividor_space = inner_width / divisions - with Locations(inner_front_centre): - with GridLocations(dividor_space, 1, dividors, 1): - # Use inner_height if there's no shelf, otherwise - # subtract the shelf's cuttout depth. - Box(wall_thickness, inner_depth, inner_height - 1.1, - align=(Align.CENTER, Align.MIN, Align.MIN)) + if not solid: + inner_width = width * bin_size - bin_clearance*2 - wall_thickness*2 + inner_depth = depth * bin_size - bin_clearance*2 - wall_thickness*2 + with BuildSketch(faces().filter_by(Plane.XY).sort_by(Axis.Z)[-1]): + RectangleRounded(inner_width, inner_depth, + radius=outer_rad - bin_clearance - + wall_thickness) + + inner_height = wall_height + if width > 1 or depth > 1 or half_grid: + # For a bin that covers more than one square we need a floor + # to connect the squares. + inner_height -= wall_thickness + extrude(amount=-inner_height, mode=Mode.SUBTRACT) + + inner_front_centre = faces().filter_by(Plane.XY) \ + .sort_by(Axis.Z)[-2].edges().filter_by(Axis.X) \ + .sort_by(Axis.Y)[0]@0.5 + + # This fillet rounds off the floor of the bin nicely. + inner_fillet_rad=7.5/2 - wall_thickness + if inner_height == wall_height: + # It is it can also prevent the wall-base corner from being too thin. + inner_fillet_rad = max(inner_fillet_rad, wall_thickness) + if inner_fillet_rad: + fillet(faces().filter_by(Plane.XY).sort_by(Axis.Z)[-2].edges(), radius=inner_fillet_rad) + if divisions > 1: + dividors = divisions-1 + dividor_space = inner_width / divisions + with Locations(inner_front_centre): + with GridLocations(dividor_space, 1, dividors, 1): + # Use inner_height if there's no shelf, otherwise + # subtract the shelf's cuttout depth. + Box(wall_thickness, inner_depth, inner_height - 1.1, + align=(Align.CENTER, Align.MIN, Align.MIN)) - if scoop_rad and scoop_rad > 0: - with Locations(inner_front_centre): - Scoop(scoop_rad, inner_width, inner_height, - wall_thickness, shelf_clearance, - align=(Align.CENTER, Align.MIN, Align.MIN)) + if scoop_rad and scoop_rad > 0: + with Locations(inner_front_centre): + Scoop(scoop_rad, inner_width, inner_height, + wall_thickness, shelf_clearance, + align=(Align.CENTER, Align.MIN, Align.MIN)) if lip: with Locations((0, 0, wall_height/2 + plate_height)): diff --git a/gfthings/gfbin.py b/gfthings/gfbin.py index 9d9a631..6f83086 100644 --- a/gfthings/gfbin.py +++ b/gfthings/gfbin.py @@ -115,6 +115,12 @@ def main(argv: list[str] | None = None): "scoops and divisions aren't supported.", type=str, default="") + parser.add_argument( + "--solid", + help="Create a solid gridfinity bin. This is useful to make " + + "the base for further modeling and carve out the bin as " + "needed.", + action="store_true") args = parser.parse_args(argv) @@ -155,6 +161,10 @@ def main(argv: list[str] | None = None): bin = None funky = args.funky if funky != "": + if args.solid: + print("Funky bins don't support the solid option.") + exit(1) + if funky == "donut": funky_expr = [[True, True, True], [True, False, True], @@ -189,6 +199,10 @@ def main(argv: list[str] | None = None): half_grid=args.half_grid, wall_thickness=args.wall_thickness) elif args.half_wall: + if args.solid: + print("Half wall bins don't support the solid option.") + exit(1) + bin = HalfWallBin(x, y, z, divisions=divisions, lip=not args.no_lip, @@ -207,7 +221,8 @@ def main(argv: list[str] | None = None): magnet_dia=args.magnet_dia, magnet_depth=args.magnet_height, half_grid=args.half_grid, - wall_thickness=args.wall_thickness) + wall_thickness=args.wall_thickness, + solid=solid) if args.vscode: from ocp_vscode import (show_object,