diff --git a/commands/commandCreateBin/entry.py b/commands/commandCreateBin/entry.py index b3aa6ce..3d3bd86 100644 --- a/commands/commandCreateBin/entry.py +++ b/commands/commandCreateBin/entry.py @@ -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 @@ -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) diff --git a/lib/gridfinityUtils/binBodyGenerator.py b/lib/gridfinityUtils/binBodyGenerator.py index deb69ef..afb6565 100644 --- a/lib/gridfinityUtils/binBodyGenerator.py +++ b/lib/gridfinityUtils/binBodyGenerator.py @@ -250,7 +250,7 @@ def createCompartment( # label tab if hasTab: - tabBody = createGridfinityBinBodyTab(tabInput,targetComponent) + tabBody = createGridfinityBinBodyTab(tabInput, targetComponent) intersectTabInput = targetComponent.features.combineFeatures.createInput( tabBody, diff --git a/lib/gridfinityUtils/binBodyTabGenerator.py b/lib/gridfinityUtils/binBodyTabGenerator.py index 98fb3d3..14a8b80 100644 --- a/lib/gridfinityUtils/binBodyTabGenerator.py +++ b/lib/gridfinityUtils/binBodyTabGenerator.py @@ -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) @@ -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 diff --git a/lib/gridfinityUtils/binBodyTabGeneratorInput.py b/lib/gridfinityUtils/binBodyTabGeneratorInput.py index 21f8100..d523108 100644 --- a/lib/gridfinityUtils/binBodyTabGeneratorInput.py +++ b/lib/gridfinityUtils/binBodyTabGeneratorInput.py @@ -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 @@ -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 + \ No newline at end of file diff --git a/lib/gridfinityUtils/const.py b/lib/gridfinityUtils/const.py index 3376291..a892197 100644 --- a/lib/gridfinityUtils/const.py +++ b/lib/gridfinityUtils/const.py @@ -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