Skip to content

Commit 017dd53

Browse files
committed
feat: rotate printability grooves to 45 degree angle so that circular pattern could be used to replicate the holes throughout the base tile
1 parent 451dc9d commit 017dd53

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

lib/gridfinityUtils/baseGenerator.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import adsk.core, adsk.fusion, traceback
1+
import adsk.core, adsk.fusion, traceback, math
22
import os
33

4-
from .sketchUtils import createRectangle, filterCirclesByRadius
4+
from .sketchUtils import createRectangle
55
from ...lib.gridfinityUtils.baseGeneratorInput import BaseGeneratorInput
6-
from . import sketchUtils, const, edgeUtils, commonUtils, combineUtils, faceUtils, extrudeUtils, shapeUtils
6+
from . import sketchUtils, const, edgeUtils, commonUtils, combineUtils, faceUtils, extrudeUtils, shapeUtils, geometryUtils
77
from ...lib import fusion360utils as futil
88
from ... import config
99

@@ -45,6 +45,7 @@ def createCircleAtPointSketch(
4545
True
4646
)
4747

48+
return (circleSketch, circle)
4849
return circleSketch
4950

5051
def createSingleGridfinityBaseBody(
@@ -118,7 +119,7 @@ def createSingleGridfinityBaseBody(
118119
chamferFeatures.add(chamferInput)
119120

120121
# screw holes
121-
rectangularPatternFeatures: adsk.fusion.RectangularPatternFeatures = features.rectangularPatternFeatures
122+
circularPatternFeatures = features.circularPatternFeatures
122123
cutoutBodies = adsk.core.ObjectCollection.create()
123124

124125
baseBottomPlane = baseBottomExtrude.endFaces.item(0)
@@ -127,13 +128,14 @@ def createSingleGridfinityBaseBody(
127128
const.DIMENSION_SCREW_HOLES_OFFSET - input.xyClearance,
128129
baseBottomPlane.boundingBox.minPoint.z
129130
)
131+
cutoutCenterPoint = adsk.core.Point3D.create(baseHoleCenterPoint.x, baseHoleCenterPoint.y, 0)
130132
if input.hasScrewHoles:
131133
screwHoleBody = shapeUtils.simpleCylinder(
132134
baseBottomPlane,
133135
0,
134136
-const.BIN_BASE_HEIGHT,
135137
input.screwHolesDiameter / 2,
136-
adsk.core.Point3D.create(baseHoleCenterPoint.x, baseHoleCenterPoint.y, 0),
138+
cutoutCenterPoint,
137139
targetComponent,
138140
)
139141
cutoutBodies.add(screwHoleBody)
@@ -145,7 +147,7 @@ def createSingleGridfinityBaseBody(
145147
0,
146148
-input.magnetCutoutsDepth,
147149
input.magnetCutoutsDiameter / 2,
148-
adsk.core.Point3D.create(baseHoleCenterPoint.x, baseHoleCenterPoint.y, 0),
150+
cutoutCenterPoint,
149151
targetComponent,
150152
)
151153
cutoutBodies.add(magnetSocketBody)
@@ -156,9 +158,10 @@ def createSingleGridfinityBaseBody(
156158
-input.magnetCutoutsDepth,
157159
-const.BIN_MAGNET_HOLE_GROOVE_DEPTH,
158160
input.magnetCutoutsDiameter / 2,
159-
adsk.core.Point3D.create(baseHoleCenterPoint.x, baseHoleCenterPoint.y, 0),
161+
cutoutCenterPoint,
160162
targetComponent,
161163
)
164+
grooveBody.name = "Groove body"
162165
grooveLayer1 = shapeUtils.simpleBox(
163166
baseBottomPlane,
164167
-input.magnetCutoutsDepth,
@@ -168,6 +171,7 @@ def createSingleGridfinityBaseBody(
168171
adsk.core.Point3D.create(baseHoleCenterPoint.x + input.magnetCutoutsDiameter / 2, baseHoleCenterPoint.y - input.screwHolesDiameter / 2, 0),
169172
targetComponent,
170173
)
174+
grooveLayer1.name = "Groove layer 1 body"
171175
grooveLayer2 = shapeUtils.simpleBox(
172176
baseBottomPlane,
173177
-(input.magnetCutoutsDepth + const.BIN_MAGNET_HOLE_GROOVE_DEPTH / 2),
@@ -177,8 +181,17 @@ def createSingleGridfinityBaseBody(
177181
adsk.core.Point3D.create(baseHoleCenterPoint.x + input.screwHolesDiameter / 2, baseHoleCenterPoint.y - input.screwHolesDiameter / 2, 0),
178182
targetComponent,
179183
)
184+
grooveLayer2.name = "Groove layer 2 body"
180185
combineUtils.intersectBody(grooveBody, commonUtils.objectCollectionFromList([grooveLayer1, grooveLayer2]), targetComponent)
181186

187+
rotateGrooveBodyInput = targetComponent.features.moveFeatures.createInput2(commonUtils.objectCollectionFromList([grooveBody]))
188+
verticalAxisVector = adsk.core.Vector3D.create(0, 0, 1.0)
189+
transformRotate = adsk.core.Matrix3D.create()
190+
transformRotate.setToRotation(math.radians(-45), verticalAxisVector, cutoutCenterPoint)
191+
rotateGrooveBodyInput.defineAsFreeMove(transformRotate)
192+
ratateGrooveBodyFeature = targetComponent.features.moveFeatures.add(rotateGrooveBodyInput)
193+
ratateGrooveBodyFeature.name = "Rotate groove by 45 degree"
194+
182195
cutoutBodies.add(grooveBody)
183196

184197

lib/gridfinityUtils/baseplateGenerator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def createGridfinityBaseplate(input: BaseplateGeneratorInput, targetComponent: a
3333
connectionHoleXTool = None
3434

3535
if input.hasSkeletonizedBottom:
36-
centerCutoutSketch = baseGenerator.createCircleAtPointSketch(
36+
centerCutoutSketch,centerCutoutSketchCircle = baseGenerator.createCircleAtPointSketch(
3737
faceUtils.getBottomFace(baseBody),
3838
input.magnetCutoutsDiameter / 2,
3939
holeCenterPoint,

lib/gridfinityUtils/geometryUtils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ def createOffsetPoint(originalPoint: adsk.core.Point3D, byX = 0, byY = 0, byZ =
2828
originalPoint.y + byY,
2929
originalPoint.z + byZ,
3030
)
31+
32+
def pointToXY(point: adsk.core.Point3D):
33+
return adsk.core.Point3D.create(point.x, point.y, 0)

0 commit comments

Comments
 (0)