@@ -46,6 +46,67 @@ def createCircleAtPointSketch(
4646 )
4747
4848 return (circleSketch , circle )
49+
50+ def createTabAtCircleEdgeSketch (
51+ plane : adsk .core .Base ,
52+ radius : float ,
53+ circleCenterPoint : adsk .core .Point3D ,
54+ targetComponent : adsk .fusion .Component ,
55+ ):
56+ circleSketch , circle = createCircleAtPointSketch (
57+ plane ,
58+ radius ,
59+ circleCenterPoint ,
60+ targetComponent ,
61+ )
62+ circleCenterOnSketch = geometryUtils .pointToXY (circleSketch .modelToSketchSpace (circleCenterPoint ))
63+ angularPointOnSketch = geometryUtils .pointToXY (circleSketch .modelToSketchSpace (
64+ adsk .core .Point3D .create (circleCenterPoint .x + radius , circleCenterPoint .y + radius , circleCenterPoint .z )
65+ ))
66+ dimensions : adsk .fusion .SketchDimensions = circleSketch .sketchDimensions
67+ constraints : adsk .fusion .GeometricConstraints = circleSketch .geometricConstraints
68+ sketchUtils .convertToConstruction (circleSketch .sketchCurves )
69+ verticalConstructionLine = circleSketch .sketchCurves .sketchLines .addByTwoPoints (
70+ circleCenterOnSketch ,
71+ adsk .core .Point3D .create (circleCenterOnSketch .x , circleCenterOnSketch .y + radius , circleCenterOnSketch .z )
72+ )
73+ verticalConstructionLine .isConstruction = True
74+ diagonalConstructionLine = circleSketch .sketchCurves .sketchLines .addByTwoPoints (
75+ circleCenterOnSketch ,
76+ angularPointOnSketch ,
77+ )
78+ diagonalConstructionLine .isConstruction = True
79+ constraints .addVertical (verticalConstructionLine )
80+ dimensions .addAngularDimension (
81+ diagonalConstructionLine ,
82+ verticalConstructionLine ,
83+ angularPointOnSketch ,
84+ )
85+ constraints .addCoincident (
86+ verticalConstructionLine .startSketchPoint ,
87+ circle .centerSketchPoint ,
88+ )
89+ constraints .addCoincident (
90+ verticalConstructionLine .endSketchPoint ,
91+ circle ,
92+ )
93+ constraints .addCoincident (
94+ diagonalConstructionLine .startSketchPoint ,
95+ circle .centerSketchPoint ,
96+ )
97+ constraints .addCoincident (
98+ diagonalConstructionLine .endSketchPoint ,
99+ circle ,
100+ )
101+ circle = circleSketch .sketchCurves .sketchCircles .addByCenterRadius (
102+ diagonalConstructionLine .endSketchPoint ,
103+ radius / 2 ,
104+ )
105+ dimensions .addRadialDimension (
106+ circle ,
107+ circleCenterOnSketch ,
108+ )
109+
49110 return circleSketch
50111
51112def createSingleGridfinityBaseBody (
@@ -151,6 +212,26 @@ def createSingleGridfinityBaseBody(
151212 targetComponent ,
152213 )
153214 cutoutBodies .add (magnetSocketBody )
215+
216+ # magnet tab cutouts
217+ if input .hasMagnetCutoutsTabs :
218+ magnetTabCutoutSketch = createTabAtCircleEdgeSketch (
219+ baseBottomPlane ,
220+ input .magnetCutoutsDiameter / 2 ,
221+ cutoutCenterPoint ,
222+ targetComponent ,
223+ )
224+ magnetTabCutoutSketch .name = "Cutout tab sketch"
225+
226+ magnetTabCutoutExtrude = extrudeUtils .simpleDistanceExtrude (
227+ magnetTabCutoutSketch .profiles .item (0 ),
228+ adsk .fusion .FeatureOperations .NewBodyFeatureOperation ,
229+ input .magnetCutoutsDepth ,
230+ adsk .fusion .ExtentDirections .NegativeExtentDirection ,
231+ [],
232+ targetComponent ,
233+ )
234+ cutoutBodies .add (magnetTabCutoutExtrude .bodies .item (0 ))
154235
155236 if input .hasScrewHoles and (const .BIN_BASE_HEIGHT - input .magnetCutoutsDepth ) > const .BIN_MAGNET_HOLE_GROOVE_DEPTH :
156237 grooveBody = shapeUtils .simpleCylinder (
@@ -199,17 +280,31 @@ def createSingleGridfinityBaseBody(
199280 if cutoutBodies .count > 1 :
200281 joinFeature = combineUtils .joinBodies (cutoutBodies .item (0 ), commonUtils .objectCollectionFromList (list (cutoutBodies )[1 :]), targetComponent )
201282 cutoutBodies = commonUtils .objectCollectionFromList (joinFeature .bodies )
202- patternSpacingX = input .baseWidth - const .DIMENSION_SCREW_HOLES_OFFSET * 2
203- patternSpacingY = input .baseLength - const .DIMENSION_SCREW_HOLES_OFFSET * 2
204- patternInput = rectangularPatternFeatures .createInput (cutoutBodies ,
205- targetComponent .xConstructionAxis ,
206- adsk .core .ValueInput .createByReal (2 ),
207- adsk .core .ValueInput .createByReal (patternSpacingX ),
208- adsk .fusion .PatternDistanceType .SpacingPatternDistanceType )
209- patternInput .directionTwoEntity = targetComponent .yConstructionAxis
210- patternInput .quantityTwo = adsk .core .ValueInput .createByReal (2 )
211- patternInput .distanceTwo = adsk .core .ValueInput .createByReal (patternSpacingY )
212- patternFeature = rectangularPatternFeatures .add (patternInput )
283+
284+ baseXZMidPlaneInput = targetComponent .constructionPlanes .createInput ()
285+ baseXZMidPlaneInput .setByOffset (targetComponent .xZConstructionPlane , adsk .core .ValueInput .createByReal (input .baseLength / 2 - input .xyClearance ))
286+ baseXZMidPlane = targetComponent .constructionPlanes .add (baseXZMidPlaneInput )
287+ baseXZMidPlane .name = "Base XZ mid plane"
288+ baseXZMidPlane .isLightBulbOn = False
289+ baseYZMidPlaneInput = targetComponent .constructionPlanes .createInput ()
290+ baseYZMidPlaneInput .setByOffset (targetComponent .yZConstructionPlane , adsk .core .ValueInput .createByReal (input .baseWidth / 2 - input .xyClearance ))
291+ baseYZMidPlane = targetComponent .constructionPlanes .add (baseYZMidPlaneInput )
292+ baseYZMidPlane .name = "Base YZ mid plane"
293+ baseYZMidPlane .isLightBulbOn = False
294+ patternAxisInput = targetComponent .constructionAxes .createInput ()
295+ patternAxisInput .setByTwoPlanes (
296+ baseXZMidPlane ,
297+ baseYZMidPlane
298+ )
299+ baseCenterAxis = targetComponent .constructionAxes .add (patternAxisInput )
300+ baseCenterAxis .name = "Base center axis"
301+ baseCenterAxis .isLightBulbOn = False
302+ patternInput = circularPatternFeatures .createInput (
303+ cutoutBodies ,
304+ baseCenterAxis ,
305+ )
306+ patternInput .quantity = adsk .core .ValueInput .createByString ("4" )
307+ patternFeature = circularPatternFeatures .add (patternInput )
213308 combineUtils .cutBody (baseBody , commonUtils .objectCollectionFromList (list (cutoutBodies ) + list (patternFeature .bodies )), targetComponent )
214309
215310 return baseBody
0 commit comments