Routines to quickly position panels on the face of a box.
OTop( thickness, offset ) | position children as top panel |
OBottom( thickness, offset ) | position children as bottom panel |
OFront( thickness, offset ) | position children as front panel |
OBack( thickness, offset ) | position children as back panel |
OLeft( thickness, offset ) | position children as left panel |
ORight( thickness, offset ) | position children as right panel |
OFTop( thickness, offset ) | same as OTop() but flipped |
OFBottom( thickness, offset ) | same as OBottom() but flipped |
OFFront( thickness, offset ) | same as OFront() but flipped |
OFBack( thickness, offset ) | same as OBack() but flipped |
OFLeft( thickness, offset ) | same as OLeft() but flipped |
OFRight( thickness, offset ) | same as ORight() but flipped |
thickness | panel thickness |
offset = 0 | up/down offset, UP+ |
leftRight = 0 | left/right offset, right+ |
frontBack = 0 | front/back offset, back+ |
faceIn = false | whether panel is to face inwards or outwards the "box" |
thickness | panel thickness |
offset = 0 | up/down offset, DOWN+ |
leftRight = 0 | left/right offset, right+ |
frontBack = 0 | front/back offset, back+ |
faceIn = true | whether panel is to face inwards or outwards the "box" |
thickness | panel thickness |
offset = 0 | front/back offset, FRONT+ |
leftRight = 0 | left/right offset, right+ |
upDown = 0 | up/down offset, up+ |
faceIn = false | whether panel is to face inwards or outwards the "box" |
thickness | panel thickness |
offset = 0 | front/back offset, BACK+ |
leftRight = 0 | left/right offset, right+ |
upDown = 0 | up/down offset, up+ |
faceIn = true | whether panel is to face inwards or outwards the "box" |
thickness | panel thickness |
offset = 0 | left/right offset, LEFT+ |
frontBack = 0 | front/back offset, back+ |
upDown = 0 | up/down offset, up+ |
faceIn = true | whether panel is to face inwards or outwards the "box" |
thickness | panel thickness |
offset = 0 | left/right offset, RIGHT+ |
frontBack = 0 | front/back offset, back+ |
upDown = 0 | up/down offset, up+ |
faceIn = true | whether panel is to face inwards or outwards the "box" |
same as similarly named version but faceIn is reversed eg. OTop( faceIn=false ), OFTop( faceIn=true ), ...
// NATURAL POSITIONING
axis();
Panel(50,50);
color("steelblue") OFront (THK,50) Panel(50,50);
color("red") OBack (THK,50) Panel(50,50);
color("green") OLeft (THK,50) Panel(50,50);
color("violet") ORight (THK,50) Panel(50,50);
color("orange") OTop (THK,50) Panel(50,50);
color("gold") OBottom(THK,50) Panel(50,50);
// FLIP OF NATURAL
translate( [100,0,0] ) {
axis();
Panel(50,50);
color("steelblue") OFFront (THK,50) Panel(50,50);
color("red") OFBack (THK,50) Panel(50,50);
color("green") OFLeft (THK,50) Panel(50,50);
color("violet") OFRight (THK,50) Panel(50,50);
color("orange") OFTop (THK,50) Panel(50,50);
color("gold") OFBottom(THK,50) Panel(50,50);
}
W = 40; // width
D = 50; // depth
H = 80; // height
THK = 3; // thickness of panel
// panels facing outwards
translate( [210,0,0] )
Box( faceIn=false );
// panels facing inwards
translate( [300,0,0] )
Box( faceIn=true );
module axis() {
color("red") {
cube([100,1,1],center=true);
cube([1,100,1],center=true);
cube([1,1,100],center=true);
}
}
module Box( faceIn ) {
// less: THK*2, so no overlap
OBottom(THK, H/2, faceIn=faceIn) color("gold" ) Panel( W,D );
OLeft (THK, W/2, faceIn=faceIn) color("green" ) Panel( D-THK*2,H-THK*2 );
OBack (THK, D/2, faceIn=faceIn) color("red" ) Panel( W, H-THK*2 );
OTop (THK, H/2, faceIn=faceIn) color("orange" ) Panel( W,D );
ORight (THK, W/2, faceIn=faceIn) color("violet" ) Panel( D-THK*2,H-THK*2 );
OFront (THK, D/2, faceIn=faceIn) color("steelblue") Panel( W, H-THK*2 );
CubeExtents( W,D,H, color="red" );
}
module Panel( width,height ) {
linear_extrude( THK, center=true )
difference() {
square( [width,height], center=true );
{
translate( [width*.25,-height*.25,0] )
square( [width/4,height/4], center=true );
translate( [-width*.25,-height*.25,0] )
circle( d=width/4 );
translate( [0,height*.25,0] )
text("H3LLO",size=6,halign="center",valign="center");
}
}
}