Skip to content

Instantly share code, notes, and snippets.

@christianvdstap
Created October 29, 2021 14:48
Show Gist options
  • Save christianvdstap/e1027851027ab13391331fdc8de1e454 to your computer and use it in GitHub Desktop.
Save christianvdstap/e1027851027ab13391331fdc8de1e454 to your computer and use it in GitHub Desktop.
module copy2(v) {
children();
translate(v) children();
}
function glue(v1,v2,offset=0,i=0,faces=[]) =
let(n=len(v1))
i < n-1
? glue(v1,v2,offset,i+1,concat(faces, [[i,i+1,i+n+1,i+n]+[offset,offset,offset,offset]]))
: concat(faces, [[n-1,0,n,(n-1)+n]+[offset,offset,offset,offset]]);
;
module l_prefab_bosh_beton_250(h) {
a1 = [0,1,0];
b1 = [140,1,0];
c1 = [140,1,13.6];
d1 = [20,1,17.8];
e1 = [17.1,1,17.8+25];
f1 = [10,1,250];
g1 = [0,1,250];
face1 = [a1,b1,c1,d1,e1,f1,g1];
a2 = [1,0,0];
b2 = [140-1,0,0];
c2 = [140-1,0,13.6-1];
d2 = [20-1,0,17.8-1];
e2 = [17.1-1,0,17.8+25];
f2 = [10-1,0,250-1];
g2 = [1,0,250-1];
face2 = [a2,b2,c2,d2,e2,f2,g2];
face3 = [for (i = [0:len(face1)-1]) face1[i]+[0,h-2,0]];
face4 = [for (i = [0:len(face2)-1]) face2[i]+[0,h,0]];
let(n=len(face1))
difference() {
polyhedron(concat(face2,face1,face3,face4),
concat(
[[for (i = [n-1:-1:0]) i]],
glue(face2,face1),
glue(face1,face3,n),
glue(face3,face4,n*2),
[[for (i = [n*3:n*4-1]) i]],
)
);
copy2([0,h,0])
translate([5-sqrt(2*2+2*2)/2,-sqrt(2*2+2*2)/2,17.8+25])
rotate([0,0,45])
cube([2,2,250]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment