Skip to content

Commit fc82c6a

Browse files
committed
fix: calculate bottom interface holes position from the edge instead of center
this is addressing issue #21, when bottom holes can't be generated on smaller bins due to hardcoded pattern spacing
1 parent 7b8f79e commit fc82c6a

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

lib/gridfinityUtils/baseGenerator.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def createGridfinityBase(
6565
basePlateSketch: adsk.fusion.Sketch = sketches.add(baseConstructionPlane)
6666
rectangleOrigin = basePlateSketch.modelToSketchSpace(input.originPoint)
6767
createRectangle(actual_base_width, actual_base_length,rectangleOrigin, basePlateSketch)
68-
68+
6969
# extrude top section
7070
topSectionExtrudeDepth = adsk.core.ValueInput.createByReal(const.BIN_BASE_TOP_SECTION_HEIGH)
7171
topSectionExtrudeInput = extrudeFeatures.createInput(basePlateSketch.profiles.item(0),
@@ -122,8 +122,11 @@ def createGridfinityBase(
122122
cutoutBodies = adsk.core.ObjectCollection.create()
123123

124124
baseBottomPlane = baseBottomExtrude.endFaces.item(0)
125-
baseCenterPoint = adsk.core.Point3D.create(actual_base_width / 2, actual_base_length / 2, baseBottomPlane.boundingBox.minPoint.z)
126-
baseHoleCenterPoint = adsk.core.Point3D.create(baseCenterPoint.x - const.DIMENSION_SCREW_HOLES_DISTANCE / 2, baseCenterPoint.y - const.DIMENSION_SCREW_HOLES_DISTANCE / 2, baseCenterPoint.z)
125+
baseHoleCenterPoint = adsk.core.Point3D.create(
126+
const.DIMENSION_SCREW_HOLES_OFFSET - input.xyTolerance,
127+
const.DIMENSION_SCREW_HOLES_OFFSET - input.xyTolerance,
128+
baseBottomPlane.boundingBox.minPoint.z
129+
)
127130
if input.hasScrewHoles:
128131
screwHoleBody = shapeUtils.simpleCylinder(
129132
baseBottomPlane,
@@ -183,14 +186,16 @@ def createGridfinityBase(
183186
if cutoutBodies.count > 1:
184187
joinFeature = combineUtils.joinBodies(cutoutBodies.item(0), commonUtils.objectCollectionFromList(list(cutoutBodies)[1:]), targetComponent)
185188
cutoutBodies = commonUtils.objectCollectionFromList(joinFeature.bodies)
189+
patternSpacingX = input.baseWidth - const.DIMENSION_SCREW_HOLES_OFFSET * 2
190+
patternSpacingY = input.baseLength - const.DIMENSION_SCREW_HOLES_OFFSET * 2
186191
patternInput = rectangularPatternFeatures.createInput(cutoutBodies,
187192
targetComponent.xConstructionAxis,
188193
adsk.core.ValueInput.createByReal(2),
189-
adsk.core.ValueInput.createByReal(const.DIMENSION_SCREW_HOLES_DISTANCE),
194+
adsk.core.ValueInput.createByReal(patternSpacingX),
190195
adsk.fusion.PatternDistanceType.SpacingPatternDistanceType)
191196
patternInput.directionTwoEntity = targetComponent.yConstructionAxis
192197
patternInput.quantityTwo = adsk.core.ValueInput.createByReal(2)
193-
patternInput.distanceTwo = adsk.core.ValueInput.createByReal(const.DIMENSION_SCREW_HOLES_DISTANCE)
198+
patternInput.distanceTwo = adsk.core.ValueInput.createByReal(patternSpacingY)
194199
patternFeature = rectangularPatternFeatures.add(patternInput)
195200
combineUtils.cutBody(baseBody, commonUtils.objectCollectionFromList(list(cutoutBodies) + list(patternFeature.bodies)), targetComponent)
196201

lib/gridfinityUtils/baseplateGenerator.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ def createGridfinityBaseplate(input: BaseplateGeneratorInput, targetComponent: a
1818
cuttingTools: list[adsk.fusion.BRepBody] = [baseBody]
1919
extraCutoutBodies: list[adsk.fusion.BRepBody] = []
2020

21-
holeCenterPoint = adsk.core.Point3D.create(input.baseWidth / 2 - input.xyTolerance - const.DIMENSION_SCREW_HOLES_DISTANCE / 2, input.baseLength / 2 - input.xyTolerance - const.DIMENSION_SCREW_HOLES_DISTANCE / 2, 0)
21+
holeCenterPoint = adsk.core.Point3D.create(
22+
const.DIMENSION_SCREW_HOLES_OFFSET - input.xyTolerance,
23+
const.DIMENSION_SCREW_HOLES_OFFSET - input.xyTolerance,
24+
0
25+
)
2226

2327
if input.hasSkeletonizedBottom:
2428
centerCutoutSketch = baseGenerator.createCircleAtPointSketch(
@@ -182,10 +186,12 @@ def createGridfinityBaseplate(input: BaseplateGeneratorInput, targetComponent: a
182186
holeCuttingBodies.append(screwHeadBody)
183187

184188
if len(holeCuttingBodies) > 0:
189+
patternSpacingX = input.baseWidth - const.DIMENSION_SCREW_HOLES_OFFSET * 2
190+
patternSpacingY = input.baseLength - const.DIMENSION_SCREW_HOLES_OFFSET * 2
185191
magnetScrewCutoutsPattern = patternUtils.recPattern(
186192
commonUtils.objectCollectionFromList(holeCuttingBodies),
187193
(targetComponent.xConstructionAxis, targetComponent.yConstructionAxis),
188-
(const.DIMENSION_SCREW_HOLES_DISTANCE, const.DIMENSION_SCREW_HOLES_DISTANCE),
194+
(patternSpacingX, patternSpacingY),
189195
(2, 2),
190196
targetComponent
191197
)

lib/gridfinityUtils/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
DIMENSION_DEFAULT_WIDTH_UNIT = 4.2
3030
DIMENSION_DEFAULT_HEIGHT_UNIT = 0.7
31-
DIMENSION_SCREW_HOLES_DISTANCE = 2.6
31+
DIMENSION_SCREW_HOLES_OFFSET = 0.8
3232
DIMENSION_SCREW_HOLE_DIAMETER = 0.3
3333
DIMENSION_PLATE_CONNECTION_SCREW_HOLE_DIAMETER = 0.32
3434
DIMENSION_PLATE_SCREW_HOLE_DIAMETER = 0.32

0 commit comments

Comments
 (0)