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 xxx)
13 // $sealingbox_floorth
15 // ts_cnrrad (outer radius of corners, leave at default normall)
16 // xxx default should be in this file
21 // B. Complicated shapes, but harder work
22 // 1. Be a .m4 file and m4_include sealing-box.scad.m4
23 // 2. Define your own BoxDoShapeSomething like BoxDoShapeRect
24 // 3. Invoke BoxUseShape
25 // 4. Use the Box and Lid modules generated
27 m4_define(`BoxLocals',`
28 wall = $sealingbox_wallth;
29 floorth = $sealingbox_floorth;
30 ceilth = $sealingbox_ceilth;
31 xbox = $sealingbox_xbox;
32 ybox = $sealingbox_ybox;
33 zbox = $sealingbox_zbox;
35 ts_cidoff = (ts_cnrrad * (1-.7) + wall * .8) * [1,1];
37 xbox_lin = xbox - ts_cnrrad*2;
38 ybox_lin = ybox - ts_cnrrad*2;
41 m4_dnl Box_Part($1=transl_x,$2=transl_y, $3=rot_z,$4=mirror_xy)
42 m4_dnl $5=kind, $6=kindargs, $7=profile(profileargsargs))
43 m4_define(`Box_Part',`
44 translate([($1),($2)])
47 BoxPart_Extrude_$5($6, $7)') m4_dnl
51 m4_dnl BoxPart_Extrude_Linear(dist, `profile(...);');
52 m4_define(`BoxPart_Extrude_Linear',`
54 translate([0,0, -($1)])
55 linear_extrude(height= boxpart_d + ($1)) {
60 m4_dnl BoxPart_Extrude_Arc(x0_radius, swept_angle, `profile(...);')
61 m4_dnl arc starting at transl_x, transl_y, moving towards positive
62 m4_dnl y at first and then bending towards negative x, until
63 m4_dnl use negative x0_radius to inciate bending towards positive x
64 m4_dnl swept_angle is reached
65 m4_dnl x0_radius is the radius of the extruded part at x=0, not of the box
66 m4_define(`BoxPart_Extrude_Arc',`
67 translate([-($1),0,0])
70 linear_extrude(height=1000)
74 rotate_extrude(convexity=10, $fs=1, $fn=36)
76 translate([+($1),0,0]){
82 m4_dnl BoxDoShapeRect(`profile(profileargs)');
83 m4_define(`BoxDoShapeRect',`
84 Box_Part(0, ts_cnrrad, 0,0, Linear,`ybox_lin', `$1' )
85 Box_Part(0, ybox-ts_cnrrad, 0,0, Arc,`-ts_cnrrad,90' , `$1' )
86 Box_Part(ts_cnrrad, ybox, -90,0, Linear,`xbox_lin', `$1' )
87 Box_Part(xbox-ts_cnrrad, ybox, -90,0, Arc,`-ts_cnrrad,90' , `$1' )
88 Box_Part(xbox, ybox-ts_cnrrad, -180,0, Linear,`ybox_lin', `$1' )
89 Box_Part(xbox, ts_cnrrad, -180,0, Arc,`-ts_cnrrad,90' , `$1' )
90 Box_Part(xbox-ts_cnrrad, 0, -270,0, Linear,`xbox_lin', `$1' )
91 Box_Part(ts_cnrrad, 0, -270,0, Arc,`-ts_cnrrad,90' , `$1' )
96 module SealingBox_WallProfile(){
98 z = zbox - innertube - tubesealrad;
99 translate([0, -0.1]) square([wall, z]);
100 translate([tubesealrad, z]) circle(r=tubesealrad, $fn=20);
103 module SealingBox_FloorProfile(){
105 mirror([0,1]) square([wall, floorth]);
108 module SealingBox_LidProfile(){
110 rad = tubesealrad + innertube;
113 translate([-lidoverlap - innertube,
114 zbox - lidoverhang - innertube])
115 square([lidoverlap + innertube + wall,
116 lidoverhang + innertube + ceilth]);
118 translate([tubesealrad,
119 zbox - innertube - tubesealrad])
125 circle(r= tubesealrad + innertube, $fn=20);
131 module SealingBox_CeilProfile(){
134 square([wall*2, ceilth]);
137 // BoxDoShape(Basename,BoxDoShapeSomething)
138 // generates modules BasenameBox and BasenameLid
139 m4_define(`BoxUseShape',`
142 $2(SealingBox_WallProfile(););
143 hull(){ $2(SealingBox_FloorProfile();); }
148 $2(SealingBox_LidProfile(););
149 hull(){ $2(SealingBox_CeilProfile();); }
153 BoxUseShape(`TestSealBox',`BoxDoShapeRect')