mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-09-09 06:31:32 +02:00
Dome option added to nut to draw acorn nuts.
Chamfers added to nuts and hex head screws when manifold is used.
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
//
|
||||
//! 20mm panel mount fuse holder.
|
||||
//
|
||||
include <../utils/core/core.scad>
|
||||
include <../core.scad>
|
||||
include <spades.scad>
|
||||
use <../utils/tube.scad>
|
||||
use <../utils/thread.scad>
|
||||
@@ -69,18 +69,10 @@ module fuseholder(thickness) { //! Fuseholder with nut in place for specified pa
|
||||
vflip()
|
||||
translate_z(thickness)
|
||||
explode(height, explode_children = true) {
|
||||
color(colour) {
|
||||
color(colour)
|
||||
tube(or = nut_d / 2, ir = thread_d / 2, h = nut_flange_t, center = false);
|
||||
|
||||
linear_extrude(nut_t)
|
||||
difference() {
|
||||
circle(d = nut_d, $fn = 6);
|
||||
|
||||
circle(d = thread_d);
|
||||
}
|
||||
}
|
||||
if(show_threads && exploded())
|
||||
female_metric_thread(thread_d, thread_p, nut_t, false, colour = colour);
|
||||
draw_nut(nut_d, thread_d, nut_t, thread_p, colour, show_threads && exploded() || thickness > thread);
|
||||
}
|
||||
//
|
||||
// Body
|
||||
|
@@ -149,18 +149,8 @@ module jack_4mm_plastic(colour, thickness, display_colour = false) { //! Draw a
|
||||
}
|
||||
translate_z(-thickness)
|
||||
explode(-length)
|
||||
vflip() {
|
||||
color(silver)
|
||||
linear_extrude(nut_t)
|
||||
difference() {
|
||||
circle(d = nut_d, $fn = 6);
|
||||
|
||||
circle(d = thread_d);
|
||||
}
|
||||
|
||||
if(show_threads)
|
||||
female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver);
|
||||
}
|
||||
vflip()
|
||||
draw_nut(nut_d, thread_d, nut_t, thread_p, silver, show_threads);
|
||||
}
|
||||
|
||||
function jack_4mm_shielded_hole_radius() = 12 / 2; //! Panel hole radius for 4mm shielded jack
|
||||
@@ -282,14 +272,7 @@ module post_4mm(colour, thickness, display_colour = false) { //! Draw a 4mm bind
|
||||
module nut() {
|
||||
nut_t = 2.3;
|
||||
|
||||
color(silver)
|
||||
linear_extrude(nut_t) difference() {
|
||||
circle(d = 6.3 / cos(30), $fn = 6);
|
||||
|
||||
circle(d = thread_d);
|
||||
}
|
||||
if(show_threads)
|
||||
female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver);
|
||||
draw_nut(6.3 / cos(30), thread_d, nut_t, thread_p, silver, show_threads);
|
||||
|
||||
translate_z(nut_t)
|
||||
children();
|
||||
@@ -498,16 +481,6 @@ module power_jack(thickness) { //! Draw a power jack socket with nut positioned
|
||||
// Nut
|
||||
translate_z(-thickness)
|
||||
explode(-length)
|
||||
vflip() {
|
||||
color(silver)
|
||||
linear_extrude(nut_t)
|
||||
difference() {
|
||||
circle(d = nut_d, $fn = 6);
|
||||
|
||||
circle(d = thread_d);
|
||||
}
|
||||
|
||||
if(show_threads)
|
||||
female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver);
|
||||
}
|
||||
vflip()
|
||||
draw_nut(nut_d, thread_d, nut_t, thread_p, silver, show_threads);
|
||||
}
|
||||
|
@@ -37,6 +37,7 @@ function nut_thickness(type, nyloc = false) = nyloc ? type[4] : type[3]; //! Thi
|
||||
function nut_washer(type) = type[5]; //! Corresponding washer
|
||||
function nut_trap_depth(type) = type[6]; //! Depth of nut trap
|
||||
function nut_pitch(type) = type[7]; //! Pitch if not standard metric course thread
|
||||
function nut_dome(type) = type[8]; //! Dome height and max thread depth if a domed acorn nut
|
||||
|
||||
function nut_flat_radius(type) = nut_radius(type) * cos(30); //! Radius across the flats
|
||||
|
||||
@@ -44,36 +45,84 @@ function nut_square_size(type) = type[1]; //! Diameter of the corresponding
|
||||
function nut_square_width(type) = type[2]; //! Width of the square nut
|
||||
function nut_square_thickness(type) = type[3]; //! Thickness of the square nut
|
||||
|
||||
module nut(type, nyloc = false, brass = false, nylon = false) { //! Draw specified nut
|
||||
function nut_dome_height(type) = let(d = nut_dome(type)) d ? d[0] : nut_thickness(type); //! Height of the domed version
|
||||
function nut_thread_depth(type) = let(d = nut_dome(type)) d ? d[1] : nut_thickness(type); //! Max thread depth in domed version
|
||||
|
||||
module draw_nut(od, id, t, pitch, colour, show_thread, thread_h = undef ) {
|
||||
th = is_undef(thread_h) ? t : thread_h;
|
||||
|
||||
color(colour) {
|
||||
or = od / 2;
|
||||
fr = or * cos(30);
|
||||
|
||||
render_if(manifold) intersection() {
|
||||
linear_extrude(t, convexity = 5)
|
||||
difference() {
|
||||
circle(or, $fn = 6);
|
||||
|
||||
if(id)
|
||||
circle(d = id);
|
||||
}
|
||||
|
||||
if(manifold)
|
||||
rotate_extrude()
|
||||
hull() {
|
||||
h = (or - fr) * tan(30);
|
||||
|
||||
translate([0, -eps])
|
||||
square([fr, t + eps]);
|
||||
|
||||
translate([or, h])
|
||||
square([eps, t - 2 * h]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(show_thread && id)
|
||||
female_metric_thread(id, pitch,
|
||||
th,
|
||||
top = th > t ? 0 : manifold ? 1 : -1,
|
||||
bot = manifold ? 1 : -1,
|
||||
center = false, colour = colour);
|
||||
}
|
||||
|
||||
module nut(type, nyloc = false, brass = false, nylon = false, dome = false) { //! Draw specified nut
|
||||
thread_d = nut_size(type);
|
||||
thread_p = nut_pitch(type) ? nut_pitch(type) : metric_coarse_pitch(thread_d);
|
||||
hole_rad = thread_d / 2;
|
||||
outer_rad = nut_radius(type);
|
||||
thickness = nut_thickness(type);
|
||||
nyloc_thickness = nut_thickness(type, true);
|
||||
desc = nyloc ? "nyloc" : brass ? "brass" : nylon ? "nylon" : "";
|
||||
vitamin(str("nut(", type[0], arg(nyloc, false, "nyloc"), arg(brass, false, "brass"), arg(nylon, false, "nylon"),
|
||||
desc = nyloc ? "nyloc" : brass ? "brass" : nylon ? "nylon" : dome ? "domed" : "";
|
||||
vitamin(str("nut(", type[0],
|
||||
arg(nyloc, false, "nyloc"),
|
||||
arg(brass, false, "brass"),
|
||||
arg(nylon, false, "nylon"),
|
||||
arg(dome, false, "dome"),
|
||||
"): Nut M", nut_size(type), " x ", thickness, "mm ", desc));
|
||||
|
||||
$fs = fs; $fa = fa;
|
||||
|
||||
colour = brass ? brass_colour : nylon ? grey(30): grey(70);
|
||||
explode(nyloc ? 10 : 0) {
|
||||
draw_nut(outer_rad * 2, thread_d, thickness, thread_p, colour, show_threads, dome ? nut_thread_depth(type) : thickness);
|
||||
|
||||
fr = nut_flat_radius(type);
|
||||
color(colour) {
|
||||
linear_extrude(thickness)
|
||||
difference() {
|
||||
circle(outer_rad, $fn = 6);
|
||||
|
||||
circle(hole_rad);
|
||||
}
|
||||
|
||||
if(nyloc)
|
||||
translate_z(-eps)
|
||||
rounded_cylinder(r = outer_rad * cos(30) , h = nyloc_thickness, r2 = (nyloc_thickness - thickness) / 2, ir = hole_rad);
|
||||
}
|
||||
translate_z(eps)
|
||||
rounded_cylinder(r = outer_rad * cos(30), h = nyloc_thickness - eps, r2 = (nyloc_thickness - thickness) / 2, ir = hole_rad);
|
||||
|
||||
if(show_threads)
|
||||
female_metric_thread(thread_d, thread_p, thickness, center = false, colour = colour);
|
||||
if(dome)
|
||||
translate_z(thickness)
|
||||
rotate_extrude()
|
||||
difference() {
|
||||
h = nut_dome_height(type) - thickness;
|
||||
r = fr - eps;
|
||||
rounded_corner(r, h, r);
|
||||
|
||||
square([thread_d / 2, nut_thread_depth(type) - thickness]);
|
||||
}
|
||||
}
|
||||
|
||||
if(nyloc)
|
||||
translate_z(thickness)
|
||||
|
@@ -28,25 +28,25 @@ M5_nut_depth = 4;
|
||||
M6_nut_depth = 5;
|
||||
M8_nut_depth = 6.5;
|
||||
|
||||
// s d t n w t t
|
||||
// c i h y a r h
|
||||
// r a i l s a r
|
||||
// e m c o h p e
|
||||
// s d t n w t t d d
|
||||
// c i h y a r h o o
|
||||
// r a i l s a r m m
|
||||
// e m c o h p e e e
|
||||
// w e k c e d
|
||||
// t n r d
|
||||
// e e t e p
|
||||
// r s h p i
|
||||
// s k t t
|
||||
// h c
|
||||
// h
|
||||
// t n r d h t
|
||||
// e e t e p e h
|
||||
// r s h p i i r
|
||||
// s k t t g e
|
||||
// h c h a
|
||||
// h t d
|
||||
M2_nut = ["M2_nut", 2, 4.9, 1.6, 2.4, M2_washer, M2_nut_trap_depth, 0];
|
||||
M2p5_nut = ["M2p5_nut", 2.5, 5.8, 2.2, 3.8, M2p5_washer, M2p5_nut_trap_depth, 0];
|
||||
M3_nut = ["M3_nut", 3, 6.4, 2.4, 4, M3_washer, M3_nut_trap_depth, 0];
|
||||
M4_nut = ["M4_nut", 4, 8.1, 3.2, 5, M4_washer, M4_nut_trap_depth, 0];
|
||||
M5_nut = ["M5_nut", 5, 9.2, 4, 6.25, M5_washer, M5_nut_depth, 0];
|
||||
M6_nut = ["M6_nut", 6, 11.5, 5, 8, M6_washer, M6_nut_depth, 0];
|
||||
M3_nut = ["M3_nut", 3, 6.4, 2.4, 4, M3_washer, M3_nut_trap_depth, 0, [6, 5.40]];
|
||||
M4_nut = ["M4_nut", 4, 8.1, 3.2, 5, M4_washer, M4_nut_trap_depth, 0, [8, 5.74]];
|
||||
M5_nut = ["M5_nut", 5, 9.2, 4, 6.25, M5_washer, M5_nut_depth, 0, [10, 7.79]];
|
||||
M6_nut = ["M6_nut", 6, 11.5, 5, 8, M6_washer, M6_nut_depth, 0, [12, 8.29]];
|
||||
M6_half_nut = ["M6_half_nut", 6, 11.5, 3, 8, M6_washer, 3, 0];
|
||||
M8_nut = ["M8_nut", 8, 15, 6.5, 8, M8_washer, M8_nut_depth, 0];
|
||||
M8_nut = ["M8_nut", 8, 15, 6.5, 8, M8_washer, M8_nut_depth, 0, [15, 11.35]];
|
||||
toggle_nut = ["toggle_nut", 6.1, 9.2, 1.5, 1.5, M6_washer, 1.5, inch(1/40)];
|
||||
|
||||
M4_wingnut = ["M4_wingnut", 4, 10, 3.75,8, M4_washer, 0, 22, 10, 6, 3];
|
||||
|
@@ -17,7 +17,7 @@
|
||||
// If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
//! Potentiometers and rotary encoders
|
||||
include <../utils/core/core.scad>
|
||||
include <../core.scad>
|
||||
use <../utils/rounded_cylinder.scad>
|
||||
use <../utils/round.scad>
|
||||
use <../utils/thread.scad>
|
||||
@@ -71,18 +71,8 @@ module pot_nut(type, washer = true) { //! Draw the nut for a potentiometer and p
|
||||
}
|
||||
|
||||
if(nut)
|
||||
color(nut[2])
|
||||
translate_z(nut_z + exploded() * 10) {
|
||||
linear_extrude(nut[1])
|
||||
difference() {
|
||||
circle(d = nut.x / cos(30), $fn = 6);
|
||||
|
||||
circle(d = thread_d);
|
||||
}
|
||||
|
||||
if(show_threads && exploded())
|
||||
female_metric_thread(thread_d, pot_thread_p(type), nut[1], center = false, colour = nut[2]);
|
||||
}
|
||||
translate_z(nut_z + exploded() * 10)
|
||||
draw_nut(nut.x / cos(30), thread_d, nut[1], pot_thread_p(type), nut[2], show_threads && exploded());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -205,8 +205,7 @@ module screw(type, length, hob_point = 0, nylon = false) { //! Draw specified sc
|
||||
cylinder(h=2 * eps, r=socket_rad, $fn = 6);
|
||||
}
|
||||
if(head_type == hs_hex) {
|
||||
color(colour)
|
||||
cylinder(r = head_rad, h = head_height, $fn = 6);
|
||||
draw_nut(head_rad * 2, 0, head_height, 0, colour, false);
|
||||
|
||||
shaft();
|
||||
}
|
||||
|
Reference in New Issue
Block a user