Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions gfthings/Bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self,

class BinBase(BasePartObject):
def __init__(self,
magnets: bool,
refined: bool,
magnet_dia: float,
magnet_depth: float,
Expand All @@ -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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand All @@ -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,
Expand All @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion gfthings/gfbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 " +
Expand All @@ -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' " +
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_bins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)