PinePhoneBoy/strap.scad

102 lines
3.1 KiB
OpenSCAD
Raw Normal View History

2021-01-02 09:43:54 +00:00
// dependency: https://github.com/revarbat/BOSL
include <BOSL/constants.scad>
use <BOSL/transforms.scad>
use <BOSL/shapes.scad>
use <BOSL/masks.scad>
use <BOSL/sliders.scad>
// DEBUG:
//validation = 1;
//xray = 1;
// EXPORT:
MODEL_STRAP_PLATFORM_BASE=10;
MODEL_STRAP_PLATFORM_RIB=11;
MODEL_STRAP_PLATFORM_RIB_BRACE=12;
export=0; // [0:20]
function is_not_export() = is_undef(export) || export == 0;
function is_export() = !is_not_export();
function is_model_strict(m) = is_export() && export == m;
function is_model(m) = is_not_export() || export == m;
function get_phone_size() = [160, 76.7, 10];
module arm() {
$fn=$preview ? 10 : 30;
arm_size=[200, 55, 40];
color("gray")
down(arm_size.z/2) cuboid(arm_size, fillet=16, edges=EDGES_X_ALL);
}
module strap_platform() {
base_size=[40, 70, 2];
rib_thickness=2;
rib_height=20;
rib_pos=[base_size.x/2 - rib_thickness, 0, -1.3];
brace_size=[base_size.x, 3.6, 4.8];
brace_pos=[0, base_size.y/2 - 4, -1.3];
module platform_base() {
difference() {
down(base_size.z/2) cuboid(base_size, fillet=2, edges=EDGES_Z_ALL);
down(base_size.z/2) scale([0.75, 0.85, 2]) cuboid(base_size, fillet=2, edges=EDGES_Z_ALL);
model_rib_left(socket=true);
model_rib_right(socket=true);
}
}
module platform_rib(socket=false) {
rib_size=[rib_thickness, base_size.y - 2, rib_height];
difference() {
union() {
difference() {
down(rib_size.z/2) scale(socket ? 1.01 : 1) sparse_strut(h=rib_size.z, l=rib_size.y, thick=rib_size.x, strut=1.2, maxang=40, max_bridge=4);
arm();
}
difference() {
intersection() {
down(rib_size.z/2) cube(rib_size, center=true);
scale(1.07) arm();
}
down(2) scale(1.0) arm();
}
}
fwd(brace_pos.y) platform_rib_brace(socket=true);
back(brace_pos.y) platform_rib_brace(socket=true);
}
}
module platform_rib_brace(socket=false) {
down(rib_height - 1.2 - brace_size.z/2) scale(socket ? 1.02 : 1) cuboid(brace_size, fillet=1, edges=EDGES_X_ALL);
}
module model_rib_left(socket=false) {
left(rib_pos.x) up(rib_pos.z) platform_rib(socket=socket);
}
module model_rib_right(socket=false) {
right(rib_pos.x) up(rib_pos.z) platform_rib(socket=socket);
}
module model_brace_front() {
fwd(brace_pos.y) up(brace_pos.z) platform_rib_brace();
}
module model_brace_back() {
back(brace_pos.y) up(brace_pos.z) platform_rib_brace();
}
if (is_model(MODEL_STRAP_PLATFORM_BASE)) platform_base();
if (is_model(MODEL_STRAP_PLATFORM_RIB)) model_rib_left();
if (is_model(MODEL_STRAP_PLATFORM_RIB_BRACE)) model_brace_front();
if (is_not_export()) {
model_rib_right();
model_brace_back();
}
}
module model_strap_platform() {
strap_platform();
}
module model_arm() {
if (is_not_export()) down(3) arm();
}
model_strap_platform();
model_arm();