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 // ts_xbox (outer dimensions)
9 // ts_ybox (outer dimension)
11 // ts_cnrrad (outer radius of corners, leave at default normall)
12 // xxx default should be in this file
17 // B. Complicated shapes, but harder work
18 // 1. Be a .m4 file and m4_include sealing-box.scad.m4
19 // 2. Define your own BoxDoShapeSomething like BoxDoShapeRect
20 // 3. Invoke BoxUseShape
21 // 4. Use the Box and Lid modules generated
23 m4_dnl Box_Part($1=transl_x,$2=transl_y, $3=rot_z,$4=mirror_xy)
24 m4_dnl $5=kind, $6=kindargs, $7=profile(profileargsargs))
25 m4_define(`Box_Part',`
26 translate([($1),($2)])
29 BoxPart_Extrude_$5($6, $7)') m4_dnl
33 m4_dnl BoxPart_Extrude_Linear(dist, `profile(...);');
34 m4_define(`BoxPart_Extrude_Linear',`
36 translate([0,0, -($1)])
37 linear_extrude(height= boxpart_d + ($1)) {
42 m4_dnl BoxPart_Extrude_Arc(x0_radius, swept_angle, `profile(...);')
43 m4_dnl arc starting at transl_x, transl_y, moving towards positive
44 m4_dnl y at first and then bending towards negative x, until
45 m4_dnl use negative x0_radius to inciate bending towards positive x
46 m4_dnl swept_angle is reached
47 m4_dnl x0_radius is the radius of the extruded part at x=0, not of the box
48 m4_define(`BoxPart_Extrude_Arc',`
49 translate([-($1),0,0])
52 linear_extrude(height=1000)
56 rotate_extrude(convexity=10, $fs=1, $fn=36)
58 translate([+($1),0,0]){
64 m4_define(`BoxLocals',`
65 ts_cidoff = (ts_cnrrad * (1-.7) + wallthick * .8) * [1,1];
67 ts_xbox_lin = ts_xbox - ts_cnrrad*2;
68 ts_ybox_lin = ts_ybox - ts_cnrrad*2;
71 m4_dnl BoxDoShapeRect(`profile(profileargs)');
72 m4_define(`BoxDoShapeRect',`
73 Box_Part(0, ts_cnrrad, 0,0, Linear,`ts_ybox_lin', `$1' )
74 Box_Part(0, ts_ybox-ts_cnrrad, 0,0, Arc,`-ts_cnrrad,90' , `$1' )
75 Box_Part(ts_cnrrad, ts_ybox, -90,0, Linear,`ts_xbox_lin', `$1' )
76 Box_Part(ts_xbox-ts_cnrrad, ts_ybox, -90,0, Arc,`-ts_cnrrad,90' , `$1' )
77 Box_Part(ts_xbox, ts_ybox-ts_cnrrad, -180,0, Linear,`ts_ybox_lin', `$1' )
78 Box_Part(ts_xbox, ts_cnrrad, -180,0, Arc,`-ts_cnrrad,90' , `$1' )
79 Box_Part(ts_xbox-ts_cnrrad, 0, -270,0, Linear,`ts_xbox_lin', `$1' )
80 Box_Part(ts_cnrrad, 0, -270,0, Arc,`-ts_cnrrad,90' , `$1' )
85 module SealingBox_WallProfile(){
87 z = ts_zbox - innertube - tubesealrad;
88 translate([0, -0.1]) square([wallthick, z]);
89 translate([tubesealrad, z]) circle(r=tubesealrad, $fn=20);
92 module SealingBox_FloorProfile(){
94 mirror([0,1]) square([wallthick, floorth]);
97 module SealingBox_LidProfile(){
99 rad = tubesealrad + innertube;
102 translate([-lidoverlap - innertube,
103 ts_zbox - lidoverhang - innertube])
104 square([lidoverlap + innertube + wallthick,
105 lidoverhang + innertube + ceilth]);
107 translate([tubesealrad,
108 ts_zbox - innertube - tubesealrad])
114 circle(r= tubesealrad + innertube, $fn=20);
120 module SealingBox_CeilProfile(){
122 translate([0, ts_zbox])
123 square([wallthick*2, ceilth]);
126 // BoxDoShape(Basename,BoxDoShapeSomething)
127 // generates modules BasenameBox and BasenameLid
128 m4_define(`BoxUseShape',`
131 $2(SealingBox_WallProfile(););
132 hull(){ $2(SealingBox_FloorProfile();); }
137 $2(SealingBox_LidProfile(););
138 hull(){ $2(SealingBox_CeilProfile();); }
142 BoxUseShape(`TestSealBox',`BoxDoShapeRect')