mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Guard various linear_extrude()s for height=0
This commit is contained in:
parent
fa0281f246
commit
0399cd085c
6 changed files with 45 additions and 27 deletions
|
@ -762,9 +762,11 @@ module linear_sweep_bezier(bezier, height=100, splinesteps=16, N=3, center, conv
|
||||||
maxy = max([for (pt = bezier) abs(pt[1])]);
|
maxy = max([for (pt = bezier) abs(pt[1])]);
|
||||||
anchor = get_anchor(anchor,center,BOT,BOT);
|
anchor = get_anchor(anchor,center,BOT,BOT);
|
||||||
attachable(anchor,spin,orient, size=[maxx*2,maxy*2,height]) {
|
attachable(anchor,spin,orient, size=[maxx*2,maxy*2,height]) {
|
||||||
|
if (height > 0) {
|
||||||
linear_extrude(height=height, center=true, convexity=convexity, twist=twist, slices=slices, scale=scale) {
|
linear_extrude(height=height, center=true, convexity=convexity, twist=twist, slices=slices, scale=scale) {
|
||||||
bezier_polygon(bezier, splinesteps=splinesteps, N=N);
|
bezier_polygon(bezier, splinesteps=splinesteps, N=N);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -779,15 +779,17 @@ module modulated_circle(r, sines=[10], d)
|
||||||
// extrude_from_to([0,0,0], [10,20,30], convexity=4, twist=360, scale=3.0, slices=40) {
|
// extrude_from_to([0,0,0], [10,20,30], convexity=4, twist=360, scale=3.0, slices=40) {
|
||||||
// xcopies(3) circle(3, $fn=32);
|
// xcopies(3) circle(3, $fn=32);
|
||||||
// }
|
// }
|
||||||
module extrude_from_to(pt1, pt2, convexity=undef, twist=undef, scale=undef, slices=undef) {
|
module extrude_from_to(pt1, pt2, convexity, twist, scale, slices) {
|
||||||
rtp = xyz_to_spherical(pt2-pt1);
|
rtp = xyz_to_spherical(pt2-pt1);
|
||||||
translate(pt1) {
|
translate(pt1) {
|
||||||
rotate([0, rtp[2], rtp[1]]) {
|
rotate([0, rtp[2], rtp[1]]) {
|
||||||
|
if (rtp[0] > 0) {
|
||||||
linear_extrude(height=rtp[0], convexity=convexity, center=false, slices=slices, twist=twist, scale=scale) {
|
linear_extrude(height=rtp[0], convexity=convexity, center=false, slices=slices, twist=twist, scale=scale) {
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -895,12 +897,14 @@ module path_extrude(path, convexity=10, clipsize=100) {
|
||||||
translate(pt1) {
|
translate(pt1) {
|
||||||
Qrot(q) {
|
Qrot(q) {
|
||||||
down(clipsize/2/2) {
|
down(clipsize/2/2) {
|
||||||
|
if ((dist+clipsize/2) > 0) {
|
||||||
linear_extrude(height=dist+clipsize/2, convexity=convexity) {
|
linear_extrude(height=dist+clipsize/2, convexity=convexity) {
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
translate(pt1) {
|
translate(pt1) {
|
||||||
hq = (i > 0)? Q_Slerp(q, pquats[i-1][1], 0.5) : q;
|
hq = (i > 0)? Q_Slerp(q, pquats[i-1][1], 0.5) : q;
|
||||||
Qrot(hq) down(clipsize/2+epsilon) cube(clipsize, center=true);
|
Qrot(hq) down(clipsize/2+epsilon) cube(clipsize, center=true);
|
||||||
|
|
|
@ -108,9 +108,11 @@ module cube(size=1, center, anchor, spin=0, orient=UP)
|
||||||
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG);
|
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG);
|
||||||
size = scalar_vec3(size);
|
size = scalar_vec3(size);
|
||||||
attachable(anchor,spin,orient, size=size) {
|
attachable(anchor,spin,orient, size=size) {
|
||||||
|
if (size.z > 0) {
|
||||||
linear_extrude(height=size.z, center=true, convexity=2) {
|
linear_extrude(height=size.z, center=true, convexity=2) {
|
||||||
square([size.x,size.y], center=true);
|
square([size.x,size.y], center=true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,17 +191,21 @@ module cylinder(h, r1, r2, center, l, r, d, d1, d2, anchor, spin=0, orient=UP)
|
||||||
l = first_defined([h, l, 1]);
|
l = first_defined([h, l, 1]);
|
||||||
sides = segs(max(r1,r2));
|
sides = segs(max(r1,r2));
|
||||||
attachable(anchor,spin,orient, r1=r1, r2=r2, l=l) {
|
attachable(anchor,spin,orient, r1=r1, r2=r2, l=l) {
|
||||||
if(r1>r2) {
|
if (r1 > r2) {
|
||||||
|
if (l > 0) {
|
||||||
linear_extrude(height=l, center=true, convexity=2, scale=r2/r1) {
|
linear_extrude(height=l, center=true, convexity=2, scale=r2/r1) {
|
||||||
circle(r=r1);
|
circle(r=r1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
zflip() {
|
zflip() {
|
||||||
|
if (l > 0) {
|
||||||
linear_extrude(height=l, center=true, convexity=2, scale=r1/r2) {
|
linear_extrude(height=l, center=true, convexity=2, scale=r1/r2) {
|
||||||
circle(r=r2);
|
circle(r=r2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -512,9 +512,11 @@ module right_triangle(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
|
||||||
size = scalar_vec3(size);
|
size = scalar_vec3(size);
|
||||||
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG);
|
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG);
|
||||||
attachable(anchor,spin,orient, size=size) {
|
attachable(anchor,spin,orient, size=size) {
|
||||||
|
if (size.z > 0) {
|
||||||
linear_extrude(height=size.z, convexity=2, center=true) {
|
linear_extrude(height=size.z, convexity=2, center=true) {
|
||||||
polygon([[-size.x/2,-size.y/2], [-size.x/2,size.y/2], [size.x/2,-size.y/2]]);
|
polygon([[-size.x/2,-size.y/2], [-size.x/2,size.y/2], [size.x/2,-size.y/2]]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1395,10 +1397,12 @@ module teardrop(r=undef, d=undef, l=undef, h=undef, ang=45, cap_h=undef, anchor=
|
||||||
size = [r*2,l,r*2];
|
size = [r*2,l,r*2];
|
||||||
attachable(anchor,spin,orient, size=size) {
|
attachable(anchor,spin,orient, size=size) {
|
||||||
rot(from=UP,to=FWD) {
|
rot(from=UP,to=FWD) {
|
||||||
|
if (l > 0) {
|
||||||
linear_extrude(height=l, center=true, slices=2) {
|
linear_extrude(height=l, center=true, slices=2) {
|
||||||
teardrop2d(r=r, ang=ang, cap_h=cap_h);
|
teardrop2d(r=r, ang=ang, cap_h=cap_h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1567,6 +1571,7 @@ module interior_fillet(l=1.0, r, ang=90, overlap=0.01, d, anchor=FRONT+LEFT, spi
|
||||||
steps = ceil(segs(r)*ang/360);
|
steps = ceil(segs(r)*ang/360);
|
||||||
step = ang/steps;
|
step = ang/steps;
|
||||||
attachable(anchor,spin,orient, size=[r,r,l]) {
|
attachable(anchor,spin,orient, size=[r,r,l]) {
|
||||||
|
if (l > 0) {
|
||||||
linear_extrude(height=l, convexity=4, center=true) {
|
linear_extrude(height=l, convexity=4, center=true) {
|
||||||
path = concat(
|
path = concat(
|
||||||
[[0,0]],
|
[[0,0]],
|
||||||
|
@ -1574,6 +1579,7 @@ module interior_fillet(l=1.0, r, ang=90, overlap=0.01, d, anchor=FRONT+LEFT, spi
|
||||||
);
|
);
|
||||||
translate(-[r,r]/2) polygon(path);
|
translate(-[r,r]/2) polygon(path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,7 +298,7 @@ module stroke(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rotate([90,0,endcap_angle1]) {
|
rotate([90,0,endcap_angle1]) {
|
||||||
linear_extrude(height=widths[0], center=true, convexity=convexity) {
|
linear_extrude(height=max(widths[0],0.001), center=true, convexity=convexity) {
|
||||||
polygon(endcap_shape1);
|
polygon(endcap_shape1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ module stroke(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rotate([90,0,endcap_angle2]) {
|
rotate([90,0,endcap_angle2]) {
|
||||||
linear_extrude(height=select(widths,-1), center=true, convexity=convexity) {
|
linear_extrude(height=max(select(widths,-1),0.001), center=true, convexity=convexity) {
|
||||||
polygon(endcap_shape2);
|
polygon(endcap_shape2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,470];
|
BOSL_VERSION = [2,0,471];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue