3 // This file can be used in two ways:
5 // A. Rectangular boxes
6 // 1. include <sealing-box.scad>
7 // 2. assign() values to (xxx these should be $ variables)
8 // $sealingbox_wallthick
9 // ts_xbox (outer dimensions)
10 // ts_ybox (outer dimension)
12 // ts_cnrrad (outer radius of corners, leave at default normall)
13 // xxx default should be in this file
18 // B. Complicated shapes, but harder work
19 // 1. Be a .m4 file and m4_include sealing-box.scad.m4
20 // 2. Define your own BoxDoShapeSomething like BoxDoShapeRect
21 // 3. Invoke BoxUseShape
22 // 4. Use the Box and Lid modules generated
24 m4_define(`BoxLocals',`
25 wall = $sealingbox_wallthick;
27 ts_cidoff = (ts_cnrrad * (1-.7) + wall * .8) * [1,1];
29 ts_xbox_lin = ts_xbox - ts_cnrrad*2;
30 ts_ybox_lin = ts_ybox - ts_cnrrad*2;
33 m4_dnl Box_Part($1=transl_x,$2=transl_y, $3=rot_z,$4=mirror_xy)
34 m4_dnl $5=kind, $6=kindargs, $7=profile(profileargsargs))
35 m4_define(`Box_Part',`
36 translate([($1),($2)])
39 BoxPart_Extrude_$5($6, $7)') m4_dnl
43 m4_dnl BoxPart_Extrude_Linear(dist, `profile(...);');
44 m4_define(`BoxPart_Extrude_Linear',`
46 translate([0,0, -($1)])
47 linear_extrude(height= boxpart_d + ($1)) {
52 m4_dnl BoxPart_Extrude_Arc(x0_radius, swept_angle, `profile(...);')
53 m4_dnl arc starting at transl_x, transl_y, moving towards positive
54 m4_dnl y at first and then bending towards negative x, until
55 m4_dnl use negative x0_radius to inciate bending towards positive x
56 m4_dnl swept_angle is reached
57 m4_dnl x0_radius is the radius of the extruded part at x=0, not of the box
58 m4_define(`BoxPart_Extrude_Arc',`
59 translate([-($1),0,0])
62 linear_extrude(height=1000)
66 rotate_extrude(convexity=10, $fs=1, $fn=36)
68 translate([+($1),0,0]){
74 m4_dnl BoxDoShapeRect(`profile(profileargs)');
75 m4_define(`BoxDoShapeRect',`
76 Box_Part(0, ts_cnrrad, 0,0, Linear,`ts_ybox_lin', `$1' )
77 Box_Part(0, ts_ybox-ts_cnrrad, 0,0, Arc,`-ts_cnrrad,90' , `$1' )
78 Box_Part(ts_cnrrad, ts_ybox, -90,0, Linear,`ts_xbox_lin', `$1' )
79 Box_Part(ts_xbox-ts_cnrrad, ts_ybox, -90,0, Arc,`-ts_cnrrad,90' , `$1' )
80 Box_Part(ts_xbox, ts_ybox-ts_cnrrad, -180,0, Linear,`ts_ybox_lin', `$1' )
81 Box_Part(ts_xbox, ts_cnrrad, -180,0, Arc,`-ts_cnrrad,90' , `$1' )
82 Box_Part(ts_xbox-ts_cnrrad, 0, -270,0, Linear,`ts_xbox_lin', `$1' )
83 Box_Part(ts_cnrrad, 0, -270,0, Arc,`-ts_cnrrad,90' , `$1' )
88 module SealingBox_WallProfile(){
90 z = ts_zbox - innertube - tubesealrad;
91 translate([0, -0.1]) square([wall, z]);
92 translate([tubesealrad, z]) circle(r=tubesealrad, $fn=20);
95 module SealingBox_FloorProfile(){
97 mirror([0,1]) square([wall, floorth]);
100 module SealingBox_LidProfile(){
102 rad = tubesealrad + innertube;
105 translate([-lidoverlap - innertube,
106 ts_zbox - lidoverhang - innertube])
107 square([lidoverlap + innertube + wall,
108 lidoverhang + innertube + ceilth]);
110 translate([tubesealrad,
111 ts_zbox - innertube - tubesealrad])
117 circle(r= tubesealrad + innertube, $fn=20);
123 module SealingBox_CeilProfile(){
125 translate([0, ts_zbox])
126 square([wall*2, ceilth]);
129 // BoxDoShape(Basename,BoxDoShapeSomething)
130 // generates modules BasenameBox and BasenameLid
131 m4_define(`BoxUseShape',`
134 $2(SealingBox_WallProfile(););
135 hull(){ $2(SealingBox_FloorProfile();); }
140 $2(SealingBox_LidProfile(););
141 hull(){ $2(SealingBox_CeilProfile();); }
145 BoxUseShape(`TestSealBox',`BoxDoShapeRect')