Created
January 14, 2019 22:50
-
-
Save 3kmch/66f3046d258a293a91cb5cd5da0f884a to your computer and use it in GitHub Desktop.
Moulds for concrete casting
This file contains 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
function getParameterDefinitions() { | |
return [ | |
{name: 'side', caption: 'Width:', type: 'float', default: 50}, | |
{name: 'hgt', caption: 'Height:', type: 'float', default: 14}, | |
{name: 'dia', caption: 'Screw dia:', type: 'float', default: 3}, | |
{name: 'posX', caption: 'Screw Position X:', type: 'float', default: 8}, | |
{name: 'posY', caption: 'Screw Position Y:', type: 'float', default: 8} | |
]; | |
} | |
function main(params){ | |
var side = params.side/2; | |
var hgt = params.hgt; | |
var dia = params.dia/2; | |
var posX = params.posX; | |
var posY = params.posY; | |
var wall = 1; // Approx ;-) | |
var draft = 2; | |
var res = 24; | |
//Mainbody | |
var Cyl1 = CSG.cylinder({ | |
center: [0,0,0], | |
start: [0,0,0], | |
end: [0,0,hgt], | |
radiusStart: side*1.41, | |
radiusEnd: side*1.41-draft, | |
resolution: 4 | |
}); | |
//Cutout for mold | |
var Cyl2 = CSG.cylinder({ | |
center: [0,0,0], | |
start: [0,0,0], | |
end: [0,0,hgt-wall], | |
radiusStart: side*1.41-wall, | |
radiusEnd: side*1.41-draft-wall, | |
resolution: 4 | |
}); | |
//Cutout for Screw | |
var Cyl3 = CSG.cylinder({ | |
center: [0,0,0], | |
start: [0,0,0], | |
end: [0,0,hgt], | |
radius: dia, | |
resolution: 16 | |
}); | |
//Addon -> will get replaced with a extrudet polygon | |
var Cyl4 = CSG.cylinder({ | |
center: [0,0,0], | |
start: [0,0,0], | |
end: [0,0,wall+2], | |
radius: 18, | |
resolution: 5 | |
}); | |
var result = translate([0, 0, -hgt], rotate([0, 0, 45], Cyl1.subtract(Cyl2))); | |
Cyl3 = Cyl3.translate([side-posX, side-posY, -hgt/2]); | |
result = result.subtract(Cyl3); | |
result = rotate([0, 180, 0],result); | |
result = result.union(Cyl4); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment