mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +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,8 +762,10 @@ module linear_sweep_bezier(bezier, height=100, splinesteps=16, N=3, center, conv
|
|||
maxy = max([for (pt = bezier) abs(pt[1])]);
|
||||
anchor = get_anchor(anchor,center,BOT,BOT);
|
||||
attachable(anchor,spin,orient, size=[maxx*2,maxy*2,height]) {
|
||||
linear_extrude(height=height, center=true, convexity=convexity, twist=twist, slices=slices, scale=scale) {
|
||||
bezier_polygon(bezier, splinesteps=splinesteps, N=N);
|
||||
if (height > 0) {
|
||||
linear_extrude(height=height, center=true, convexity=convexity, twist=twist, slices=slices, scale=scale) {
|
||||
bezier_polygon(bezier, splinesteps=splinesteps, N=N);
|
||||
}
|
||||
}
|
||||
children();
|
||||
}
|
||||
|
|
14
paths.scad
14
paths.scad
|
@ -779,12 +779,14 @@ 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) {
|
||||
// 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);
|
||||
translate(pt1) {
|
||||
rotate([0, rtp[2], rtp[1]]) {
|
||||
linear_extrude(height=rtp[0], convexity=convexity, center=false, slices=slices, twist=twist, scale=scale) {
|
||||
children();
|
||||
if (rtp[0] > 0) {
|
||||
linear_extrude(height=rtp[0], convexity=convexity, center=false, slices=slices, twist=twist, scale=scale) {
|
||||
children();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -895,8 +897,10 @@ module path_extrude(path, convexity=10, clipsize=100) {
|
|||
translate(pt1) {
|
||||
Qrot(q) {
|
||||
down(clipsize/2/2) {
|
||||
linear_extrude(height=dist+clipsize/2, convexity=convexity) {
|
||||
children();
|
||||
if ((dist+clipsize/2) > 0) {
|
||||
linear_extrude(height=dist+clipsize/2, convexity=convexity) {
|
||||
children();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,10 @@ module cube(size=1, center, anchor, spin=0, orient=UP)
|
|||
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG);
|
||||
size = scalar_vec3(size);
|
||||
attachable(anchor,spin,orient, size=size) {
|
||||
linear_extrude(height=size.z, center=true, convexity=2) {
|
||||
square([size.x,size.y], center=true);
|
||||
if (size.z > 0) {
|
||||
linear_extrude(height=size.z, center=true, convexity=2) {
|
||||
square([size.x,size.y], center=true);
|
||||
}
|
||||
}
|
||||
children();
|
||||
}
|
||||
|
@ -189,14 +191,18 @@ module cylinder(h, r1, r2, center, l, r, d, d1, d2, anchor, spin=0, orient=UP)
|
|||
l = first_defined([h, l, 1]);
|
||||
sides = segs(max(r1,r2));
|
||||
attachable(anchor,spin,orient, r1=r1, r2=r2, l=l) {
|
||||
if(r1>r2) {
|
||||
linear_extrude(height=l, center=true, convexity=2, scale=r2/r1) {
|
||||
circle(r=r1);
|
||||
if (r1 > r2) {
|
||||
if (l > 0) {
|
||||
linear_extrude(height=l, center=true, convexity=2, scale=r2/r1) {
|
||||
circle(r=r1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
zflip() {
|
||||
linear_extrude(height=l, center=true, convexity=2, scale=r1/r2) {
|
||||
circle(r=r2);
|
||||
if (l > 0) {
|
||||
linear_extrude(height=l, center=true, convexity=2, scale=r1/r2) {
|
||||
circle(r=r2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
26
shapes.scad
26
shapes.scad
|
@ -512,8 +512,10 @@ module right_triangle(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
|
|||
size = scalar_vec3(size);
|
||||
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG);
|
||||
attachable(anchor,spin,orient, size=size) {
|
||||
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]]);
|
||||
if (size.z > 0) {
|
||||
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]]);
|
||||
}
|
||||
}
|
||||
children();
|
||||
}
|
||||
|
@ -1395,8 +1397,10 @@ module teardrop(r=undef, d=undef, l=undef, h=undef, ang=45, cap_h=undef, anchor=
|
|||
size = [r*2,l,r*2];
|
||||
attachable(anchor,spin,orient, size=size) {
|
||||
rot(from=UP,to=FWD) {
|
||||
linear_extrude(height=l, center=true, slices=2) {
|
||||
teardrop2d(r=r, ang=ang, cap_h=cap_h);
|
||||
if (l > 0) {
|
||||
linear_extrude(height=l, center=true, slices=2) {
|
||||
teardrop2d(r=r, ang=ang, cap_h=cap_h);
|
||||
}
|
||||
}
|
||||
}
|
||||
children();
|
||||
|
@ -1567,12 +1571,14 @@ module interior_fillet(l=1.0, r, ang=90, overlap=0.01, d, anchor=FRONT+LEFT, spi
|
|||
steps = ceil(segs(r)*ang/360);
|
||||
step = ang/steps;
|
||||
attachable(anchor,spin,orient, size=[r,r,l]) {
|
||||
linear_extrude(height=l, convexity=4, center=true) {
|
||||
path = concat(
|
||||
[[0,0]],
|
||||
[for (i=[0:1:steps]) let(a=270-i*step) r*[cos(a),sin(a)]+[dy,r]]
|
||||
);
|
||||
translate(-[r,r]/2) polygon(path);
|
||||
if (l > 0) {
|
||||
linear_extrude(height=l, convexity=4, center=true) {
|
||||
path = concat(
|
||||
[[0,0]],
|
||||
[for (i=[0:1:steps]) let(a=270-i*step) r*[cos(a),sin(a)]+[dy,r]]
|
||||
);
|
||||
translate(-[r,r]/2) polygon(path);
|
||||
}
|
||||
}
|
||||
children();
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ module stroke(
|
|||
}
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ module stroke(
|
|||
}
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
BOSL_VERSION = [2,0,470];
|
||||
BOSL_VERSION = [2,0,471];
|
||||
|
||||
|
||||
// Section: BOSL Library Version Functions
|
||||
|
|
Loading…
Reference in a new issue