mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-04 03:09:45 +00:00
Improved usability of slot()
This commit is contained in:
parent
0a9f0c02af
commit
5bd5fb894f
1 changed files with 13 additions and 3 deletions
16
shapes.scad
16
shapes.scad
|
@ -487,6 +487,7 @@ module torus(or=1, ir=0.5, od=undef, id=undef, r=undef, r2=undef, d=undef, d2=un
|
||||||
// Makes a linear slot with rounded ends, appropriate for bolts to slide along.
|
// Makes a linear slot with rounded ends, appropriate for bolts to slide along.
|
||||||
// p1 = center of starting circle of slot. (Default: [0,0,0])
|
// p1 = center of starting circle of slot. (Default: [0,0,0])
|
||||||
// p2 = center of ending circle of slot. (Default: [1,0,0])
|
// p2 = center of ending circle of slot. (Default: [1,0,0])
|
||||||
|
// l = length of slot along the X axis. Use instead of p1 and p2.
|
||||||
// h = height of slot shape. (default: 1.0)
|
// h = height of slot shape. (default: 1.0)
|
||||||
// r = radius of slot circle. (default: 0.5)
|
// r = radius of slot circle. (default: 0.5)
|
||||||
// r1 = bottom radius of slot cone. (use instead of r)
|
// r1 = bottom radius of slot cone. (use instead of r)
|
||||||
|
@ -494,18 +495,27 @@ module torus(or=1, ir=0.5, od=undef, id=undef, r=undef, r2=undef, d=undef, d2=un
|
||||||
// d = diameter of slot circle. (default: 1.0)
|
// d = diameter of slot circle. (default: 1.0)
|
||||||
// d1 = bottom diameter of slot cone. (use instead of d)
|
// d1 = bottom diameter of slot cone. (use instead of d)
|
||||||
// d2 = top diameter of slot cone. (use instead of d)
|
// d2 = top diameter of slot cone. (use instead of d)
|
||||||
|
// center = If true (default) centers vertically. Else, drops flush with XY plane.
|
||||||
|
// Examples:
|
||||||
|
// slot(l=50, h=5, d1=8, d2=10, center=false);
|
||||||
|
// slot([0,0,0], [50,50,0], h=5, d=10);
|
||||||
module slot(
|
module slot(
|
||||||
p1=[0,0,0], p2=[1,0,0], h=1.0,
|
p1=[0,0,0], p2=[1,0,0], h=1.0,
|
||||||
|
l=undef, center=true,
|
||||||
r=undef, r1=undef, r2=undef,
|
r=undef, r1=undef, r2=undef,
|
||||||
d=1.0, d1=undef, d2=undef
|
d=1.0, d1=undef, d2=undef
|
||||||
) {
|
) {
|
||||||
r = (r != undef)? r : (d/2);
|
r = (r != undef)? r : (d/2);
|
||||||
r1 = (r1 != undef)? r1 : ((d1 != undef)? (d1/2) : r);
|
r1 = (r1 != undef)? r1 : ((d1 != undef)? (d1/2) : r);
|
||||||
r2 = (r2 != undef)? r2 : ((d2 != undef)? (d2/2) : r);
|
r2 = (r2 != undef)? r2 : ((d2 != undef)? (d2/2) : r);
|
||||||
|
pt1 = l==undef? p1 : [-l/2, 0, 0];
|
||||||
|
pt2 = l==undef? p2 : [ l/2, 0, 0];
|
||||||
$fn = quantup(segs(max(r1,r2)),4);
|
$fn = quantup(segs(max(r1,r2)),4);
|
||||||
hull() {
|
down(center? 0 : h/2) {
|
||||||
translate(p1) cylinder(h=h, r1=r1, r2=r2, center=true);
|
hull() {
|
||||||
translate(p2) cylinder(h=h, r1=r1, r2=r2, center=true);
|
translate(pt1) cylinder(h=h, r1=r1, r2=r2, center=true);
|
||||||
|
translate(pt2) cylinder(h=h, r1=r1, r2=r2, center=true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue