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)
9 // $sealingbox_xbox (outer dimension)
10 // $sealingbox_ybox (outer dimension)
11 // $sealingbox_zbox (inner dimension)
13 // $sealingbox_floorth
19 // B. Complicated shapes, but harder work
20 // 1. Be a .m4 file and m4_include sealing-box.scad.m4
21 // 2. Define your own BoxDoShapeSomething like BoxDoShapeRect
22 // 3. Invoke BoxUseShape
23 // 4. Use the Box and Lid modules generated
28 $sealingbox_cnrrad = 10;
30 m4_define(`BoxLocals',`
31 xbox = $sealingbox_xbox;
32 ybox = $sealingbox_ybox;
33 zbox = $sealingbox_zbox;
34 wall = $sealingbox_wallth;
35 floorth = $sealingbox_floorth;
36 ceilth = $sealingbox_ceilth;
37 cnrrad = $sealingbox_cnrrad;
39 xbox_lin = xbox - cnrrad*2;
40 ybox_lin = ybox - cnrrad*2;
43 m4_dnl Box_Part($1=transl_x,$2=transl_y, $3=rot_z,$4=mirror_xy)
44 m4_dnl $5=kind, $6=kindargs, $7=profile(profileargsargs))
45 m4_define(`Box_Part',`
46 translate([($1),($2)])
49 BoxPart_Extrude_$5($6, $7)') m4_dnl
53 m4_dnl BoxPart_Extrude_Linear(dist, `profile(...);');
54 m4_define(`BoxPart_Extrude_Linear',`
56 translate([0,0, -($1)])
57 linear_extrude(height= boxpart_d + ($1)) {
62 m4_dnl BoxPart_Extrude_Arc(x0_radius, swept_angle, `profile(...);')
63 m4_dnl arc starting at transl_x, transl_y, moving towards positive
64 m4_dnl y at first and then bending towards negative x, until
65 m4_dnl use negative x0_radius to inciate bending towards positive x
66 m4_dnl swept_angle is reached
67 m4_dnl x0_radius is the radius of the extruded part at x=0, not of the box
68 m4_define(`BoxPart_Extrude_Arc',`
69 translate([-($1),0,0])
72 linear_extrude(height=1000)
76 rotate_extrude(convexity=10, $fs=1, $fn=36)
78 translate([+($1),0,0]){
84 m4_dnl BoxDoShapeRect(`profile(profileargs)');
85 m4_define(`BoxDoShapeRect',`
86 Box_Part(0, cnrrad, 0,0, Linear,`ybox_lin', `$1' )
87 Box_Part(0, ybox-cnrrad, 0,0, Arc,`-cnrrad,90' , `$1' )
88 Box_Part(cnrrad, ybox, -90,0, Linear,`xbox_lin', `$1' )
89 Box_Part(xbox-cnrrad, ybox, -90,0, Arc,`-cnrrad,90' , `$1' )
90 Box_Part(xbox, ybox-cnrrad, -180,0, Linear,`ybox_lin', `$1' )
91 Box_Part(xbox, cnrrad, -180,0, Arc,`-cnrrad,90' , `$1' )
92 Box_Part(xbox-cnrrad, 0, -270,0, Linear,`xbox_lin', `$1' )
93 Box_Part(cnrrad, 0, -270,0, Arc,`-cnrrad,90' , `$1' )
98 module SealingBox_WallProfile(){
100 z = zbox - innertube - tubesealrad;
101 translate([0, -0.1]) square([wall, z]);
102 translate([tubesealrad, z]) circle(r=tubesealrad, $fn=20);
105 module SealingBox_FloorProfile(){
107 mirror([0,1]) square([wall, floorth]);
110 module SealingBox_LidProfile(){
112 rad = tubesealrad + innertube;
115 translate([-lidoverlap - innertube,
116 zbox - lidoverhang - innertube])
117 square([lidoverlap + innertube + wall,
118 lidoverhang + innertube + ceilth]);
120 translate([tubesealrad,
121 zbox - innertube - tubesealrad])
127 circle(r= tubesealrad + innertube, $fn=20);
133 module SealingBox_CeilProfile(){
136 square([wall*2, ceilth]);
139 // BoxDoShape(Basename,BoxDoShapeSomething)
140 // generates modules BasenameBox and BasenameLid
141 m4_define(`BoxUseShape',`
144 $2(SealingBox_WallProfile(););
145 hull(){ $2(SealingBox_FloorProfile();); }
150 $2(SealingBox_LidProfile(););
151 hull(){ $2(SealingBox_CeilProfile();); }
155 BoxUseShape(`TestSealBox',`BoxDoShapeRect')