diff --git a/gfthings/Bin.py b/gfthings/Bin.py index 8dceee4..faf83c9 100644 --- a/gfthings/Bin.py +++ b/gfthings/Bin.py @@ -39,6 +39,7 @@ def __init__(self, class BinBase(BasePartObject): def __init__(self, + magnets: bool, refined: bool, magnet_dia: float, magnet_depth: float, @@ -48,20 +49,21 @@ def __init__(self, mode: Mode = Mode.ADD): with BuildPart() as p: GFProfileBin(bin_size=bin_size) - if refined: - with Locations(faces().filter_by(Plane.XY).sort_by(Axis.Z)[0]): - with PolarLocations(0, 4): - with Locations((35.6/2-4.8+magnet_dia/2, 35.6/2+0.8+2.15)): - RefinedMagnetHole(magnet_h=magnet_depth, - magnet_w=magnet_dia, - mode=Mode.SUBTRACT, - align=(Align.MAX, Align.MIN, Align.MIN), - rotation=(180, 0, 0)) - else: - with Locations(faces().filter_by(Plane.XY).sort_by(Axis.Z)[0]): - magnet_offset = 35.6/2 - 4.8 - with GridLocations(magnet_offset*2, magnet_offset*2, 2, 2): - Hole(magnet_dia/2, magnet_depth) + if magnets: + if refined: + with Locations(faces().filter_by(Plane.XY).sort_by(Axis.Z)[0]): + with PolarLocations(0, 4): + with Locations((35.6/2-4.8+magnet_dia/2, 35.6/2+0.8+2.15)): + RefinedMagnetHole(magnet_h=magnet_depth, + magnet_w=magnet_dia, + mode=Mode.SUBTRACT, + align=(Align.MAX, Align.MIN, Align.MIN), + rotation=(180, 0, 0)) + else: + with Locations(faces().filter_by(Plane.XY).sort_by(Axis.Z)[0]): + magnet_offset = 35.6/2 - 4.8 + with GridLocations(magnet_offset*2, magnet_offset*2, 2, 2): + Hole(magnet_dia/2, magnet_depth) super().__init__(p.part, rotation, align, mode) @@ -154,6 +156,7 @@ def __init__(self, width : int, depth : int, height_units : int, scoop_rad : float, divisions : int = 1, + magnets : bool = True, refined : bool = True, magnet_dia : float = 6, magnet_depth : float = 2, @@ -182,7 +185,8 @@ def __init__(self, width : int, depth : int, w *= 2 d *= 2 with GridLocations(bs, bs, int(w), int(d)): - BinBase(refined=refined, + BinBase(magnets=magnets, + refined=refined, bin_size = 42 if not half_grid else 21, magnet_dia=magnet_dia, magnet_depth=magnet_depth, @@ -267,6 +271,7 @@ class FunkyBin(BasePartObject): def __init__(self, array : list, height_units : int, + magnets: bool = True, refined : bool = True, magnet_dia : float = 6, magnet_depth : float = 2, @@ -309,7 +314,8 @@ def __init__(self, with Locations(((x - width/2 + 1/2)*bin_size, (y - depth/2 + 1/2)*bin_size, -wall_height/2)): - BinBase(refined=refined, + BinBase(magnets=magnets, + refined=refined, magnet_depth=magnet_depth, magnet_dia=magnet_dia, align=(Align.CENTER, Align.CENTER, Align.MAX)) @@ -327,6 +333,7 @@ class HalfWallBin(BasePartObject): def __init__(self, x, y, z, divisions : int = 1, lip : bool = True, + magnets: bool = True, refined : bool = True, half_grid : bool = False, wall_thickness : float = 1.2, @@ -337,6 +344,7 @@ def __init__(self, x, y, z, Bin(x, y, z, divisions=divisions, lip=lip, + magnets=magnets, refined=refined, magnet_dia=magnet_dia, magnet_depth=magnet_depth, diff --git a/gfthings/gfbin.py b/gfthings/gfbin.py index 9d9a631..748b990 100644 --- a/gfthings/gfbin.py +++ b/gfthings/gfbin.py @@ -70,7 +70,7 @@ def main(argv: list[str] | None = None): parser.add_argument( "--unrefined", help="Use unrefined magnet holes. " + - "Gridfinity Refind " + + "Gridfinity Refined " + "https://www.printables.com/model/413761-gridfinity-refined " + "has improved magnet holes that don't require glue, " + "If for some reason you don't want superiour magnet holes then " + @@ -89,6 +89,10 @@ def main(argv: list[str] | None = None): "(default %(default)s)", type=float, default=2) + parser.add_argument( + "--no-magnets", + help="Don't add holes for magnets.", + action="store_true") parser.add_argument( "--half-grid", help="The base of the bin will fit on a 'half grid' " + @@ -183,6 +187,7 @@ def main(argv: list[str] | None = None): else: funky_expr = eval(args.funky) bin = FunkyBin(list(reversed(funky_expr)), z, + magnets=not args.no_magnets, refined=not args.unrefined, magnet_dia=args.magnet_dia, magnet_depth=args.magnet_height, @@ -192,6 +197,7 @@ def main(argv: list[str] | None = None): bin = HalfWallBin(x, y, z, divisions=divisions, lip=not args.no_lip, + magnets=not args.no_magnets, refined=not args.unrefined, magnet_dia=args.magnet_dia, magnet_depth=args.magnet_height, @@ -203,6 +209,7 @@ def main(argv: list[str] | None = None): divisions=divisions, label=not args.no_label, lip=not args.no_lip, + magnets=not args.no_magnets, refined=not args.unrefined, magnet_dia=args.magnet_dia, magnet_depth=args.magnet_height, diff --git a/tests/test_bins.py b/tests/test_bins.py index 3cf86b0..5852f46 100644 --- a/tests/test_bins.py +++ b/tests/test_bins.py @@ -51,3 +51,8 @@ def test_nolip(): bin = Bin.Bin(1, 1, 4, scoop_rad=0, divisions=1, label=False, lip=False) float_eq(10817.207884007077, bin.volume) + +def test_nomagnets(): + bin = Bin.Bin(1,1,4, scoop_rad = 0, divisions=1, label=False, + magnets=False) + float_eq(12809.05971822781, bin.volume) \ No newline at end of file