Update 'bushing.jscad'
This commit is contained in:
parent
d16190879d
commit
ae9d42a855
@ -2,9 +2,15 @@
|
|||||||
// author : Tim Farrell
|
// author : Tim Farrell
|
||||||
// license : MIT License
|
// license : MIT License
|
||||||
// revision : 3
|
// revision : 3
|
||||||
// tags : Rubber
|
// tags : TPU
|
||||||
// file : bushing.jscad
|
// file : bushing.jscad
|
||||||
|
|
||||||
|
const { polygon, cylinder, torus } = require('@jscad/modeling').primitives;
|
||||||
|
const { extrudeLinear } = require('@jscad/modeling').extrusions;
|
||||||
|
const { translate, rotateZ } = require('@jscad/modeling').transforms;
|
||||||
|
const { subtract, union } = require('@jscad/modeling').booleans
|
||||||
|
|
||||||
|
|
||||||
function getParameterDefinitions () {
|
function getParameterDefinitions () {
|
||||||
return [
|
return [
|
||||||
{name: 'overhang', type: 'float', initial: 7, min: 1, max: 40, step: 1, caption: 'Overhang'},
|
{name: 'overhang', type: 'float', initial: 7, min: 1, max: 40, step: 1, caption: 'Overhang'},
|
||||||
@ -24,26 +30,34 @@ function knurling(p) {
|
|||||||
const bushing_radius = p.bushing_diameter / 2;
|
const bushing_radius = p.bushing_diameter / 2;
|
||||||
const thread_radius = bushing_radius * 0.72
|
const thread_radius = bushing_radius * 0.72
|
||||||
const twist_angle = 45;
|
const twist_angle = 45;
|
||||||
const overlap = 2;
|
const overlap = 1;
|
||||||
const twist = twist_angle * p.bushing_height / thread_radius;
|
const twist = twist_angle * p.bushing_height / thread_radius;
|
||||||
const threads = 360 / twist_angle * overlap;
|
const threads = 360 / twist_angle * overlap;
|
||||||
const triangle = polygon([
|
const square = polygon({points: [
|
||||||
[thread_radius, thread_radius],
|
[thread_radius, thread_radius],
|
||||||
[0, thread_radius],
|
[0, thread_radius],
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[thread_radius, 0]
|
[thread_radius, 0]
|
||||||
]);
|
]});
|
||||||
|
|
||||||
for (let i=0; i < threads; ++i) {
|
for (let i=0; i < threads; ++i) {
|
||||||
knurls.push(
|
knurls.push(
|
||||||
linear_extrude({height: p.bushing_height, twist, slices: 30}, triangle)
|
translate(
|
||||||
.rotateZ(360 / threads * i)
|
[0, 0, -p.bushing_height/2],
|
||||||
.translate([0, 0, -p.bushing_height/2])
|
rotateZ(
|
||||||
|
2 * Math.PI * i / threads,
|
||||||
|
[extrudeLinear({height: p.bushing_height, twistAngle: twist, twistSteps: 120}, square)]
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
knurls.push(
|
knurls.push(
|
||||||
linear_extrude({height: p.bushing_height, twist: -twist, slices: 30}, triangle)
|
translate(
|
||||||
.rotateZ(360 / threads * i)
|
[0, 0, -p.bushing_height/2],
|
||||||
.translate([0, 0, -p.bushing_height/2])
|
rotateZ(
|
||||||
|
2 * Math.PI * i / threads,
|
||||||
|
[extrudeLinear({height: p.bushing_height, twistAngle: -twist, twistSteps: 120}, square)]
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return union(...knurls);
|
return union(...knurls);
|
||||||
@ -54,17 +68,17 @@ function donut(p) {
|
|||||||
const outer_radius = p.overhang + p.host_hole_diameter/2 - inner_radius;
|
const outer_radius = p.overhang + p.host_hole_diameter/2 - inner_radius;
|
||||||
const z_offset = p.bushing_height/2 - (p.bushing_height/2 - p.host_hole_height/2);
|
const z_offset = p.bushing_height/2 - (p.bushing_height/2 - p.host_hole_height/2);
|
||||||
return union(
|
return union(
|
||||||
torus({ ri: inner_radius, ro: outer_radius }).translate([0, 0, z_offset]),
|
translate([0, 0, z_offset], torus({ innerRadius: inner_radius, outerRadius: outer_radius })),
|
||||||
torus({ ri: inner_radius, ro: outer_radius }).translate([0, 0, -z_offset])
|
translate([0, 0, -z_offset], torus({ innerRadius: inner_radius, outerRadius: outer_radius }))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bushing_main(p) {
|
function bushing_main(p) {
|
||||||
const outer_radius = p.overhang + p.host_hole_diameter/2;
|
const outer_radius = p.overhang + p.host_hole_diameter/2;
|
||||||
const main_cylinder = cylinder({
|
const main_cylinder = cylinder({
|
||||||
r: outer_radius - (p.taper ? (p.bushing_height - p.host_hole_height) / 2 : 0),
|
radius: outer_radius - (p.taper ? (p.bushing_height - p.host_hole_height) / 2 : 1),
|
||||||
h: p.bushing_height,
|
height: p.bushing_height,
|
||||||
center: true
|
center: [0, 0, 0]
|
||||||
});
|
});
|
||||||
if (p.taper) {
|
if (p.taper) {
|
||||||
return union(
|
return union(
|
||||||
@ -79,14 +93,14 @@ function host_hole(p) {
|
|||||||
const inner_radius = p.host_hole_diameter/2;
|
const inner_radius = p.host_hole_diameter/2;
|
||||||
const outer_radius = p.overhang + inner_radius;
|
const outer_radius = p.overhang + inner_radius;
|
||||||
|
|
||||||
return difference(
|
return subtract(
|
||||||
cylinder({r: outer_radius, h: p.host_hole_height, center: true}),
|
cylinder({radius: outer_radius, height: p.host_hole_height, center: [0, 0, 0]}),
|
||||||
cylinder({r: inner_radius, h: p.host_hole_height, center: true})
|
cylinder({radius: inner_radius, height: p.host_hole_height, center: [0, 0, 0]})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bushing_sleeve(p) {
|
function bushing_sleeve(p) {
|
||||||
const sleeve = cylinder({r: p.bushing_diameter/2, h: p.bushing_height, center: true});
|
const sleeve = cylinder({radius: p.bushing_diameter/2, height: p.bushing_height, center: [0, 0, 0]});
|
||||||
if (p.knurling) {
|
if (p.knurling) {
|
||||||
return union(sleeve, knurling(p));
|
return union(sleeve, knurling(p));
|
||||||
}
|
}
|
||||||
@ -94,9 +108,12 @@ function bushing_sleeve(p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main(p) {
|
function main(p) {
|
||||||
return difference(
|
return subtract(
|
||||||
bushing_main(p),
|
bushing_main(p),
|
||||||
host_hole(p),
|
host_hole(p),
|
||||||
bushing_sleeve(p)
|
bushing_sleeve(p)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = { main, getParameterDefinitions }
|
||||||
Loading…
x
Reference in New Issue
Block a user