1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-01-17 21:48:43 +01:00

Added box sections.

This commit is contained in:
Martin Budden 2021-03-31 12:53:27 +01:00
parent e46e6b6e5b
commit b70c2f993c
3 changed files with 118 additions and 0 deletions

30
tests/box_sections.scad Normal file
View File

@ -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 <https://www.gnu.org/licenses/>.
//
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();

58
vitamins/box_section.scad Normal file
View File

@ -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 <https://www.gnu.org/licenses/>.
//
//
//! 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));
}

View File

@ -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 <https://www.gnu.org/licenses/>.
//
//
// 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 <box_section.scad>