Used tube.scad to shorten code.

This commit is contained in:
Chris Palmer 2020-11-13 18:55:26 +00:00
parent c7dfdd0fb9
commit ba5e5fa390

View File

@ -20,7 +20,7 @@
//! Shaft couplings //! Shaft couplings
// //
include <../core.scad> include <../core.scad>
use <../utils/tube.scad>
function sc_length(type) = type[1]; //! Coupling length function sc_length(type) = type[1]; //! Coupling length
function sc_diameter(type) = type[2]; //! Coupling outer diameter function sc_diameter(type) = type[2]; //! Coupling outer diameter
@ -31,9 +31,9 @@ module shaft_coupling(type, colour = "silver") { //! Draw the shaft coupling
vitamin(str("shaft_coupling(", type[0], "): Shaft coupling ", type[0])); vitamin(str("shaft_coupling(", type[0], "): Shaft coupling ", type[0]));
length = sc_length(type); length = sc_length(type);
diameter = sc_diameter(type); radius = sc_diameter(type) / 2;
d1 = sc_diameter1(type); r1 = sc_diameter1(type) / 2;
d2 = sc_diameter2(type); r2 = sc_diameter2(type) / 2;
grub_length = 3; grub_length = 3;
module grub_screw_positions() { module grub_screw_positions() {
@ -42,7 +42,7 @@ module shaft_coupling(type, colour = "silver") { //! Draw the shaft coupling
translate_z(z) translate_z(z)
for(a = [0, 90]) for(a = [0, 90])
rotate([-90, 0, a]) rotate([-90, 0, a])
translate_z(diameter / 2 + 1) translate_z(radius + 1)
children(); children();
} }
@ -50,16 +50,9 @@ module shaft_coupling(type, colour = "silver") { //! Draw the shaft coupling
render(convexity=2) difference() { render(convexity=2) difference() {
union() { union() {
translate_z(-length / 2) translate_z(-length / 2)
linear_extrude(length / 2) tube(radius, r1, length / 2, false);
difference() {
circle(d = diameter); tube(radius, r2, length / 2, false);
circle(d = d1);
}
linear_extrude(length / 2)
difference() {
circle(d = diameter);
circle(d = d2);
}
} }
grub_screw_positions() grub_screw_positions()
rotate([180, 0, 0]) rotate([180, 0, 0])
@ -70,4 +63,3 @@ module shaft_coupling(type, colour = "silver") { //! Draw the shaft coupling
grub_screw_positions() grub_screw_positions()
not_on_bom() screw(M3_grub_screw, grub_length); not_on_bom() screw(M3_grub_screw, grub_length);
} }