Skip to content

Commit 55c791b

Browse files
committed
fix: adding clearance at the top of the tab and compartment walls to improve bin stacking
addressing #20
1 parent 707d064 commit 55c791b

File tree

7 files changed

+106
-52
lines changed

7 files changed

+106
-52
lines changed

lib/gridfinityUtils/binBodyCutoutGenerator.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ def createGridfinityBinBodyCutout(
7272
True,
7373
targetComponent
7474
)
75-
# recalculate faces after fillet
76-
[innerCutoutScoopFace, innerCutoputScoopOppositeFace] = getInnerCutoutScoopFace(innerCutoutBody)
77-
scoopOppositeEdge = faceUtils.getBottomHorizontalEdge(innerCutoputScoopOppositeFace.edges)
75+
if input.hasBottomFillet:
76+
# recalculate faces after fillet
77+
[innerCutoutScoopFace, innerCutoputScoopOppositeFace] = getInnerCutoutScoopFace(innerCutoutBody)
78+
scoopOppositeEdge = faceUtils.getBottomHorizontalEdge(innerCutoputScoopOppositeFace.edges)
7879

79-
filletUtils.createFillet(
80-
[scoopOppositeEdge],
81-
input.filletRadius,
82-
True,
83-
targetComponent
84-
)
80+
filletUtils.createFillet(
81+
[scoopOppositeEdge],
82+
input.filletRadius,
83+
True,
84+
targetComponent
85+
)
8586

8687
return innerCutoutBody

lib/gridfinityUtils/binBodyCutoutGeneratorInput.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def __init__(self):
1010
self.tabPosition = 0
1111
self.tabLength = 1
1212
self.tabWidth = const.BIN_TAB_WIDTH
13+
self.hasBottomFillet = True
1314

1415

1516
@property
@@ -60,6 +61,14 @@ def scoopMaxRadius(self) -> float:
6061
def scoopMaxRadius(self, value: float):
6162
self._scoopMaxRadius = value
6263

64+
@property
65+
def hasBottomFillet(self) -> float:
66+
return self._hasBottomFillet
67+
68+
@hasBottomFillet.setter
69+
def hasBottomFillet(self, value: float):
70+
self._hasBottomFillet = value
71+
6372
@property
6473
def filletRadius(self) -> float:
6574
return self._filletRadius

lib/gridfinityUtils/binBodyGenerator.py

Lines changed: 77 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,60 @@ def createGridfinityBinBody(
124124
for compartment in input.compartments:
125125
compartmentX = compartmentsMinX + compartment.positionX * (compartmentWidthUnit + input.wallThickness)
126126
compartmentY = compartmentsMinY + compartment.positionY * (compartmentLengthUnit + input.wallThickness)
127+
compartmentOriginPoint = adsk.core.Point3D.create(
128+
compartmentX,
129+
compartmentY,
130+
binBodyTotalHeight
131+
)
132+
compartmentWidth = compartmentWidthUnit * compartment.width + (compartment.width - 1) * input.wallThickness
133+
compartmentLength = compartmentLengthUnit * compartment.length + (compartment.length - 1) * input.wallThickness
134+
compartmentDepth = min(binBodyTotalHeight - const.BIN_COMPARTMENT_BOTTOM_THICKNESS, compartment.depth)
135+
136+
compartmentTabInput = BinBodyTabGeneratorInput()
137+
tabOriginPoint = adsk.core.Point3D.create(
138+
compartmentOriginPoint.x + max(0, min(input.tabPosition, input.binWidth - input.tabLength)) * input.baseWidth,
139+
compartmentOriginPoint.y + compartmentLength,
140+
compartmentOriginPoint.z,
141+
)
142+
compartmentTabInput.origin = tabOriginPoint
143+
compartmentTabInput.length = max(0, min(input.tabLength, input.binWidth)) * input.baseWidth
144+
compartmentTabInput.width = input.tabWidth
145+
compartmentTabInput.overhangAngle = input.tabOverhangAngle
146+
compartmentTabInput.topClearance = const.BIN_TAB_TOP_CLEARANCE
147+
127148
[compartmentMerges, compartmentCuts] = createCompartment(
128149
input.wallThickness,
129-
adsk.core.Point3D.create(
130-
compartmentX,
131-
compartmentY,
132-
binBodyTotalHeight
133-
),
134-
compartmentWidthUnit * compartment.width + (compartment.width - 1) * input.wallThickness,
135-
compartmentLengthUnit * compartment.length + (compartment.length - 1) * input.wallThickness,
136-
min(binBodyTotalHeight - const.BIN_COMPARTMENT_BOTTOM_THICKNESS, compartment.depth),
150+
compartmentOriginPoint,
151+
compartmentWidth,
152+
compartmentLength,
153+
compartmentDepth,
137154
input.hasScoop,
138155
input.scoopMaxRadius,
139156
input.hasTab,
140-
max(0, min(input.tabLength, input.binWidth)) * input.baseWidth,
141-
input.tabWidth,
142-
max(0, min(input.tabPosition, input.binWidth - input.tabLength)) * input.baseWidth,
143-
input.tabOverhangAngle,
157+
compartmentTabInput,
144158
targetComponent,
145159
)
146160
bodiesToSubtract = bodiesToSubtract + compartmentCuts
147161
bodiesToMerge = bodiesToMerge + compartmentMerges
148162

163+
if len(input.compartments) > 1:
164+
compartmentsTopClearance = createCompartmentCutout(
165+
input.wallThickness,
166+
adsk.core.Point3D.create(
167+
compartmentsMinX,
168+
compartmentsMinY,
169+
binBodyTotalHeight
170+
),
171+
actualBodyWidth - input.wallThickness * 2,
172+
actualBodyLength - input.wallThickness * 2,
173+
const.BIN_TAB_TOP_CLEARANCE,
174+
False,
175+
0,
176+
False,
177+
targetComponent,
178+
)
179+
bodiesToSubtract.append(compartmentsTopClearance)
180+
149181
if len(bodiesToSubtract) > 0:
150182
combineUtils.cutBody(
151183
binBody,
@@ -162,24 +194,18 @@ def createGridfinityBinBody(
162194
return binBody
163195

164196

165-
def createCompartment(
197+
def createCompartmentCutout(
166198
wallThickness: float,
167199
originPoint: adsk.core.Point3D,
168200
width: float,
169201
length: float,
170202
depth: float,
171203
hasScoop: bool,
172204
scoopMaxRadius: float,
173-
hasTab: bool,
174-
tabLength: float,
175-
tabWidth: float,
176-
tabPosition: float,
177-
tabOverhangAngle: float,
205+
hasBottomFillet: bool,
178206
targetComponent: adsk.fusion.Component,
179-
) -> tuple[list[adsk.fusion.BRepBody], list[adsk.fusion.BRepBody]]:
207+
) -> adsk.fusion.BRepBody:
180208

181-
bodiesToMerge: list[adsk.fusion.BRepBody] = []
182-
bodiesToSubtract: list[adsk.fusion.BRepBody] = []
183209
innerCutoutFilletRadius = max(const.BIN_BODY_CUTOUT_BOTTOM_FILLET_RADIUS, const.BIN_CORNER_FILLET_RADIUS - wallThickness)
184210
innerCutoutInput = BinBodyCutoutGeneratorInput()
185211
innerCutoutInput.origin = originPoint
@@ -188,28 +214,42 @@ def createCompartment(
188214
innerCutoutInput.height = depth
189215
innerCutoutInput.hasScoop = hasScoop
190216
innerCutoutInput.scoopMaxRadius = scoopMaxRadius
191-
innerCutoutInput.hasTab = hasTab
192-
innerCutoutInput.tabLength = tabLength
193-
innerCutoutInput.tabWidth = tabWidth
194-
innerCutoutInput.tabPosition = tabPosition
195-
innerCutoutInput.tabOverhangAngle = tabOverhangAngle
196217
innerCutoutInput.filletRadius = innerCutoutFilletRadius
218+
innerCutoutInput.hasBottomFillet = hasBottomFillet
197219

198-
innerCutoutBody = createGridfinityBinBodyCutout(innerCutoutInput, targetComponent)
220+
return createGridfinityBinBodyCutout(innerCutoutInput, targetComponent)
221+
222+
def createCompartment(
223+
wallThickness: float,
224+
originPoint: adsk.core.Point3D,
225+
width: float,
226+
length: float,
227+
depth: float,
228+
hasScoop: bool,
229+
scoopMaxRadius: float,
230+
hasTab: bool,
231+
tabInput: BinBodyTabGeneratorInput,
232+
targetComponent: adsk.fusion.Component,
233+
) -> tuple[list[adsk.fusion.BRepBody], list[adsk.fusion.BRepBody]]:
234+
235+
bodiesToMerge: list[adsk.fusion.BRepBody] = []
236+
bodiesToSubtract: list[adsk.fusion.BRepBody] = []
237+
238+
innerCutoutBody = createCompartmentCutout(
239+
wallThickness,
240+
originPoint,
241+
width,
242+
length,
243+
depth,
244+
hasScoop,
245+
scoopMaxRadius,
246+
True,
247+
targetComponent,
248+
)
199249
bodiesToSubtract.append(innerCutoutBody)
200250

201251
# label tab
202252
if hasTab:
203-
tabInput = BinBodyTabGeneratorInput()
204-
tabOriginPoint = adsk.core.Point3D.create(
205-
originPoint.x + tabPosition,
206-
originPoint.y + length,
207-
innerCutoutInput.origin.z,
208-
)
209-
tabInput.origin = tabOriginPoint
210-
tabInput.length = tabLength
211-
tabInput.width = tabWidth
212-
tabInput.overhangAngle = tabOverhangAngle
213253
tabBody = createGridfinityBinBodyTab(tabInput,targetComponent)
214254

215255
intersectTabInput = targetComponent.features.combineFeatures.createInput(

lib/gridfinityUtils/binBodyLipGenerator.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55
from .const import BIN_CORNER_FILLET_RADIUS
66
from ...lib import fusion360utils as futil
77
from . import const, combineUtils, faceUtils, commonUtils, sketchUtils, extrudeUtils, baseGenerator, edgeUtils, filletUtils, geometryUtils
8-
from .binBodyCutoutGenerator import createGridfinityBinBodyCutout
9-
from .binBodyCutoutGeneratorInput import BinBodyCutoutGeneratorInput
108
from .baseGeneratorInput import BaseGeneratorInput
119
from .binBodyLipGeneratorInput import BinBodyLipGeneratorInput
12-
from .binBodyTabGeneratorInput import BinBodyTabGeneratorInput
13-
from .binBodyTabGenerator import createGridfinityBinBodyTab
14-
from ... import config
1510

1611
app = adsk.core.Application.get()
1712
ui = app.userInterface

lib/gridfinityUtils/binBodyTabGenerator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def createGridfinityBinBodyTab(
3838
tabSketch: adsk.fusion.Sketch = targetComponent.sketches.add(tabProfilePlane)
3939
tabSketch.name = "tab sketch"
4040
tabSketchLine = tabSketch.sketchCurves.sketchLines
41-
tabTopEdgeHeight = input.origin.z
41+
tabTopEdgeHeight = input.origin.z - input.topClearance
4242
actualTabWidth = input.width + BIN_TAB_EDGE_FILLET_RADIUS / math.tan((math.radians(90) - input.overhangAngle) / 2)
4343
actualTabHeight = actualTabWidth / math.tan(input.overhangAngle)
4444
line1 = tabSketchLine.addByTwoPoints(

lib/gridfinityUtils/binBodyTabGeneratorInput.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ def __init__(self):
77
self.overhangAngle = const.BIN_TAB_OVERHANG_ANGLE
88
self.position = 0
99

10+
@property
11+
def topClearance(self) -> float:
12+
return self._topClearance
13+
14+
@topClearance.setter
15+
def topClearance(self, value: float):
16+
self._topClearance = value
17+
1018
@property
1119
def width(self) -> float:
1220
return self._baseWidth

lib/gridfinityUtils/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
BIN_TAB_WIDTH = 1.3
2121
BIN_TAB_OVERHANG_ANGLE = 45
2222
BIN_TAB_EDGE_FILLET_RADIUS = 0.06
23+
BIN_TAB_TOP_CLEARANCE = 0.025
2324

2425
BIN_SCOOP_MAX_RADIUS = 2.5
2526

0 commit comments

Comments
 (0)