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
1 change: 1 addition & 0 deletions freecad/gridfinity_workbench/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
BIN_BASE_BOTTOM_RADIUS = 0.8

STACKING_LIP = True
STACKING_LIP_THIN_STYLE = False
STACKING_LIP_TOP_LEDGE = 0.4
STACKING_LIP_BOTTOM_CHAMFER = 0.7
STACKING_LIP_VERTICAL_SECTION = 1.8
Expand Down
114 changes: 67 additions & 47 deletions freecad/gridfinity_workbench/feature_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,7 @@ def make_label_shelf(obj: fc.DocumentObject, bintype: Literal["eco", "standard"]
ydiv = 1
length = obj.yTotalWidth - obj.WallThickness * 2

width = (
obj.StackingLipTopChamfer
+ obj.StackingLipTopLedge
+ obj.StackingLipBottomChamfer
+ obj.LabelShelfWidth
- obj.WallThickness
)
width = _stacking_lip_offset(obj) + obj.LabelShelfWidth
assert width >= 0

thickness = obj.LabelShelfVerticalThickness
Expand Down Expand Up @@ -258,55 +252,53 @@ def make_scoop(obj: fc.DocumentObject) -> Part.Shape:
xdiv
)

scoopbox = Part.makeBox(
obj.StackingLipBottomChamfer
+ obj.StackingLipTopChamfer
+ obj.StackingLipTopLedge
- obj.WallThickness,
obj.yTotalWidth - obj.WallThickness * 2,
obj.UsableHeight,
fc.Vector(
obj.xTotalWidth + obj.Clearance - obj.WallThickness,
+obj.Clearance + obj.WallThickness,
),
fc.Vector(0, 0, -1),
)

scoop = face.extrude(fc.Vector(0, obj.yTotalWidth - obj.WallThickness * 2))

stacking_lip_offset = _stacking_lip_offset(obj)

vec_list = []
for x in range(xdiv):
if x == 0:
xtranslate = (
zeromm
- obj.WallThickness
+ obj.StackingLipTopLedge
+ obj.StackingLipTopChamfer
+ obj.StackingLipBottomChamfer
)
else:
xtranslate = x * (compwidth + obj.DividerThickness)
xtranslate = stacking_lip_offset.Value if x == 0 else x * (compwidth + obj.DividerThickness)
vec_list.append(fc.Vector(-xtranslate, obj.Clearance + obj.WallThickness))

funcfuse = utils.copy_and_translate(scoop, vec_list)
funcfuse = funcfuse.fuse(scoopbox)

edges = [
edge
for edge in funcfuse.Edges
if abs(edge.Vertexes[0].Z - edge.Vertexes[1].Z) == obj.UsableHeight
and edge.Vertexes[0].X == edge.Vertexes[1].X
]
if obj.StackingLip: # Scoop is offset from the wall due to the stacking lip
scoopbox = Part.makeBox(
stacking_lip_offset.Value,
obj.yTotalWidth - obj.WallThickness * 2,
obj.UsableHeight,
fc.Vector(
obj.xTotalWidth + obj.Clearance - obj.WallThickness,
+obj.Clearance + obj.WallThickness,
),
fc.Vector(0, 0, -1),
)
funcfuse = funcfuse.fuse(scoopbox)

fuse_total = funcfuse.makeFillet(
obj.StackingLipBottomChamfer
+ obj.StackingLipTopChamfer
+ obj.StackingLipTopLedge
- obj.WallThickness
- 0.01 * unitmm,
edges,
)
return fuse_total.translate(fc.Vector(-obj.xLocationOffset, -obj.yLocationOffset))
edges = [
edge
for edge in funcfuse.Edges
if abs(edge.Vertexes[0].Z - edge.Vertexes[1].Z) == obj.UsableHeight
and edge.Vertexes[0].X == edge.Vertexes[1].X
]

funcfuse = funcfuse.makeFillet(stacking_lip_offset - 0.01 * unitmm, edges)
else: # No stacking lip: Trim scoop to stop it extending outside the rounded bin corners
bin_outside_shape = utils.create_rounded_rectangle(
obj.xTotalWidth,
obj.yTotalWidth,
0,
obj.BinOuterRadius,
).translate(
fc.Vector(obj.xTotalWidth / 2 + obj.Clearance, obj.yTotalWidth / 2 + obj.Clearance),
)
bin_outside_solid = Part.Face(bin_outside_shape).extrude(
fc.Vector(0, 0, -obj.TotalHeight + obj.BaseProfileHeight),
)
funcfuse = funcfuse.common(bin_outside_solid)

return funcfuse.translate(fc.Vector(-obj.xLocationOffset, -obj.yLocationOffset))


def _corner_fillets(
Expand Down Expand Up @@ -1245,6 +1237,20 @@ def make_bin_bottom_holes(
return fuse_total.translate(fc.Vector(-obj.xLocationOffset, -obj.yLocationOffset))


def _stacking_lip_offset(obj: fc.DocumentObject) -> fc.Units.Quantity:
"""Calculate width of stacking lip relative to the inside wall."""
return (
(
obj.StackingLipTopLedge
+ obj.StackingLipTopChamfer
+ (obj.StackingLipBottomChamfer if not obj.StackingLipThinStyle else zeromm)
- obj.WallThickness
)
if obj.StackingLip
else zeromm
)


def _stacking_lip_profile(obj: fc.DocumentObject) -> Part.Wire:
"""Create stacking lip profile wire."""
## Calculated Values
Expand Down Expand Up @@ -1279,6 +1285,12 @@ def _stacking_lip_profile(obj: fc.DocumentObject) -> Part.Wire:
fc.Vector(x5, y, z5),
fc.Vector(x5, y, 0),
]
if obj.StackingLipThinStyle:
st[4:] = [ # Modify the bottom section of the stacking lip profile
fc.Vector(x3, y, 0),
fc.Vector(x5, y, (x5 - x3)), # 45 degree chamfer under the lip
fc.Vector(x5, y, 0),
]

stacking_lip_profile = Part.Wire(Part.Shape(utils.loop(st)).Edges)

Expand All @@ -1305,6 +1317,14 @@ def stacking_lip_properties(
"Toggle the stacking lip on or off",
).StackingLip = stacking_lip_default

## Gridfinity Parameters
obj.addProperty(
"App::PropertyBool",
"StackingLipThinStyle",
"Gridfinity",
"Toggle the thin style stacking lip on or off",
).StackingLipThinStyle = const.STACKING_LIP_THIN_STYLE

## Expert Only Parameters
obj.addProperty(
"App::PropertyLength",
Expand Down