From 70b13d2f2723caa18a69afb7a179d88366c82c51 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Sat, 2 May 2020 20:27:32 +0100 Subject: [PATCH] Added functions to create property lists that are created by the client. Foot, box, bbox, pbox, flat_hinge and strap_handle. --- printed/box.scad | 3 +++ printed/butt_box.scad | 3 +++ printed/flat_hinge.scad | 3 +++ printed/foot.scad | 6 ++++-- printed/printed_box.scad | 3 +++ printed/strap_handle.scad | 7 +++++-- readme.md | 10 ++++++++++ tests/box.scad | 2 +- tests/butt_box.scad | 2 +- tests/flat_hinge.scad | 4 ++-- tests/printed_box.scad | 10 +++++----- 11 files changed, 40 insertions(+), 13 deletions(-) diff --git a/printed/box.scad b/printed/box.scad index 9e16d28..8b76d2a 100644 --- a/printed/box.scad +++ b/printed/box.scad @@ -52,6 +52,9 @@ function box_width(type) = type[6]; //! Internal width function box_depth(type) = type[7]; //! Internal depth function box_height(type) = type[8]; //! Internal height +function box(screw, wall, sheets, top_sheet, base_sheet, size, feet = false) = //! Construct a property list for a box. + concat([screw, wall, sheets, top_sheet, base_sheet, feet], size); + function box_bezel_clearance(type) = bezel_clearance; function box_corner_gap(type) = 3; //! Gap between box_sheets at the corners to connect inside and outside profiles diff --git a/printed/butt_box.scad b/printed/butt_box.scad index 353a477..1dc79cc 100644 --- a/printed/butt_box.scad +++ b/printed/butt_box.scad @@ -50,6 +50,9 @@ function bbox_name(type) = type[8] ? type[8] : "bbox"; //! Optional name i function bbox_skip_blocks(type)= type[9] ? type[9] : []; //! List of fixing blocks to skip, used to allow a hinged panel for example function star_washers(type) = type[10] ? type[10] : is_undef(type[10]); //! Set to false to remove star washers. +function bbox(screw, sheets, base_sheet, top_sheet, span, size, name = "bbox", skip_blocks = [], star_washers = true) = //! Construct the property list for a butt_box + [ screw, sheets, base_sheet, top_sheet, span, size.x, size.y, size.z, name, skip_blocks, star_washers ]; + function bbox_volume(type) = bbox_width(type) * bbox_depth(type) * bbox_height(type) / 1000000; //! Internal volume in litres function bbox_area(type) = let(w = bbox_width(type), d = bbox_depth(type), h = bbox_height(type)) //! Internal surdface area in m^2 2 * (w * d + w * h + d * h) / 1000000; diff --git a/printed/flat_hinge.scad b/printed/flat_hinge.scad index eecfd24..dfb4047 100644 --- a/printed/flat_hinge.scad +++ b/printed/flat_hinge.scad @@ -42,6 +42,9 @@ function hinge_screws(type) = type[8]; //! How many screws function hinge_clearance(type) = type[9]; //! Clearance between knuckles function hinge_margin(type) = type[10]; //! How far to keep the screws from the knuckes +function flat_hinge(name, size, pin_d, knuckle_d, knuckles, screw, screws, clearance, margin) = //! Construct the property list for a flat hinge. + [name, size.x, size.y, size.z, pin_d, knuckle_d, knuckles, screw, screws, clearance, margin]; + function hinge_radius(type) = washer_radius(screw_washer(hinge_screw(type))) + 1; module hinge_screw_positions(type) { //! Place children at the screw positions diff --git a/printed/foot.scad b/printed/foot.scad index fdf63a4..fe8da82 100644 --- a/printed/foot.scad +++ b/printed/foot.scad @@ -24,8 +24,10 @@ include <../core.scad> use <../vitamins/insert.scad> -foot = [25, 12, 3, 2, M4_cap_screw, 10]; -insert_foot = [20, 10, 0, 2, M3_cap_screw, 10]; +function Foot(d, h, t, r, screw, slant = 10) = [d, h, t, r, screw, slant]; //! Construct a foot property list + +foot = Foot(25, 12, 3, 2, M4_cap_screw); +insert_foot = Foot(20, 10, 0, 2, M3_cap_screw); function insert_foot() = insert_foot; //! Default foot with insert diff --git a/printed/printed_box.scad b/printed/printed_box.scad index 2fa6b61..5b2ed34 100644 --- a/printed/printed_box.scad +++ b/printed/printed_box.scad @@ -30,6 +30,9 @@ include <../core.scad> use <../vitamins/insert.scad> use +function pbox(name, wall, top_t, base_t, radius, size, foot = false, screw = false, ridges = [0, 0]) //! Construct a printed box property list + = concat([name, wall, top_t, base_t, foot, screw, radius, ridges], size); + function pbox_name(type) = type[0]; //! Name to allow more than one box in a project function pbox_wall(type) = type[1]; //! Wall thickness function pbox_top(type) = type[2]; //! Top thickness diff --git a/printed/strap_handle.scad b/printed/strap_handle.scad index 2404a60..639cab3 100644 --- a/printed/strap_handle.scad +++ b/printed/strap_handle.scad @@ -24,8 +24,7 @@ include <../core.scad> use <../vitamins/insert.scad> -strap = [18, 2, M3_pan_screw, 3, 25]; -function strap() = strap; +strap = strap(); wall = 2; clearance = 0.5; @@ -40,6 +39,10 @@ function strap_screw(type = strap) = type[2]; //! Screw type function strap_panel(type = strap) = type[3]; //! Panel thickness function strap_extension(type = strap) = type[4]; //! How much length of the strap that can pull out + +function strap(width = 18, thickness = 2, screw = M3_pan_screw, panel_thickness = 3, extension = 25) = //! Construct a property list for a strap + [ width, thickness, screw, panel_thickness, extension ]; + function strap_insert(type) = screw_insert(strap_screw(type)); //! The insert type function strap_key(type) = strap_panel(type) - panel_clearance; function strap_height(type) = wall + max(insert_length(strap_insert(type)) - strap_key(type), strap_thickness(type) + clearance); //! Height of the ends diff --git a/readme.md b/readme.md index 3c38583..509c5c5 100644 --- a/readme.md +++ b/readme.md @@ -3863,6 +3863,7 @@ Normally the side sheets are the same type but they can be overridden individual ### Functions | Function | Description | |:--- |:--- | +| ```box(screw, wall, sheets, top_sheet, base_sheet, size, feet = false)``` | Construct a property list for a box. | | ```box_bezel_height(type, bottom)``` | Bezel height for top or bottom | | ```box_corner_gap(type)``` | Gap between box_sheets at the corners to connect inside and outside profiles | | ```box_inset(type)``` | How much the bezel intrudes on the specified width and length, away from the corners | @@ -3974,6 +3975,7 @@ Uses [fixing blocks](#fixing_block) and [corner blocks](#corner_block). ### Functions | Function | Description | |:--- |:--- | +| ```bbox(screw, sheets, base_sheet, top_sheet, span, size, name = "bbox", skip_blocks = [], star_washers = true)``` | Construct the property list for a butt_box | | ```bbox_area(type)``` | Internal surdface area in m^2 | | ```bbox_volume(type)``` | Internal volume in litres | @@ -4441,6 +4443,11 @@ This allows the hinges and one set of screws to belong to one assembly and the o | ```hinge_thickness(type)``` | Thickness of the leaves | | ```hinge_width(type)``` | Width | +### Functions +| Function | Description | +|:--- |:--- | +| ```flat_hinge(name, size, pin_d, knuckle_d, knuckles, screw, screws, clearance, margin)``` | Construct the property list for a flat hinge. | + ### Modules | Module | Description | |:--- |:--- | @@ -4502,6 +4509,7 @@ inserts don't grip well in rubber. ### Functions | Function | Description | |:--- |:--- | +| ```Foot(d, h, t, r, screw, slant = 10)``` | Construct a foot property list | | ```insert_foot()``` | Default foot with insert | ### Modules @@ -4672,6 +4680,7 @@ It can also have printed feet on the base with the screws doubling up to hold th ### Functions | Function | Description | |:--- |:--- | +| ```pbox(name, wall, top_t, base_t, radius, size, foot = false, screw = false, ridges = [0, 0])``` | Construct a printed box property list | | ```pbox_inclusion(type)``` | How far the ledge for the base extends inwards | | ```pbox_insert(type)``` | The insert for the base screws | | ```pbox_screw(type)``` | Foot screw if got feet else base_screw | @@ -4999,6 +5008,7 @@ be fully customised by passing a list of properties. ### Functions | Function | Description | |:--- |:--- | +| ```strap(width = 18, thickness = 2, screw = M3_pan_screw, panel_thickness = 3, extension = 25)``` | Construct a property list for a strap | | ```strap_end_width(type = strap)``` | Width of the ends | | ```strap_height(type)``` | Height of the ends | | ```strap_insert(type)``` | The insert type | diff --git a/tests/box.scad b/tests/box.scad index 6ec18ff..eb988eb 100644 --- a/tests/box.scad +++ b/tests/box.scad @@ -23,7 +23,7 @@ use <../vitamins/insert.scad> use <../printed/box.scad> -box = [M3_dome_screw, 3, DiBond, PMMA3, DiBond6, true, 150, 100, 70]; +box = box(screw = M3_dome_screw, wall = 3, sheets = DiBond, top_sheet = PMMA3, base_sheet = DiBond6, feet = true, size = [150, 100, 70]); include <../printed/box_assembly.scad> diff --git a/tests/butt_box.scad b/tests/butt_box.scad index 6df0020..d0d4754 100644 --- a/tests/butt_box.scad +++ b/tests/butt_box.scad @@ -25,7 +25,7 @@ include <../printed/butt_box.scad> $explode = 0; -box = [M3_dome_screw, DiBond, DiBond6, PMMA3, 250, 400, 300, 120]; +box = bbox(screw = M3_dome_screw, sheets = DiBond, base_sheet = DiBond6, top_sheet = PMMA3, span = 250, size = [400, 300, 120]); module bbox_assembly() _bbox_assembly(box); diff --git a/tests/flat_hinge.scad b/tests/flat_hinge.scad index 9622282..ed877ae 100644 --- a/tests/flat_hinge.scad +++ b/tests/flat_hinge.scad @@ -32,8 +32,8 @@ clearance = 0.2; angle = 0; // [-90 : 180] -big_hinge = ["big", width, depth, thickness, pin_diameter, knuckle_diameter, knuckles, M3_dome_screw, screws, clearance, margin]; -small_hinge = ["small", 20, 16, 2, 2.85, 7, 3, M3_dome_screw, 2, 0.2, 0]; +big_hinge = flat_hinge(name = "big", size = [width, depth, thickness], pin_d = pin_diameter, knuckle_d = knuckle_diameter, knuckles = knuckles, screw = M3_dome_screw, screws = screws, clearance = clearance, margin = margin); +small_hinge = flat_hinge(name = "small", size =[ 20, 16, 2], pin_d = 2.85, knuckle_d = 7, knuckles = 3, screw = M3_dome_screw, screws = 2, clearance = 0.2, margin = 0); hinges = [small_hinge, big_hinge]; diff --git a/tests/printed_box.scad b/tests/printed_box.scad index 3434b78..f2fbeeb 100644 --- a/tests/printed_box.scad +++ b/tests/printed_box.scad @@ -21,25 +21,25 @@ include <../core.scad> use <../printed/foot.scad> use <../printed/printed_box.scad> -foot = [13, 5, 2, 1, M3_pan_screw, 10]; +foot = Foot(d = 13, h = 5, t = 2, r = 1, screw = M3_pan_screw); module foot_stl() foot(foot); wall = 2; top_thickness = 2; base_thickness = 2; -case_inner_rad = 8; +inner_rad = 8; width = 80; depth = 45; height = 40; -box1 = ["box1", wall, top_thickness, base_thickness, false, M2_cap_screw, case_inner_rad, [8, 1], width, depth, height]; -box2 = ["smooth_box", wall, top_thickness, base_thickness, foot, false, case_inner_rad, [0, 0], width, depth, height]; +box1 = pbox(name = "box1", wall = wall, top_t = top_thickness, base_t = base_thickness, radius = inner_rad, size = [width, depth, height], screw = M2_cap_screw, ridges = [8, 1]); +box2 = pbox(name = "smooth_box", wall = wall, top_t = top_thickness, base_t = base_thickness, radius = inner_rad, size = [width, depth, height], foot = foot); module box1_feet_positions() { clearance = 2; foot_r = foot_diameter(foot) / 2; - x_inset = case_inner_rad + foot_r - pbox_ridges(box1).y; + x_inset = inner_rad + foot_r - pbox_ridges(box1).y; z_inset = foot_r + clearance; h = height + base_thickness;