1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-09-06 21:30:38 +02:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Chris Palmer
6f8ff606fa Removed woven_sheet() from the readme.
Removed redundent code.
2020-12-24 09:01:51 +00:00
Chris Palmer
acd5de0fbd Fixed extra BOM entries for woven sheet.
Added render colour to BOM for 3D sheets.
2020-12-24 08:56:54 +00:00
Chris Palmer
cc1e3baaf6 Reimplemeted woven sheets with an eye to speed and interface consistancy. 2020-12-23 21:44:05 +00:00
Chris Palmer
ab50b6f9a6 Merge branch 'woven_sheet' of https://github.com/martinbudden/NopSCADlib 2020-12-23 16:50:30 +00:00
Martin Budden
85cb54ef31 Added sheet with checkerboard texture to simulate carbon fiber. 2020-12-23 07:47:41 +00:00
6 changed files with 115 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 854 KiB

After

Width:  |  Height:  |  Size: 859 KiB

View File

@@ -3127,8 +3127,12 @@ The "Soft" parameter can be used to determinesif the sheet material needs machin
The "Colour" parameter is a quad-array: [R, G, B, Alpha], or can be a named colour, see [OpenSCAD_User_Manual](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#color).
For speed sheets should be modelled in 2D by subtracting holes from 2D templates made by ```sheet_2D()``` and then extruded to 3D with ```render_2D_sheet()```.
Note that modules that drill holes will return a 2D object if ```h``` is set to 0 to facilitate this.
For speed sheets should be modelled in 2D by subtracting holes from 2D templates made by `sheet_2D()` and then extruded to 3D with `render_2D_sheet()`.
Note that modules that drill holes will return a 2D object if `h` is set to 0 to facilitate this.
If 3D features are needed, for example countersinks, then sheets can be modelled in 3D using `sheet()` and then coloured with `render_sheet()`.
When woven sheets (e.g. carbon fibre) are rendered it is necessary to specify the dimensions again to `render_sheet()` or `render_2D_sheet()`.
[vitamins/sheets.scad](vitamins/sheets.scad) Object definitions.
@@ -3141,14 +3145,22 @@ Note that modules that drill holes will return a 2D object if ```h``` is set to
| Function | Description |
|:--- |:--- |
| ```sheet_colour(type)``` | Colour |
| ```sheet_colour2(type)``` | Second colour for a woven sheet |
| ```sheet_is_soft(type)``` | Is soft enough for wood screws |
| ```sheet_thickness(type)``` | Thickness |
| ```sheet_warp(type)``` | Wovern sheet warp |
| ```sheet_weft(type)``` | Wovern sheet weft |
### Functions
| Function | Description |
|:--- |:--- |
| ```sheet_is_woven(type)``` | Is a woven sheet, eg carbon fiber |
### Modules
| Module | Description |
|:--- |:--- |
| ```render_2D_sheet(type, colour = false)``` | Extrude a 2D sheet template and give it the correct colour |
| ```render_sheet(type, colour = false)``` | Render a sheet in the correct colour after holes have been subtracted |
| ```render_2D_sheet(type, colour = false, colour2 = false, w = undef, d = undef)``` | Extrude a 2D sheet template and give it the correct colour |
| ```render_sheet(type, colour = false, colour2 = false, w = undef, d = undef)``` | Render a sheet in the correct colour after holes have been subtracted |
| ```sheet(type, w, d, corners = [0, 0, 0, 0])``` | Draw specified sheet |
| ```sheet_2D(type, w, d, corners = [0, 0, 0, 0])``` | 2D sheet template with specified size and optionally rounded corners |
@@ -3173,6 +3185,9 @@ Note that modules that drill holes will return a 2D object if ```h``` is set to
| 1 | ```sheet(PMMA3, 30, 30, 2)``` | Sheet acrylic 30mm x 30mm x 3mm |
| 1 | ```sheet(PMMA6, 30, 30, 2)``` | Sheet acrylic 30mm x 30mm x 6mm |
| 1 | ```sheet(PMMA8, 30, 30, 2)``` | Sheet acrylic 30mm x 30mm x 8mm |
| 1 | ```sheet(CF1, 30, 30, 2)``` | Sheet carbon fiber 30mm x 30mm x 1mm |
| 1 | ```sheet(CF2, 30, 30, 2)``` | Sheet carbon fiber 30mm x 30mm x 2mm |
| 1 | ```sheet(CF3, 30, 30, 2)``` | Sheet carbon fiber 30mm x 30mm x 3mm |
| 1 | ```sheet(glass2, 30, 30, 2)``` | Sheet glass 30mm x 30mm x 2mm |
| 1 | ```sheet(Steel06, 30, 30, 2)``` | Sheet mild steel 30mm x 30mm x 0.6mm |

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -20,12 +20,30 @@ include <../utils/core/core.scad>
use <../utils/layout.scad>
include <../vitamins/sheets.scad>
include <../vitamins/screws.scad>
width = 30;
2d = true;
module sheets()
layout([for(s = sheets) width], 5)
render_sheet(sheets[$i]) sheet(sheets[$i], width, width, 2);
let(sheet = sheets[$i], w = sheet_is_woven(sheet) ? width : undef)
if(2d)
render_2D_sheet(sheet, w = w, d = w)
difference() {
sheet_2D(sheet, width, width, 2);
circle(3);
}
else
render_sheet(sheet, w = w, d = w)
difference() {
sheet(sheet, width, width, 2);
translate_z(sheet_thickness(sheet) / 2)
screw_countersink(M3_cs_cap_screw);
}
if($preview)
sheets();

View File

@@ -27,14 +27,22 @@
//!
//! The "Colour" parameter is a quad-array: [R, G, B, Alpha], or can be a named colour, see [OpenSCAD_User_Manual](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#color).
//!
//! For speed sheets should be modelled in 2D by subtracting holes from 2D templates made by ```sheet_2D()``` and then extruded to 3D with ```render_2D_sheet()```.
//! Note that modules that drill holes will return a 2D object if ```h``` is set to 0 to facilitate this.
//! For speed sheets should be modelled in 2D by subtracting holes from 2D templates made by `sheet_2D()` and then extruded to 3D with `render_2D_sheet()`.
//! Note that modules that drill holes will return a 2D object if `h` is set to 0 to facilitate this.
//!
//! If 3D features are needed, for example countersinks, then sheets can be modelled in 3D using `sheet()` and then coloured with `render_sheet()`.
//!
//! When woven sheets (e.g. carbon fibre) are rendered it is necessary to specify the dimensions again to `render_sheet()` or `render_2D_sheet()`.
//
include <../utils/core/core.scad>
function sheet_thickness(type) = type[2]; //! Thickness
function sheet_colour(type) = type[3]; //! Colour
function sheet_is_soft(type) = type[4]; //! Is soft enough for wood screws
function sheet_is_woven(type) = !is_undef(type[5]); //! Is a woven sheet, eg carbon fiber
function sheet_warp(type) = type[5]; //! Wovern sheet warp
function sheet_weft(type) = type[6]; //! Wovern sheet weft
function sheet_colour2(type) = type[7]; //! Second colour for a woven sheet
module corner(r) {
if(r > 0)
@@ -78,12 +86,66 @@ module sheet(type, w, d, corners = [0, 0, 0, 0]) //! Draw specified sheet
linear_extrude(sheet_thickness(type), center = true)
sheet_2D(type, w, d, corners);
module render_sheet(type, colour = false) //! Render a sheet in the correct colour after holes have been subtracted
color(colour ? colour : sheet_colour(type))
render() children();
module render_sheet(type, colour = false, colour2 = false, w = undef, d = undef) { //! Render a sheet in the correct colour after holes have been subtracted
woven = sheet_is_woven(type);
t = sheet_thickness(type);
colour = colour ? colour : sheet_colour(type);
colour2 = colour2 ? colour2 : sheet_colour2(type);
let($dxf_colour = colour)
color(woven ? colour2 : colour)
render()
scale([1, 1, woven ? (t - 2 * eps) / t : 1])
children();
module render_2D_sheet(type, colour = false) //! Extrude a 2D sheet template and give it the correct colour
let($dxf_colour = colour ? colour : sheet_colour(type))
color($dxf_colour)
linear_extrude(sheet_thickness(type), center = true)
if(woven)
for(side = [-1, 1], z = side * (t - eps) / 2)
translate_z(z)
woven_sheet(type, eps, colour, colour2, w, d)
projection(cut = true)
translate_z(-z)
not_on_bom()
children();
}
module render_2D_sheet(type, colour = false, colour2 = false, w = undef, d = undef) { //! Extrude a 2D sheet template and give it the correct colour
colour = colour ? colour : sheet_colour(type);
colour2 = colour2 ? colour2 : sheet_colour2(type);
let($dxf_colour = colour)
if(sheet_is_woven(type))
woven_sheet(type, sheet_thickness(type), colour, colour2, w, d)
children();
else
color($dxf_colour)
linear_extrude(sheet_thickness(type), center = true)
children();
}
module woven_sheet(type, thickness, colour, colour2, w, d) { // Create a woven 2D sheet with specified thickness and colours
warp = sheet_warp(type);
weft = sheet_weft(type);
warp_doublet_count = assert(!is_undef(w) && !is_undef(d), "Must specify the dimensions to render woven sheets") ceil(w / (2 * warp));
weft_count = ceil(d / weft);
module chequerboard(odd = 0)
translate([-w / 2, -d / 2])
for (y = [0 : weft_count - 1], x = [0 : warp_doublet_count - 1])
translate([warp * (2 * x + ((y + odd) % 2)), weft * y])
square([warp, weft]);
color(colour)
linear_extrude(thickness)
intersection() {
chequerboard();
children();
}
if(thickness > eps)
color(colour2)
linear_extrude(thickness)
intersection() {
chequerboard(1);
not_on_bom()
children();
}
}

View File

@@ -22,7 +22,7 @@
//
//
// [ Code, Description, Thickness, Color, Soft]
// [ Code, Description, Thickness, Color, Soft, Warp, Weft, Color2]
//
mdf_colour = "#BEA587"; // sampled from a photo
@@ -45,7 +45,11 @@ Foam20 = [ "Foam20", "Foam sponge", 20,[0.3, 0.3, 0.3, 1 ],
AL6 = [ "AL6", "Aluminium tooling plate", 6, [0.9, 0.9, 0.9, 1 ], false];
AL8 = [ "AL8", "Aluminium tooling plate", 8, [0.9, 0.9, 0.9, 1 ], false];
Steel06 = [ "Steel06", "Sheet mild steel", 0.6,"silver" , false];
CF1 = [ "CF1", "Sheet carbon fiber", 1, grey(30), false, 2, 2, grey(25)];
CF2 = [ "CF2", "Sheet carbon fiber", 2, grey(30), false, 2, 2, grey(25)];
CF3 = [ "CF3", "Sheet carbon fiber", 3, grey(30), false, 2, 2, grey(25)];
sheets = [MDF6, MDF10, MDF12, MDF19, PMMA2, PMMA3, PMMA6, PMMA8, PMMA10, glass2, DiBond, DiBond6, Cardboard, FoilTape, Foam20, AL6, AL8, Steel06];
sheets = [CF1, CF2, CF3, MDF6, MDF10, MDF12, MDF19, PMMA2, PMMA3, PMMA6, PMMA8, PMMA10, glass2, DiBond, DiBond6, Cardboard, FoilTape, Foam20, AL6, AL8, Steel06];
use <sheet.scad>