Skip to content

Commit e45dd67

Browse files
committed
feat: simple implementation of label tab for shelled bins
1 parent 92cb46d commit e45dd67

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

commands/commandCreateBin/entry.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77
from ...lib import configUtils
88
from ...lib import fusion360utils as futil
99
from ... import config
10+
from ...lib.gridfinityUtils import combineUtils
1011
from ...lib.gridfinityUtils import geometryUtils
1112
from ...lib.gridfinityUtils import faceUtils
1213
from ...lib.gridfinityUtils import shellUtils
14+
from ...lib.gridfinityUtils import commonUtils
1315
from ...lib.gridfinityUtils import const
1416
from ...lib.gridfinityUtils.baseGenerator import createGridfinityBase
1517
from ...lib.gridfinityUtils.baseGeneratorInput import BaseGeneratorInput
1618
from ...lib.gridfinityUtils.binBodyGenerator import createGridfinityBinBody, uniformCompartments
1719
from ...lib.gridfinityUtils.binBodyGeneratorInput import BinBodyGeneratorInput, BinBodyCompartmentDefinition
20+
from ...lib.gridfinityUtils.binBodyTabGeneratorInput import BinBodyTabGeneratorInput
21+
from ...lib.gridfinityUtils.binBodyTabGenerator import createGridfinityBinBodyTab
1822
from .inputState import InputState, CompartmentTableRow
1923
from .staticInputCache import StaticInputCache
2024

@@ -966,6 +970,30 @@ def generateBin(args: adsk.core.CommandEventArgs):
966970
binBody = gridfinityBinComponent.bRepBodies.item(0)
967971
else:
968972
shellUtils.simpleShell([topFace], binBodyInput.wallThickness, gridfinityBinComponent)
973+
974+
if hasTabInput.value:
975+
compartmentTabInput = BinBodyTabGeneratorInput()
976+
tabOriginPoint = adsk.core.Point3D.create(
977+
binBodyInput.wallThickness + max(0, min(binBodyInput.tabPosition, binBodyInput.binWidth - binBodyInput.tabLength)) * binBodyInput.baseWidth,
978+
const.BIN_LIP_WALL_THICKNESS if binBodyInput.hasLip and binBodyInput.hasScoop else binBodyInput.wallThickness + binBodyInput.binLength * binBodyInput.baseLength - binBodyInput.wallThickness - binBodyInput.xyTolerance * 2,
979+
(binBodyInput.binHeight - 1) * binBodyInput.heightUnit + max(0, binBodyInput.heightUnit - const.BIN_BASE_HEIGHT),
980+
)
981+
compartmentTabInput.origin = tabOriginPoint
982+
compartmentTabInput.length = max(0, min(binBodyInput.tabLength, binBodyInput.binWidth)) * binBodyInput.baseWidth - binBodyInput.wallThickness * 2 - binBodyInput.xyTolerance * 2
983+
compartmentTabInput.width = binBodyInput.tabWidth
984+
compartmentTabInput.overhangAngle = binBodyInput.tabOverhangAngle
985+
compartmentTabInput.topClearance = const.BIN_TAB_TOP_CLEARANCE
986+
tabBody = createGridfinityBinBodyTab(compartmentTabInput, gridfinityBinComponent)
987+
combineInput = combineFeatures.createInput(tabBody, commonUtils.objectCollectionFromList([binBody]))
988+
combineInput.operation = adsk.fusion.FeatureOperations.CutFeatureOperation
989+
combineInput.isKeepToolBodies = True
990+
combineFeature = combineFeatures.add(combineInput)
991+
tabBodies = [body for body in combineFeature.bodies if body.faces != binBody.faces]
992+
tabMainBody = max([body for body in tabBodies], key=lambda x: x.edges.count)
993+
bodiesToRemove = [body for body in tabBodies if body is not tabMainBody]
994+
for body in bodiesToRemove:
995+
gridfinityBinComponent.features.removeFeatures.add(body)
996+
combineUtils.joinBodies(binBody, commonUtils.objectCollectionFromList([tabMainBody]), gridfinityBinComponent)
969997

970998
# group features in timeline
971999
binGroup = des.timeline.timelineGroups.add(newCmpOcc.timelineObject.index, newCmpOcc.timelineObject.index + gridfinityBinComponent.features.count + gridfinityBinComponent.constructionPlanes.count + gridfinityBinComponent.sketches.count)

lib/gridfinityUtils/binBodyGenerator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def createCompartment(
250250

251251
# label tab
252252
if hasTab:
253-
tabBody = createGridfinityBinBodyTab(tabInput,targetComponent)
253+
tabBody = createGridfinityBinBodyTab(tabInput, targetComponent)
254254

255255
intersectTabInput = targetComponent.features.combineFeatures.createInput(
256256
tabBody,

lib/gridfinityUtils/binBodyTabGenerator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def createGridfinityBinBodyTab(
3636
)
3737
tabProfilePlane = targetComponent.constructionPlanes.add(tabProfilePlaneInput)
3838
tabSketch: adsk.fusion.Sketch = targetComponent.sketches.add(tabProfilePlane)
39-
tabSketch.name = "tab sketch"
39+
tabSketch.name = "label tab sketch"
4040
tabSketchLine = tabSketch.sketchCurves.sketchLines
4141
tabTopEdgeHeight = input.origin.z - input.topClearance
4242
actualTabWidth = input.width + BIN_TAB_EDGE_FILLET_RADIUS / math.tan((math.radians(90) - input.overhangAngle) / 2)
@@ -108,11 +108,12 @@ def createGridfinityBinBodyTab(
108108

109109
tabTopFace = faceUtils.getTopFace(tabBody)
110110
roundedEdge = min([edge for edge in tabTopFace.edges if geometryUtils.isCollinearToX(edge)], key=lambda x: x.boundingBox.minPoint.y)
111-
filletUtils.createFillet(
111+
fillet = filletUtils.createFillet(
112112
[roundedEdge],
113113
BIN_TAB_EDGE_FILLET_RADIUS,
114114
False,
115115
targetComponent
116116
)
117+
fillet.name = 'label tab fillet'
117118

118119
return tabBody

lib/gridfinityUtils/binBodyTabGeneratorInput.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class BinBodyTabGeneratorInput():
66
def __init__(self):
77
self.overhangAngle = const.BIN_TAB_OVERHANG_ANGLE
8+
self.labelAngle = const.BIN_TAB_LABEL_ANGLE
89
self.position = 0
910

1011
@property
@@ -47,4 +48,12 @@ def overhangAngle(self) -> float:
4748
def overhangAngle(self, value: float):
4849
self._tabOverhangAngle = value
4950

51+
@property
52+
def labelAngle(self) -> float:
53+
return self._tablabelAngle
54+
55+
@labelAngle.setter
56+
def labelAngle(self, value: float):
57+
self._tablabelAngle = value
58+
5059

lib/gridfinityUtils/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
BIN_TAB_WIDTH = 1.3
2121
BIN_TAB_OVERHANG_ANGLE = 45
22+
BIN_TAB_LABEL_ANGLE = 0
2223
BIN_TAB_EDGE_FILLET_RADIUS = 0.06
2324
BIN_TAB_TOP_CLEARANCE = 0.05
2425

0 commit comments

Comments
 (0)