Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOR DISCUSSION - Moved screws, nuts, washers and rails test arrays into test files. #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core.scad
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ include <utils/core/core.scad>
//
// Fasteners used by a lot of other vitamins
//
include <vitamins/screws.scad>
include <utils/screws.scad>
3 changes: 3 additions & 0 deletions tests/nuts.scad
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
include <../core.scad>
use <../utils/layout.scad>

nuts = [M2_nut, M2p5_nut, M3_nut, M4_nut, M5_nut, M6_nut, M8_nut];


module nuts() {
layout([for(n = nuts) 2 * nut_radius(n)], 5) let(n = nuts[$i]) {
for(nyloc = [false, true])
Expand Down
7 changes: 7 additions & 0 deletions tests/rails.scad
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ length = 200;
sheet = 3;
pos = 1; //[-1 : 0.1 : 1]

rails = [MGN5, MGN7, MGN9, MGN12, MGN15, SSR15, HGH15CA, HGH20CA];
carriages = [MGN5C_carriage, MGN7C_carriage, MGN7H_carriage, MGN9C_carriage, MGN9H_carriage,
MGN12C_carriage, MGN12H_carriage, MGN12H_carriage, MGN15C_carriage, SSR15_carriage,
HGH15CA_carriage, HGH20CA_carriage
];


function rail_carriages(rail) = [for(c = carriages) if(carriage_rail(c) == rail) c];

module rails()
Expand Down
3 changes: 3 additions & 0 deletions tests/washers.scad
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use <../utils/layout.scad>

include <../vitamins/washers.scad>

washers = [M2_washer, M2p5_washer, M3_washer, M3p5_washer, M4_washer, M5_washer, M6_washer, M8_washer, M3_rubber_washer];


function penny_diameter(w) = let(p = penny_washer(w)) washer_diameter(p ? p : w);

module washers()
Expand Down
42 changes: 42 additions & 0 deletions utils/screws.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// NopSCADlib Copyright Chris Palmer 2018
// [email protected]
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//

include <../vitamins/screws.scad>

screw_lists = [
[ M2_cap_screw, M2p5_cap_screw, M3_cap_screw, M4_cap_screw, M5_cap_screw, M6_cap_screw, M8_cap_screw],
[ 0, 0, M3_low_cap_screw],
[ M2_cs_cap_screw, 0, M3_cs_cap_screw, M4_cs_cap_screw, M5_cs_cap_screw, M6_cs_cap_screw, M8_cs_cap_screw],
[ M2_dome_screw, M2p5_dome_screw,M3_dome_screw, M4_dome_screw, M5_dome_screw],
[ 0, 0, M3_hex_screw, M4_hex_screw, M5_hex_screw, M6_hex_screw, M8_hex_screw],
[ 0, M2p5_pan_screw, M3_pan_screw, M4_pan_screw, M5_pan_screw, M6_pan_screw, No632_pan_screw],
[ No2_screw, 0, No4_screw, No6_screw, No8_screw, No6_cs_screw],
[ 0, 0, M3_grub_screw, M4_grub_screw, M5_grub_screw, M6_grub_screw]
];

screws = [for(list = screw_lists) each list];

function find_screw(type, size, i = 0) =
i >= len(screws) ? undef
: screw_head_type(screws[i]) == type && screw_radius(screws[i]) == size / 2 ? screws[i]
: find_screw(type, size, i + 1);

function alternate_screw(type, screw) =
let(alt_screw = find_screw(type, screw_radius(screw) * 2))
alt_screw ? alt_screw :screw;
2 changes: 0 additions & 2 deletions vitamins/nuts.scad
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,4 @@ M5nS_thin_nut = ["M5nS_thin_nut", 5, 8, 2.7];
M6nS_thin_nut = ["M6nS_thin_nut", 6, 10, 3.2];
M8nS_thin_nut = ["M8nS_thin_nut", 8, 13, 4];

nuts = [M2_nut, M2p5_nut, M3_nut, M4_nut, M5_nut, M6_nut, M8_nut];

use <nut.scad>
9 changes: 0 additions & 9 deletions vitamins/rails.scad
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
include <../core.scad>

//
// Rails
//
Expand Down Expand Up @@ -46,11 +44,4 @@ HGH15CA_carriage= [ "HGH15CA", 61.4, 39.4, 34, 28, 4, 26, 26, M4_cap_screw, HG
HGH20CA_carriage= [ "HGH20CA", 77.5, 50.5, 44, 30, 4.6, 35, 32, M5_cap_screw, HGH20CA ];
SSR15_carriage = [ "SSR15", 40.3, 23.3, 34, 24, 4.5, 0, 26, M4_cap_screw, SSR15 ];

rails = [MGN5, MGN7, MGN9, MGN12, MGN15, SSR15, HGH15CA, HGH20CA];

carriages = [MGN5C_carriage, MGN7C_carriage, MGN7H_carriage, MGN9C_carriage, MGN9H_carriage,
MGN12C_carriage, MGN12H_carriage, MGN12H_carriage, MGN15C_carriage, SSR15_carriage,
HGH15CA_carriage, HGH20CA_carriage
];

use <rail.scad>
22 changes: 0 additions & 22 deletions vitamins/screws.scad
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,4 @@ No6_screw = ["No6", "No6 pan wood", hs_pan, 3.5, 6.7, 2.2, 0, 0
No6_cs_screw = ["No6_cs", "No6 cs wood", hs_cs, 3.5, 7.0, 0, 0, 0, 0, M4_washer, false, No6_pilot_radius, No6_clearance_radius];
No8_screw = ["No8", "No8 pan wood", hs_pan, 4.2, 8.2, 3.05, 0, 0, 0 , M5_washer, false, No8_pilot_radius, No8_clearance_radius];

screw_lists = [
[ M2_cap_screw, M2p5_cap_screw, M3_cap_screw, M4_cap_screw, M5_cap_screw, M6_cap_screw, M8_cap_screw],
[ 0, 0, M3_low_cap_screw],
[ M2_cs_cap_screw, 0, M3_cs_cap_screw, M4_cs_cap_screw, M5_cs_cap_screw, M6_cs_cap_screw, M8_cs_cap_screw],
[ M2_dome_screw, M2p5_dome_screw,M3_dome_screw, M4_dome_screw, M5_dome_screw],
[ 0, 0, M3_hex_screw, M4_hex_screw, M5_hex_screw, M6_hex_screw, M8_hex_screw],
[ 0, M2p5_pan_screw, M3_pan_screw, M4_pan_screw, M5_pan_screw, M6_pan_screw, No632_pan_screw],
[ No2_screw, 0, No4_screw, No6_screw, No8_screw, No6_cs_screw],
[ 0, 0, M3_grub_screw, M4_grub_screw, M5_grub_screw, M6_grub_screw]
];

use <screw.scad>

screws = [for(list = screw_lists) each list];

function find_screw(type, size, i = 0) =
i >= len(screws) ? undef
: screw_head_type(screws[i]) == type && screw_radius(screws[i]) == size / 2 ? screws[i]
: find_screw(type, size, i + 1);

function alternate_screw(type, screw) =
let(alt_screw = find_screw(type, screw_radius(screw) * 2))
alt_screw ? alt_screw :screw;
2 changes: 0 additions & 2 deletions vitamins/washers.scad
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,4 @@ toggle_washer = ["toggle", 6.1,12, 0.6, false, 10, 0, 0, undef];

M3_rubber_washer= ["M3_rubber",3, 10, 1.5, true, 5.8, M3_penny_washer];

washers = [M2_washer, M2p5_washer, M3_washer, M3p5_washer, M4_washer, M5_washer, M6_washer, M8_washer, M3_rubber_washer];

use <washer.scad>