Created
November 19, 2025 13:29
-
-
Save jonathanperret/6ddf8d0b655e36a2b300a32d609932d1 to your computer and use it in GitHub Desktop.
Arduino case for AYAB shield
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { booleans, primitives, transforms, extrusions, hulls, utils } = require('@jscad/modeling') | |
| const { cuboid, cylinder, circle } = primitives | |
| const { translate, rotateX } = transforms | |
| const { subtract, union } = booleans | |
| const { extrudeLinear } = extrusions | |
| const { hull } = hulls | |
| const { degToRad } = utils | |
| // Helper to mimic OpenSCAD cube (origin at corner instead of center) | |
| const scadCube = (size) => { | |
| return translate( | |
| [size[0] / 2, size[1] / 2, size[2] / 2], | |
| cuboid({ size: size }) | |
| ) | |
| } | |
| const main = () => { | |
| // --- Create the main Subtract/Difference block --- | |
| // 1. Main Cube | |
| const mainBlock = scadCube([56, 73, 19]) | |
| // 2. Inner Hollow Cube | |
| const hollow = translate([1, 1, 0.5], scadCube([54, 71, 50])) | |
| // 3. Hull/Slot Feature | |
| // Create the 2D profile | |
| const c1 = circle({ radius: 2.5 }) // d=5 | |
| const c2 = translate([11, 0], circle({ radius: 2.5 })) | |
| const profile = hull(c1, c2) | |
| // Extrude, Rotate, Place | |
| let slot = extrudeLinear({ height: 5 }, profile) | |
| slot = rotateX(degToRad(90), slot) | |
| slot = translate([36.5, 75, 6], slot) | |
| // 4. Side Cutout | |
| const sideCut = translate([-1, 62, 16], scadCube([34, 12, 4])) | |
| // 5. Bottom Hole | |
| // OpenSCAD 'center=true' is default behavior for JSCAD cylinder | |
| const bottomHole = translate( | |
| [20, 54, 0], | |
| cylinder({ height: 10, radius: 10, segments: 64 }) // d=20 -> r=10 | |
| ) | |
| // Execute Difference | |
| const caseBody = subtract(mainBlock, hollow, slot, sideCut, bottomHole) | |
| // --- Create the Tabs (For Loop) --- | |
| const tabs = [] | |
| const xVals = [0, 1] | |
| const yVals = [0, 1] | |
| xVals.forEach((x) => { | |
| yVals.forEach((y) => { | |
| tabs.push( | |
| translate( | |
| [x * 54, y * 36 + 16, 18], | |
| scadCube([2, 5, 1]) | |
| ) | |
| ) | |
| }) | |
| }) | |
| // --- Final Union --- | |
| return union(caseBody, ...tabs) | |
| } | |
| module.exports = { main } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment