Skip to content

Commit

Permalink
feat: simple implementation of label tab for shelled bins
Browse files Browse the repository at this point in the history
  • Loading branch information
Le0Michine committed Nov 4, 2023
1 parent 92cb46d commit e45dd67
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
28 changes: 28 additions & 0 deletions commands/commandCreateBin/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
from ...lib import configUtils
from ...lib import fusion360utils as futil
from ... import config
from ...lib.gridfinityUtils import combineUtils
from ...lib.gridfinityUtils import geometryUtils
from ...lib.gridfinityUtils import faceUtils
from ...lib.gridfinityUtils import shellUtils
from ...lib.gridfinityUtils import commonUtils
from ...lib.gridfinityUtils import const
from ...lib.gridfinityUtils.baseGenerator import createGridfinityBase
from ...lib.gridfinityUtils.baseGeneratorInput import BaseGeneratorInput
from ...lib.gridfinityUtils.binBodyGenerator import createGridfinityBinBody, uniformCompartments
from ...lib.gridfinityUtils.binBodyGeneratorInput import BinBodyGeneratorInput, BinBodyCompartmentDefinition
from ...lib.gridfinityUtils.binBodyTabGeneratorInput import BinBodyTabGeneratorInput
from ...lib.gridfinityUtils.binBodyTabGenerator import createGridfinityBinBodyTab
from .inputState import InputState, CompartmentTableRow
from .staticInputCache import StaticInputCache

Expand Down Expand Up @@ -966,6 +970,30 @@ def generateBin(args: adsk.core.CommandEventArgs):
binBody = gridfinityBinComponent.bRepBodies.item(0)
else:
shellUtils.simpleShell([topFace], binBodyInput.wallThickness, gridfinityBinComponent)

if hasTabInput.value:
compartmentTabInput = BinBodyTabGeneratorInput()
tabOriginPoint = adsk.core.Point3D.create(
binBodyInput.wallThickness + max(0, min(binBodyInput.tabPosition, binBodyInput.binWidth - binBodyInput.tabLength)) * binBodyInput.baseWidth,
const.BIN_LIP_WALL_THICKNESS if binBodyInput.hasLip and binBodyInput.hasScoop else binBodyInput.wallThickness + binBodyInput.binLength * binBodyInput.baseLength - binBodyInput.wallThickness - binBodyInput.xyTolerance * 2,
(binBodyInput.binHeight - 1) * binBodyInput.heightUnit + max(0, binBodyInput.heightUnit - const.BIN_BASE_HEIGHT),
)
compartmentTabInput.origin = tabOriginPoint
compartmentTabInput.length = max(0, min(binBodyInput.tabLength, binBodyInput.binWidth)) * binBodyInput.baseWidth - binBodyInput.wallThickness * 2 - binBodyInput.xyTolerance * 2
compartmentTabInput.width = binBodyInput.tabWidth
compartmentTabInput.overhangAngle = binBodyInput.tabOverhangAngle
compartmentTabInput.topClearance = const.BIN_TAB_TOP_CLEARANCE
tabBody = createGridfinityBinBodyTab(compartmentTabInput, gridfinityBinComponent)
combineInput = combineFeatures.createInput(tabBody, commonUtils.objectCollectionFromList([binBody]))
combineInput.operation = adsk.fusion.FeatureOperations.CutFeatureOperation
combineInput.isKeepToolBodies = True
combineFeature = combineFeatures.add(combineInput)
tabBodies = [body for body in combineFeature.bodies if body.faces != binBody.faces]
tabMainBody = max([body for body in tabBodies], key=lambda x: x.edges.count)
bodiesToRemove = [body for body in tabBodies if body is not tabMainBody]
for body in bodiesToRemove:
gridfinityBinComponent.features.removeFeatures.add(body)
combineUtils.joinBodies(binBody, commonUtils.objectCollectionFromList([tabMainBody]), gridfinityBinComponent)

# group features in timeline
binGroup = des.timeline.timelineGroups.add(newCmpOcc.timelineObject.index, newCmpOcc.timelineObject.index + gridfinityBinComponent.features.count + gridfinityBinComponent.constructionPlanes.count + gridfinityBinComponent.sketches.count)
Expand Down
2 changes: 1 addition & 1 deletion lib/gridfinityUtils/binBodyGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def createCompartment(

# label tab
if hasTab:
tabBody = createGridfinityBinBodyTab(tabInput,targetComponent)
tabBody = createGridfinityBinBodyTab(tabInput, targetComponent)

intersectTabInput = targetComponent.features.combineFeatures.createInput(
tabBody,
Expand Down
5 changes: 3 additions & 2 deletions lib/gridfinityUtils/binBodyTabGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def createGridfinityBinBodyTab(
)
tabProfilePlane = targetComponent.constructionPlanes.add(tabProfilePlaneInput)
tabSketch: adsk.fusion.Sketch = targetComponent.sketches.add(tabProfilePlane)
tabSketch.name = "tab sketch"
tabSketch.name = "label tab sketch"
tabSketchLine = tabSketch.sketchCurves.sketchLines
tabTopEdgeHeight = input.origin.z - input.topClearance
actualTabWidth = input.width + BIN_TAB_EDGE_FILLET_RADIUS / math.tan((math.radians(90) - input.overhangAngle) / 2)
Expand Down Expand Up @@ -108,11 +108,12 @@ def createGridfinityBinBodyTab(

tabTopFace = faceUtils.getTopFace(tabBody)
roundedEdge = min([edge for edge in tabTopFace.edges if geometryUtils.isCollinearToX(edge)], key=lambda x: x.boundingBox.minPoint.y)
filletUtils.createFillet(
fillet = filletUtils.createFillet(
[roundedEdge],
BIN_TAB_EDGE_FILLET_RADIUS,
False,
targetComponent
)
fillet.name = 'label tab fillet'

return tabBody
9 changes: 9 additions & 0 deletions lib/gridfinityUtils/binBodyTabGeneratorInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class BinBodyTabGeneratorInput():
def __init__(self):
self.overhangAngle = const.BIN_TAB_OVERHANG_ANGLE
self.labelAngle = const.BIN_TAB_LABEL_ANGLE
self.position = 0

@property
Expand Down Expand Up @@ -47,4 +48,12 @@ def overhangAngle(self) -> float:
def overhangAngle(self, value: float):
self._tabOverhangAngle = value

@property
def labelAngle(self) -> float:
return self._tablabelAngle

@labelAngle.setter
def labelAngle(self, value: float):
self._tablabelAngle = value


1 change: 1 addition & 0 deletions lib/gridfinityUtils/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

BIN_TAB_WIDTH = 1.3
BIN_TAB_OVERHANG_ANGLE = 45
BIN_TAB_LABEL_ANGLE = 0
BIN_TAB_EDGE_FILLET_RADIUS = 0.06
BIN_TAB_TOP_CLEARANCE = 0.05

Expand Down

1 comment on commit e45dd67

@Le0Michine
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial implementation for #15

Please sign in to comment.