svg2scad2cc/test/test.scad

136 lines
4.6 KiB
OpenSCAD

// OpenSCAD file automatically generated by svg2scad2cc.py
// parameters tunable by user
wallHeight = 10;
minWallThickness = 1.6;
maxWallThickness = 1.6;
minInsideWallThickness = 1.6;
maxInsideWallThickness = 1.6;
wallFlareWidth = 8;
wallFlareThickness = 2;
insideWallFlareWidth = 5;
insideWallFlareThickness = 1.6;
featureHeight = 1;
minFeatureThickness = 1;
maxFeatureThickness = 3;
connectorThickness = 1.6;
cuttingTaperHeight = 3;
cuttingEdgeThickness = 0.8;
// set to non-zero value to generate a demoulding plate
demouldingPlateHeight = 2;
demouldingPlateSlack = 0.5;
// sizing function
function clamp(t,minimum,maximum) = min(maximum,max(t,minimum));
function featureThickness(t) = clamp(t,minFeatureThickness,maxFeatureThickness);
function wallThickness(t) = clamp(t,minWallThickness,maxWallThickness);
function insideWallThickness(t) = clamp(t,minInsideWallThickness,maxInsideWallThickness);
size = 100.198;
scale = size/100.198;
// helper modules: subshapes
module ribbon(points, thickness=1) {
union() {
for (i=[1:len(points)-1]) {
hull() {
translate(points[i-1]) circle(d=thickness, $fn=8);
translate(points[i]) circle(d=thickness, $fn=8);
}
}
}
}
module wall(points,height,thickness) {
module profile() {
if (height>=cuttingTaperHeight && cuttingTaperHeight>0 && cuttingEdgeThickness<thickness) {
cylinder(h=height-cuttingTaperHeight+0.001,d=thickness,$fn=8);
translate([0,0,height-cuttingTaperHeight]) cylinder(h=cuttingTaperHeight,d1=thickness,d2=cuttingEdgeThickness);
} else {
cylinder(h=height,d=thickness,$fn=8);
}
}
for (i=[1:len(points)-1]) {
hull() {
translate(points[i-1]) profile();
translate(points[i]) profile();
}
}
}
module outerFlare(path) {
difference() {
render(convexity=10) linear_extrude(height=wallFlareThickness) ribbon(path,thickness=wallFlareWidth);
translate([0,0,-0.01]) linear_extrude(height=wallFlareThickness+0.02) polygon(points=path);
}
}
module innerFlare(path) {
intersection() {
render(convexity=10) linear_extrude(height=insideWallFlareThickness) ribbon(path,thickness=insideWallFlareWidth);
translate([0,0,-0.01]) linear_extrude(height=insideWallFlareThickness+0.02) polygon(points=path);
}
}
module fill(path,height) {
render(convexity=10) linear_extrude(height=height) polygon(points=path);
}
// data from svg file
outerWall_0 = scale * [[-0.397,100.396],[-0.397,0.397],[-100.396,0.397],[-100.396,78.534],[-81.412,78.534],[-81.412,100.396],[-0.397,100.396]];
feature_1 = scale * [[-74.069,67.833],[-88.752,67.833],[-88.752,17.555],[-74.069,17.555],[-74.069,67.833]];
feature_2 = scale * [[-12.522,85.476],[-31.750,85.476],[-31.750,15.995],[-12.522,15.995],[-12.522,85.476]];
innerWall_3 = scale * [[-41.656,80.465],[-41.656,19.228],[-64.933,49.709],[-41.656,80.465]];
connector_4 = scale * [[-45.418,100.595],[-59.237,100.595],[-59.237,0.482],[-45.418,0.482],[-45.418,100.595]];
// Main modules
module cookieCutter() {
wall(outerWall_0,wallHeight,wallThickness(0.794));
outerFlare(outerWall_0);
if (demouldingPlateHeight <= 0) {
wall(feature_1,featureHeight,featureThickness(0.794));
}
if (demouldingPlateHeight <= 0) {
wall(feature_2,featureHeight,featureThickness(0.794));
}
wall(innerWall_3,wallHeight,insideWallThickness(0.794));
innerFlare(innerWall_3);
fill(connector_4,connectorThickness);
}
module demouldingPlate(){
// A plate to help push on the cookie to turn it out.
// If features exists, they forms stamp with plate.
render(convexity=10) difference() {
linear_extrude(height=demouldingPlateHeight) union() {
polygon(points=outerWall_0);
}
translate([0,0,-0.01]) linear_extrude(height=demouldingPlateHeight+0.02) union() {
ribbon(outerWall_0,thickness=demouldingPlateSlack+wallThickness(0.794));
ribbon(innerWall_3,thickness=demouldingPlateSlack+insideWallThickness(0.794));
}
}
if (demouldingPlateHeight>0) {
translate([0,0,demouldingPlateHeight]) {
// features transferred onto the demoulding plate
wall(feature_1,featureHeight,featureThickness(0.794));
wall(feature_2,featureHeight,featureThickness(0.794));
}
}
}
////////////////////////////////////////////////////////////////////////////////
// final call, use main modules
translate([100.396*scale + wallFlareWidth/2, -0.397*scale + wallFlareWidth/2,0])
cookieCutter();
// translate([-40,15,0]) cylinder(h=wallHeight+10,d=5,$fn=20); // handle
if (demouldingPlateHeight>0)
translate([100.396*scale + wallFlareWidth/2 + 100.000*scale + wallFlareWidth + demouldingPlateSlack, -0.397*scale + wallFlareWidth/2,0])
demouldingPlate();