From b70c2f993c351bf71da57cfc169ed02a235cf4f3 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Wed, 31 Mar 2021 12:53:27 +0100 Subject: [PATCH] Added box sections. --- tests/box_sections.scad | 30 ++++++++++++++++++++ vitamins/box_section.scad | 58 ++++++++++++++++++++++++++++++++++++++ vitamins/box_sections.scad | 30 ++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 tests/box_sections.scad create mode 100644 vitamins/box_section.scad create mode 100644 vitamins/box_sections.scad diff --git a/tests/box_sections.scad b/tests/box_sections.scad new file mode 100644 index 0000000..6885c98 --- /dev/null +++ b/tests/box_sections.scad @@ -0,0 +1,30 @@ +// +// NopSCADlib Copyright Chris Palmer 2018 +// nop.head@gmail.com +// 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 . +// +include <../utils/core/core.scad> +use <../utils/layout.scad> + +include <../vitamins/box_sections.scad> + +module box_sections() { + layout([for(b = box_sections) box_section_size(b).x], 20) + box_section(box_sections[$i], 100); +} + +if($preview) + box_sections(); diff --git a/vitamins/box_section.scad b/vitamins/box_section.scad new file mode 100644 index 0000000..bbe2115 --- /dev/null +++ b/vitamins/box_section.scad @@ -0,0 +1,58 @@ +// +// NopSCADlib Copyright Chris Palmer 2018 +// nop.head@gmail.com +// 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 . +// + +// +//! Box sections. +// +include <../utils/core/core.scad> +include <../utils/tube.scad> + +include <../vitamins/sheets.scad> + +function box_section_material(type) = type[1]; //! Material description +function box_section_size(type) = type[2]; //! Size +function box_section_thickness(type) = type[3]; //! Wall thickness +function box_section_fillet(type) = type[4]; //! Fillet +function box_section_colour(type) = type[5]; //! Colour +function box_section_colour2(type) = type[6]; //! Colour2, for woven box section +function box_section_is_woven(type) = !is_undef(type[6]); //! Box section is woven, eg carbon fiber + +module box_section(type, length, center = true) { + vitamin(str("box_section(", type[0], arg(length, 15), "): ", box_section_material(type), ", length ", length, "mm")); + + size = box_section_size(type); + thickness = box_section_thickness(type); + + if (box_section_is_woven(type)) + translate_z(center ? 0 : length / 2) { + rotate([0, -90, 90]) + for (z = [-size.y / 2, size.y / 2 - thickness]) + translate_z(z) + woven_sheet(CF1, thickness, box_section_colour(type), box_section_colour2(type), length, size.x) + square([length, size.x], center=true); + rotate([0, -90, 0]) + for (z = [-size.x / 2, size.x / 2 - thickness]) + translate_z(z) + woven_sheet(CF1, thickness, box_section_colour(type), box_section_colour2(type), length, size.y) + square([length, size.y], center=true); + } + else + color(box_section_colour(type)) + rectangular_tube([size.x, size.y, length], center, thickness, box_section_fillet(type)); +} diff --git a/vitamins/box_sections.scad b/vitamins/box_sections.scad new file mode 100644 index 0000000..b7bb46e --- /dev/null +++ b/vitamins/box_sections.scad @@ -0,0 +1,30 @@ +// +// NopSCADlib Copyright Chris Palmer 2018 +// nop.head@gmail.com +// 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 . +// + +// +// Box sections +// +AL12x8x1 = ["AL12x8x1", "Aluminium rectangular box section 12mm x 8mm x 1mm", [12, 8], 1, 0.5, silver, undef]; +AL20x20x2 = ["AL20x20x2", "Aluminium rectangular box section 20mm x 20mm x 2mm", [20, 20], 2, 0.5, silver, undef]; +CF10x10x1 = ["CF10x10x1", "Carbon fiber rectangular box section 10mm x 10mm x 1mm", [10, 10], 1, 0.5, grey(35), grey(20)]; + + +box_sections = [AL12x8x1, AL20x20x2, CF10x10x1]; + +use