mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Fixed argument formatting issue in tube().
This commit is contained in:
parent
e0614732b6
commit
db460ea8d8
2 changed files with 162 additions and 162 deletions
322
shapes.scad
322
shapes.scad
|
@ -487,6 +487,166 @@ function prismoid(
|
|||
) reorient(anchor,spin,orient, size=[s1.x,s1.y,h], size2=s2, shift=shift, p=vnf);
|
||||
|
||||
|
||||
// Module: rect_tube()
|
||||
// Usage:
|
||||
// rect_tube(size, wall, h, [center]);
|
||||
// rect_tube(isize, wall, h, [center]);
|
||||
// rect_tube(size, isize, h, [center]);
|
||||
// rect_tube(size1, size2, wall, h, [center]);
|
||||
// rect_tube(isize1, isize2, wall, h, [center]);
|
||||
// rect_tube(size1, size2, isize1, isize2, h, [center]);
|
||||
// Description:
|
||||
// Creates a rectangular or prismoid tube with optional roundovers and/or chamfers.
|
||||
// You can only round or chamfer the vertical(ish) edges. For those edges, you can
|
||||
// specify rounding and/or chamferring per-edge, and for top and bottom, inside and
|
||||
// outside separately.
|
||||
// Note: if using chamfers or rounding, you **must** also include the hull.scad file:
|
||||
// ```
|
||||
// include <BOSL2/hull.scad>
|
||||
// ```
|
||||
// Arguments:
|
||||
// size = The outer [X,Y] size of the rectangular tube.
|
||||
// isize = The inner [X,Y] size of the rectangular tube.
|
||||
// h|l = The height or length of the rectangular tube. Default: 1
|
||||
// wall = The thickness of the rectangular tube wall.
|
||||
// size1 = The [X,Y] side of the outside of the bottom of the rectangular tube.
|
||||
// size2 = The [X,Y] side of the outside of the top of the rectangular tube.
|
||||
// isize1 = The [X,Y] side of the inside of the bottom of the rectangular tube.
|
||||
// isize2 = The [X,Y] side of the inside of the top of the rectangular tube.
|
||||
// rounding = The roundover radius for the outside edges of the rectangular tube.
|
||||
// rounding1 = The roundover radius for the outside bottom corner of the rectangular tube.
|
||||
// rounding2 = The roundover radius for the outside top corner of the rectangular tube.
|
||||
// chamfer = The chamfer size for the outside edges of the rectangular tube.
|
||||
// chamfer1 = The chamfer size for the outside bottom corner of the rectangular tube.
|
||||
// chamfer2 = The chamfer size for the outside top corner of the rectangular tube.
|
||||
// irounding = The roundover radius for the inside edges of the rectangular tube. Default: Same as `rounding`
|
||||
// irounding1 = The roundover radius for the inside bottom corner of the rectangular tube.
|
||||
// irounding2 = The roundover radius for the inside top corner of the rectangular tube.
|
||||
// ichamfer = The chamfer size for the inside edges of the rectangular tube. Default: Same as `chamfer`
|
||||
// ichamfer1 = The chamfer size for the inside bottom corner of the rectangular tube.
|
||||
// ichamfer2 = The chamfer size for the inside top corner of the rectangular tube.
|
||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `BOTTOM`
|
||||
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
||||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
||||
// Examples:
|
||||
// rect_tube(size=50, wall=5, h=30);
|
||||
// rect_tube(size=[100,60], wall=5, h=30);
|
||||
// rect_tube(isize=[60,80], wall=5, h=30);
|
||||
// rect_tube(size=[100,60], isize=[90,50], h=30);
|
||||
// rect_tube(size1=[100,60], size2=[70,40], wall=5, h=30);
|
||||
// rect_tube(size1=[100,60], size2=[70,40], isize1=[40,20], isize2=[65,35], h=15);
|
||||
// Example: Outer Rounding Only
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=5, rounding=10, irounding=0, h=30);
|
||||
// Example: Outer Chamfer Only
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=5, chamfer=5, ichamfer=0, h=30);
|
||||
// Example: Outer Rounding, Inner Chamfer
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=5, rounding=10, ichamfer=8, h=30);
|
||||
// Example: Inner Rounding, Outer Chamfer
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=5, chamfer=10, irounding=8, h=30);
|
||||
// Example: Gradiant Rounding
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size1=100, size2=80, wall=5, rounding1=10, rounding2=0, irounding1=8, irounding2=0, h=30);
|
||||
// Example: Per Corner Rounding
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=10, rounding=[0,5,10,15], irounding=0, h=30);
|
||||
// Example: Per Corner Chamfer
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=10, chamfer=[0,5,10,15], ichamfer=0, h=30);
|
||||
// Example: Mixing Chamfer and Rounding
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=10, chamfer=[0,5,0,10], ichamfer=0, rounding=[5,0,10,0], irounding=0, h=30);
|
||||
// Example: Really Mixing It Up
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(
|
||||
// size1=[100,80], size2=[80,60],
|
||||
// isize1=[50,30], isize2=[70,50], h=20,
|
||||
// chamfer1=[0,5,0,10], ichamfer1=[0,3,0,8],
|
||||
// chamfer2=[5,0,10,0], ichamfer2=[3,0,8,0],
|
||||
// rounding1=[5,0,10,0], irounding1=[3,0,8,0],
|
||||
// rounding2=[0,5,0,10], irounding2=[0,3,0,8]
|
||||
// );
|
||||
module rect_tube(
|
||||
size, isize,
|
||||
h, shift=[0,0], wall,
|
||||
size1, size2,
|
||||
isize1, isize2,
|
||||
rounding=0, rounding1, rounding2,
|
||||
irounding=0, irounding1, irounding2,
|
||||
chamfer=0, chamfer1, chamfer2,
|
||||
ichamfer=0, ichamfer1, ichamfer2,
|
||||
anchor, spin=0, orient=UP,
|
||||
center, l
|
||||
) {
|
||||
h = first_defined([h,l,1]);
|
||||
assert(is_num(h), "l or h argument required.");
|
||||
assert(is_vector(shift,2));
|
||||
s1 = is_num(size1)? [size1, size1] :
|
||||
is_vector(size1,2)? size1 :
|
||||
is_num(size)? [size, size] :
|
||||
is_vector(size,2)? size :
|
||||
undef;
|
||||
s2 = is_num(size2)? [size2, size2] :
|
||||
is_vector(size2,2)? size2 :
|
||||
is_num(size)? [size, size] :
|
||||
is_vector(size,2)? size :
|
||||
undef;
|
||||
is1 = is_num(isize1)? [isize1, isize1] :
|
||||
is_vector(isize1,2)? isize1 :
|
||||
is_num(isize)? [isize, isize] :
|
||||
is_vector(isize,2)? isize :
|
||||
undef;
|
||||
is2 = is_num(isize2)? [isize2, isize2] :
|
||||
is_vector(isize2,2)? isize2 :
|
||||
is_num(isize)? [isize, isize] :
|
||||
is_vector(isize,2)? isize :
|
||||
undef;
|
||||
size1 = is_def(s1)? s1 :
|
||||
(is_def(wall) && is_def(is1))? (is1+2*[wall,wall]) :
|
||||
undef;
|
||||
size2 = is_def(s2)? s2 :
|
||||
(is_def(wall) && is_def(is2))? (is2+2*[wall,wall]) :
|
||||
undef;
|
||||
isize1 = is_def(is1)? is1 :
|
||||
(is_def(wall) && is_def(s1))? (s1-2*[wall,wall]) :
|
||||
undef;
|
||||
isize2 = is_def(is2)? is2 :
|
||||
(is_def(wall) && is_def(s2))? (s2-2*[wall,wall]) :
|
||||
undef;
|
||||
assert(wall==undef || is_num(wall));
|
||||
assert(size1!=undef, "Bad size/size1 argument.");
|
||||
assert(size2!=undef, "Bad size/size2 argument.");
|
||||
assert(isize1!=undef, "Bad isize/isize1 argument.");
|
||||
assert(isize2!=undef, "Bad isize/isize2 argument.");
|
||||
assert(isize1.x < size1.x, "Inner size is larger than outer size.");
|
||||
assert(isize1.y < size1.y, "Inner size is larger than outer size.");
|
||||
assert(isize2.x < size2.x, "Inner size is larger than outer size.");
|
||||
assert(isize2.y < size2.y, "Inner size is larger than outer size.");
|
||||
anchor = get_anchor(anchor, center, BOT, BOT);
|
||||
attachable(anchor,spin,orient, size=[each size1, h], size2=size2, shift=shift) {
|
||||
diff("_H_o_L_e_")
|
||||
prismoid(
|
||||
size1, size2, h=h, shift=shift,
|
||||
rounding=rounding, rounding1=rounding1, rounding2=rounding2,
|
||||
chamfer=chamfer, chamfer1=chamfer1, chamfer2=chamfer2,
|
||||
anchor=CTR
|
||||
) {
|
||||
children();
|
||||
tags("_H_o_L_e_") prismoid(
|
||||
isize1, isize2, h=h+0.05, shift=shift,
|
||||
rounding=irounding, rounding1=irounding1, rounding2=irounding2,
|
||||
chamfer=ichamfer, chamfer1=ichamfer1, chamfer2=ichamfer2,
|
||||
anchor=CTR
|
||||
);
|
||||
}
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Module: right_triangle()
|
||||
//
|
||||
// Usage:
|
||||
|
@ -859,7 +1019,7 @@ module zcyl(l=undef, r=undef, d=undef, r1=undef, r2=undef, d1=undef, d2=undef, h
|
|||
// tube(h|l, ir1|id1, ir2|id2, or1|od1, or2|od2, [realign]);
|
||||
//
|
||||
// Arguments:
|
||||
// h|l = height of tube. (Default: 1)
|
||||
// h / l = height of tube. (Default: 1)
|
||||
// or = Outer radius of tube.
|
||||
// or1 = Outer radius of bottom of tube. (Default: value of r)
|
||||
// or2 = Outer radius of top of tube. (Default: value of r)
|
||||
|
@ -936,166 +1096,6 @@ module tube(
|
|||
}
|
||||
|
||||
|
||||
// Module: rect_tube()
|
||||
// Usage:
|
||||
// rect_tube(size, wall, h, [center]);
|
||||
// rect_tube(isize, wall, h, [center]);
|
||||
// rect_tube(size, isize, h, [center]);
|
||||
// rect_tube(size1, size2, wall, h, [center]);
|
||||
// rect_tube(isize1, isize2, wall, h, [center]);
|
||||
// rect_tube(size1, size2, isize1, isize2, h, [center]);
|
||||
// Description:
|
||||
// Creates a rectangular or prismoid tube with optional roundovers and/or chamfers.
|
||||
// You can only round or chamfer the vertical(ish) edges. For those edges, you can
|
||||
// specify rounding and/or chamferring per-edge, and for top and bottom, inside and
|
||||
// outside separately.
|
||||
// Note: if using chamfers or rounding, you **must** also include the hull.scad file:
|
||||
// ```
|
||||
// include <BOSL2/hull.scad>
|
||||
// ```
|
||||
// Arguments:
|
||||
// size = The outer [X,Y] size of the rectangular tube.
|
||||
// isize = The inner [X,Y] size of the rectangular tube.
|
||||
// h|l = The height or length of the rectangular tube. Default: 1
|
||||
// wall = The thickness of the rectangular tube wall.
|
||||
// size1 = The [X,Y] side of the outside of the bottom of the rectangular tube.
|
||||
// size2 = The [X,Y] side of the outside of the top of the rectangular tube.
|
||||
// isize1 = The [X,Y] side of the inside of the bottom of the rectangular tube.
|
||||
// isize2 = The [X,Y] side of the inside of the top of the rectangular tube.
|
||||
// rounding = The roundover radius for the outside edges of the rectangular tube.
|
||||
// rounding1 = The roundover radius for the outside bottom corner of the rectangular tube.
|
||||
// rounding2 = The roundover radius for the outside top corner of the rectangular tube.
|
||||
// chamfer = The chamfer size for the outside edges of the rectangular tube.
|
||||
// chamfer1 = The chamfer size for the outside bottom corner of the rectangular tube.
|
||||
// chamfer2 = The chamfer size for the outside top corner of the rectangular tube.
|
||||
// irounding = The roundover radius for the inside edges of the rectangular tube. Default: Same as `rounding`
|
||||
// irounding1 = The roundover radius for the inside bottom corner of the rectangular tube.
|
||||
// irounding2 = The roundover radius for the inside top corner of the rectangular tube.
|
||||
// ichamfer = The chamfer size for the inside edges of the rectangular tube. Default: Same as `chamfer`
|
||||
// ichamfer1 = The chamfer size for the inside bottom corner of the rectangular tube.
|
||||
// ichamfer2 = The chamfer size for the inside top corner of the rectangular tube.
|
||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `BOTTOM`
|
||||
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
|
||||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
|
||||
// Examples:
|
||||
// rect_tube(size=50, wall=5, h=30);
|
||||
// rect_tube(size=[100,60], wall=5, h=30);
|
||||
// rect_tube(isize=[60,80], wall=5, h=30);
|
||||
// rect_tube(size=[100,60], isize=[90,50], h=30);
|
||||
// rect_tube(size1=[100,60], size2=[70,40], wall=5, h=30);
|
||||
// rect_tube(size1=[100,60], size2=[70,40], isize1=[40,20], isize2=[65,35], h=15);
|
||||
// Example: Outer Rounding Only
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=5, rounding=10, irounding=0, h=30);
|
||||
// Example: Outer Chamfer Only
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=5, chamfer=5, ichamfer=0, h=30);
|
||||
// Example: Outer Rounding, Inner Chamfer
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=5, rounding=10, ichamfer=8, h=30);
|
||||
// Example: Inner Rounding, Outer Chamfer
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=5, chamfer=10, irounding=8, h=30);
|
||||
// Example: Gradiant Rounding
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size1=100, size2=80, wall=5, rounding1=10, rounding2=0, irounding1=8, irounding2=0, h=30);
|
||||
// Example: Per Corner Rounding
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=10, rounding=[0,5,10,15], irounding=0, h=30);
|
||||
// Example: Per Corner Chamfer
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=10, chamfer=[0,5,10,15], ichamfer=0, h=30);
|
||||
// Example: Mixing Chamfer and Rounding
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(size=100, wall=10, chamfer=[0,5,0,10], ichamfer=0, rounding=[5,0,10,0], irounding=0, h=30);
|
||||
// Example: Really Mixing It Up
|
||||
// include <BOSL2/hull.scad>
|
||||
// rect_tube(
|
||||
// size1=[100,80], size2=[80,60],
|
||||
// isize1=[50,30], isize2=[70,50], h=20,
|
||||
// chamfer1=[0,5,0,10], ichamfer1=[0,3,0,8],
|
||||
// chamfer2=[5,0,10,0], ichamfer2=[3,0,8,0],
|
||||
// rounding1=[5,0,10,0], irounding1=[3,0,8,0],
|
||||
// rounding2=[0,5,0,10], irounding2=[0,3,0,8]
|
||||
// );
|
||||
module rect_tube(
|
||||
size, isize,
|
||||
h, shift=[0,0], wall,
|
||||
size1, size2,
|
||||
isize1, isize2,
|
||||
rounding=0, rounding1, rounding2,
|
||||
irounding=0, irounding1, irounding2,
|
||||
chamfer=0, chamfer1, chamfer2,
|
||||
ichamfer=0, ichamfer1, ichamfer2,
|
||||
anchor, spin=0, orient=UP,
|
||||
center, l
|
||||
) {
|
||||
h = first_defined([h,l,1]);
|
||||
assert(is_num(h), "l or h argument required.");
|
||||
assert(is_vector(shift,2));
|
||||
s1 = is_num(size1)? [size1, size1] :
|
||||
is_vector(size1,2)? size1 :
|
||||
is_num(size)? [size, size] :
|
||||
is_vector(size,2)? size :
|
||||
undef;
|
||||
s2 = is_num(size2)? [size2, size2] :
|
||||
is_vector(size2,2)? size2 :
|
||||
is_num(size)? [size, size] :
|
||||
is_vector(size,2)? size :
|
||||
undef;
|
||||
is1 = is_num(isize1)? [isize1, isize1] :
|
||||
is_vector(isize1,2)? isize1 :
|
||||
is_num(isize)? [isize, isize] :
|
||||
is_vector(isize,2)? isize :
|
||||
undef;
|
||||
is2 = is_num(isize2)? [isize2, isize2] :
|
||||
is_vector(isize2,2)? isize2 :
|
||||
is_num(isize)? [isize, isize] :
|
||||
is_vector(isize,2)? isize :
|
||||
undef;
|
||||
size1 = is_def(s1)? s1 :
|
||||
(is_def(wall) && is_def(is1))? (is1+2*[wall,wall]) :
|
||||
undef;
|
||||
size2 = is_def(s2)? s2 :
|
||||
(is_def(wall) && is_def(is2))? (is2+2*[wall,wall]) :
|
||||
undef;
|
||||
isize1 = is_def(is1)? is1 :
|
||||
(is_def(wall) && is_def(s1))? (s1-2*[wall,wall]) :
|
||||
undef;
|
||||
isize2 = is_def(is2)? is2 :
|
||||
(is_def(wall) && is_def(s2))? (s2-2*[wall,wall]) :
|
||||
undef;
|
||||
assert(wall==undef || is_num(wall));
|
||||
assert(size1!=undef, "Bad size/size1 argument.");
|
||||
assert(size2!=undef, "Bad size/size2 argument.");
|
||||
assert(isize1!=undef, "Bad isize/isize1 argument.");
|
||||
assert(isize2!=undef, "Bad isize/isize2 argument.");
|
||||
assert(isize1.x < size1.x, "Inner size is larger than outer size.");
|
||||
assert(isize1.y < size1.y, "Inner size is larger than outer size.");
|
||||
assert(isize2.x < size2.x, "Inner size is larger than outer size.");
|
||||
assert(isize2.y < size2.y, "Inner size is larger than outer size.");
|
||||
anchor = get_anchor(anchor, center, BOT, BOT);
|
||||
attachable(anchor,spin,orient, size=[each size1, h], size2=size2, shift=shift) {
|
||||
diff("_H_o_L_e_")
|
||||
prismoid(
|
||||
size1, size2, h=h, shift=shift,
|
||||
rounding=rounding, rounding1=rounding1, rounding2=rounding2,
|
||||
chamfer=chamfer, chamfer1=chamfer1, chamfer2=chamfer2,
|
||||
anchor=CTR
|
||||
) {
|
||||
children();
|
||||
tags("_H_o_L_e_") prismoid(
|
||||
isize1, isize2, h=h+0.05, shift=shift,
|
||||
rounding=irounding, rounding1=irounding1, rounding2=irounding2,
|
||||
chamfer=ichamfer, chamfer1=ichamfer1, chamfer2=ichamfer2,
|
||||
anchor=CTR
|
||||
);
|
||||
}
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Module: torus()
|
||||
//
|
||||
// Description:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
BOSL_VERSION = [2,0,512];
|
||||
BOSL_VERSION = [2,0,513];
|
||||
|
||||
|
||||
// Section: BOSL Library Version Functions
|
||||
|
|
Loading…
Reference in a new issue