mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Added axis= to attachable() and reorient().
This commit is contained in:
parent
4f3baccec7
commit
5bfd3bee4d
2 changed files with 132 additions and 34 deletions
164
attachments.scad
164
attachments.scad
|
@ -104,14 +104,21 @@ function anchorpt(name, pos=[0,0,0], orient=UP, spin=0) = [name, pos, orient, sp
|
||||||
|
|
||||||
// Function: attach_geom()
|
// Function: attach_geom()
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage: Square/Trapezoid Geometry
|
||||||
// geom = attach_geom(anchor, spin, [orient], two_d, size, [size2], [shift], [cp], [offset], [anchors]);
|
// geom = attach_geom(anchor, spin, [orient], two_d, size, [size2], [shift], [cp], [offset], [anchors]);
|
||||||
|
// Usage: Circle/Oval Geometry
|
||||||
// geom = attach_geom(anchor, spin, [orient], two_d, r|d, [cp], [offset], [anchors]);
|
// geom = attach_geom(anchor, spin, [orient], two_d, r|d, [cp], [offset], [anchors]);
|
||||||
|
// Usage: 2D Path/Polygon Geometry
|
||||||
// geom = attach_geom(anchor, spin, [orient], two_d, path, [extent], [cp], [offset], [anchors]);
|
// geom = attach_geom(anchor, spin, [orient], two_d, path, [extent], [cp], [offset], [anchors]);
|
||||||
|
// Usage: Cubical/Prismoidal Geometry
|
||||||
// geom = attach_geom(anchor, spin, [orient], size, [size2], [shift], [cp], [offset], [anchors]);
|
// geom = attach_geom(anchor, spin, [orient], size, [size2], [shift], [cp], [offset], [anchors]);
|
||||||
// geom = attach_geom(anchor, spin, [orient], r|d, l, [cp], [offset], [anchors]);
|
// Usage: Cylindrical Geometry
|
||||||
// geom = attach_geom(anchor, spin, [orient], r1|d1, r2|d2, l, [cp], [offset], [anchors]);
|
// geom = attach_geom(anchor, spin, [orient], r|d, l, [cp], [axis], [offset], [anchors]);
|
||||||
|
// Usage: Conical Geometry
|
||||||
|
// geom = attach_geom(anchor, spin, [orient], r1|d1, r2|d2, l, [cp], [axis], [offset], [anchors]);
|
||||||
|
// Usage: Spheroid/Ovoid Geometry
|
||||||
// geom = attach_geom(anchor, spin, [orient], r|d, [cp], [offset], [anchors]);
|
// geom = attach_geom(anchor, spin, [orient], r|d, [cp], [offset], [anchors]);
|
||||||
|
// Usage: VNF Geometry
|
||||||
// geom = attach_geom(anchor, spin, [orient], vnf, [extent], [cp], [offset], [anchors]);
|
// geom = attach_geom(anchor, spin, [orient], vnf, [extent], [cp], [offset], [anchors]);
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -135,6 +142,7 @@ function anchorpt(name, pos=[0,0,0], orient=UP, spin=0) = [name, pos, orient, sp
|
||||||
// offset = If given, offsets the perimeter of the volume around the centerpoint.
|
// offset = If given, offsets the perimeter of the volume around the centerpoint.
|
||||||
// anchors = If given as a list of anchor points, allows named anchor points.
|
// anchors = If given as a list of anchor points, allows named anchor points.
|
||||||
// two_d = If true, the attachable shape is 2D. If false, 3D. Default: false (3D)
|
// two_d = If true, the attachable shape is 2D. If false, 3D. Default: false (3D)
|
||||||
|
// axis = The vector pointing along the axis of a cylinder geometry. Default: UP
|
||||||
//
|
//
|
||||||
// Example(NORENDER): Cubical Shape
|
// Example(NORENDER): Cubical Shape
|
||||||
// geom = attach_geom(anchor, spin, orient, size=size);
|
// geom = attach_geom(anchor, spin, orient, size=size);
|
||||||
|
@ -146,18 +154,36 @@ function anchorpt(name, pos=[0,0,0], orient=UP, spin=0) = [name, pos, orient, sp
|
||||||
// size2=topsize, shift=shift
|
// size2=topsize, shift=shift
|
||||||
// );
|
// );
|
||||||
//
|
//
|
||||||
// Example(NORENDER): Cylindrical Shape
|
// Example(NORENDER): Cylindrical Shape, Z-Axis Aligned
|
||||||
// geom = attach_geom(anchor, spin, orient, r=r, h=h);
|
// geom = attach_geom(anchor, spin, orient, r=r, h=h);
|
||||||
//
|
//
|
||||||
// Example(NORENDER): Conical Shape
|
// Example(NORENDER): Cylindrical Shape, Y-Axis Aligned
|
||||||
|
// geom = attach_geom(anchor, spin, orient, r=r, h=h, axis=BACK);
|
||||||
|
//
|
||||||
|
// Example(NORENDER): Cylindrical Shape, X-Axis Aligned
|
||||||
|
// geom = attach_geom(anchor, spin, orient, r=r, h=h, axis=RIGHT);
|
||||||
|
//
|
||||||
|
// Example(NORENDER): Conical Shape, Z-Axis Aligned
|
||||||
// geom = attach_geom(anchor, spin, orient, r1=r1, r2=r2, h=h);
|
// geom = attach_geom(anchor, spin, orient, r1=r1, r2=r2, h=h);
|
||||||
//
|
//
|
||||||
|
// Example(NORENDER): Conical Shape, Y-Axis Aligned
|
||||||
|
// geom = attach_geom(anchor, spin, orient, r1=r1, r2=r2, h=h, axis=BACK);
|
||||||
|
//
|
||||||
|
// Example(NORENDER): Conical Shape, X-Axis Aligned
|
||||||
|
// geom = attach_geom(anchor, spin, orient, r1=r1, r2=r2, h=h, axis=RIGHT);
|
||||||
|
//
|
||||||
// Example(NORENDER): Spherical Shape
|
// Example(NORENDER): Spherical Shape
|
||||||
// geom = attach_geom(anchor, spin, orient, r=r);
|
// geom = attach_geom(anchor, spin, orient, r=r);
|
||||||
//
|
//
|
||||||
// Example(NORENDER): Arbitrary VNF Shape
|
// Example(NORENDER): Ovoid Shape
|
||||||
|
// geom = attach_geom(anchor, spin, orient, r=[r_x, r_y, r_z]);
|
||||||
|
//
|
||||||
|
// Example(NORENDER): Arbitrary VNF Shape, Anchored by Extents
|
||||||
// geom = attach_geom(anchor, spin, orient, vnf=vnf);
|
// geom = attach_geom(anchor, spin, orient, vnf=vnf);
|
||||||
//
|
//
|
||||||
|
// Example(NORENDER): Arbitrary VNF Shape, Anchored by Intersection
|
||||||
|
// geom = attach_geom(anchor, spin, orient, vnf=vnf, extent=false);
|
||||||
|
//
|
||||||
// Example(NORENDER): 2D Rectangular Shape
|
// Example(NORENDER): 2D Rectangular Shape
|
||||||
// geom = attach_geom(anchor, spin, orient, size=size);
|
// geom = attach_geom(anchor, spin, orient, size=size);
|
||||||
//
|
//
|
||||||
|
@ -170,9 +196,15 @@ function anchorpt(name, pos=[0,0,0], orient=UP, spin=0) = [name, pos, orient, sp
|
||||||
// Example(NORENDER): 2D Circular Shape
|
// Example(NORENDER): 2D Circular Shape
|
||||||
// geom = attach_geom(anchor, spin, orient, two_d=true, r=r);
|
// geom = attach_geom(anchor, spin, orient, two_d=true, r=r);
|
||||||
//
|
//
|
||||||
// Example(NORENDER): Arbitrary 2D Polygon Shape
|
// Example(NORENDER): 2D Oval Shape
|
||||||
|
// geom = attach_geom(anchor, spin, orient, two_d=true, r=[r_x, r_y]);
|
||||||
|
//
|
||||||
|
// Example(NORENDER): Arbitrary 2D Polygon Shape, Anchored by Extents
|
||||||
// geom = attach_geom(anchor, spin, orient, path=path);
|
// geom = attach_geom(anchor, spin, orient, path=path);
|
||||||
//
|
//
|
||||||
|
// Example(NORENDER): Arbitrary 2D Polygon Shape, Anchored by Intersection
|
||||||
|
// geom = attach_geom(anchor, spin, orient, path=path, extent=false);
|
||||||
|
//
|
||||||
function attach_geom(
|
function attach_geom(
|
||||||
size, size2, shift,
|
size, size2, shift,
|
||||||
r,r1,r2, d,d1,d2, l,h,
|
r,r1,r2, d,d1,d2, l,h,
|
||||||
|
@ -181,13 +213,15 @@ function attach_geom(
|
||||||
cp=[0,0,0],
|
cp=[0,0,0],
|
||||||
offset=[0,0,0],
|
offset=[0,0,0],
|
||||||
anchors=[],
|
anchors=[],
|
||||||
two_d=false
|
two_d=false,
|
||||||
|
axis=UP
|
||||||
) =
|
) =
|
||||||
assert(is_bool(extent))
|
assert(is_bool(extent))
|
||||||
assert(is_vector(cp))
|
assert(is_vector(cp))
|
||||||
assert(is_vector(offset))
|
assert(is_vector(offset))
|
||||||
assert(is_list(anchors))
|
assert(is_list(anchors))
|
||||||
assert(is_bool(two_d))
|
assert(is_bool(two_d))
|
||||||
|
assert(is_vector(axis))
|
||||||
!is_undef(size)? (
|
!is_undef(size)? (
|
||||||
two_d? (
|
two_d? (
|
||||||
let(
|
let(
|
||||||
|
@ -233,7 +267,7 @@ function attach_geom(
|
||||||
assert(is_num(r2) || is_vector(r2,2))
|
assert(is_num(r2) || is_vector(r2,2))
|
||||||
assert(is_num(l))
|
assert(is_num(l))
|
||||||
assert(is_vector(shift,2))
|
assert(is_vector(shift,2))
|
||||||
["cyl", r1, r2, l, shift, cp, offset, anchors]
|
["cyl", r1, r2, l, shift, axis, cp, offset, anchors]
|
||||||
) : (
|
) : (
|
||||||
two_d? (
|
two_d? (
|
||||||
assert(is_num(r1) || is_vector(r1,2))
|
assert(is_num(r1) || is_vector(r1,2))
|
||||||
|
@ -275,14 +309,19 @@ function attach_geom_size(geom) =
|
||||||
) [maxx, maxy, z]
|
) [maxx, maxy, z]
|
||||||
) : type == "cyl"? ( //r1, r2, l, shift
|
) : type == "cyl"? ( //r1, r2, l, shift
|
||||||
let(
|
let(
|
||||||
r1=geom[1], r2=geom[2], l=geom[3], shift=point2d(geom[4]),
|
r1=geom[1], r2=geom[2], l=geom[3],
|
||||||
|
shift=point2d(geom[4]), axis=point3d(geom[5]),
|
||||||
rx1 = default(r1[0],r1),
|
rx1 = default(r1[0],r1),
|
||||||
ry1 = default(r1[1],r1),
|
ry1 = default(r1[1],r1),
|
||||||
rx2 = default(r2[0],r2),
|
rx2 = default(r2[0],r2),
|
||||||
ry2 = default(r2[1],r2),
|
ry2 = default(r2[1],r2),
|
||||||
maxxr = max(rx1,rx2),
|
maxxr = max(rx1,rx2),
|
||||||
maxyr = max(ry1,ry2)
|
maxyr = max(ry1,ry2)
|
||||||
) [2*maxxr,2*maxyr,l]
|
)
|
||||||
|
approx(axis,UP)? [2*maxxr,2*maxyr,l] :
|
||||||
|
approx(axis,RIGHT)? [l,2*maxyr,2*maxxr] :
|
||||||
|
approx(axis,BACK)? [2*maxxr,l,2*maxyr] :
|
||||||
|
[2*maxxr, 2*maxyr,l]
|
||||||
) : type == "spheroid"? ( //r
|
) : type == "spheroid"? ( //r
|
||||||
let( r=geom[1] )
|
let( r=geom[1] )
|
||||||
is_num(r)? [2,2,2]*r : vmul([2,2,2],point3d(r))
|
is_num(r)? [2,2,2]*r : vmul([2,2,2],point3d(r))
|
||||||
|
@ -429,21 +468,25 @@ function find_anchor(anchor, geom) =
|
||||||
) [anchor, pos, vec, oang]
|
) [anchor, pos, vec, oang]
|
||||||
) : type == "cyl"? ( //r1, r2, l, shift
|
) : type == "cyl"? ( //r1, r2, l, shift
|
||||||
let(
|
let(
|
||||||
rr1=geom[1], rr2=geom[2], l=geom[3], shift=point2d(geom[4]),
|
rr1=geom[1], rr2=geom[2], l=geom[3],
|
||||||
|
shift=point2d(geom[4]), axis=point3d(geom[5]),
|
||||||
r1 = is_num(rr1)? [rr1,rr1] : point2d(rr1),
|
r1 = is_num(rr1)? [rr1,rr1] : point2d(rr1),
|
||||||
r2 = is_num(rr2)? [rr2,rr2] : point2d(rr2),
|
r2 = is_num(rr2)? [rr2,rr2] : point2d(rr2),
|
||||||
u = (anchor.z+1)/2,
|
anch = rot(from=axis, to=UP, p=anchor),
|
||||||
axy = unit(point2d(anchor),[0,0]),
|
u = (anch.z+1)/2,
|
||||||
|
axy = unit(point2d(anch),[0,0]),
|
||||||
bot = point3d(vmul(r1,axy), -l/2),
|
bot = point3d(vmul(r1,axy), -l/2),
|
||||||
top = point3d(vmul(r2,axy)+shift, l/2),
|
top = point3d(vmul(r2,axy)+shift, l/2),
|
||||||
pos = point3d(cp) + lerp(bot,top,u) + offset,
|
pos = point3d(cp) + lerp(bot,top,u) + offset,
|
||||||
sidevec = rot(from=UP, to=top-bot, p=point3d(axy)),
|
sidevec = rot(from=UP, to=top-bot, p=point3d(axy)),
|
||||||
vvec = anchor==CENTER? UP : unit([0,0,anchor.z],UP),
|
vvec = anch==CENTER? UP : unit([0,0,anch.z],UP),
|
||||||
vec = anchor==CENTER? UP :
|
vec = anch==CENTER? UP :
|
||||||
approx(axy,[0,0])? unit(anchor,UP) :
|
approx(axy,[0,0])? unit(anch,UP) :
|
||||||
approx(anchor.z,0)? sidevec :
|
approx(anch.z,0)? sidevec :
|
||||||
unit((sidevec+vvec)/2,UP)
|
unit((sidevec+vvec)/2,UP),
|
||||||
) [anchor, pos, vec, oang]
|
pos2 = rot(from=UP, to=axis, p=pos),
|
||||||
|
vec2 = rot(from=UP, to=axis, p=vec)
|
||||||
|
) [anchor, pos2, vec2, oang]
|
||||||
) : type == "spheroid"? ( //r
|
) : type == "spheroid"? ( //r
|
||||||
let(
|
let(
|
||||||
rr = geom[1],
|
rr = geom[1],
|
||||||
|
@ -585,14 +628,21 @@ function attachment_is_shown(tags) =
|
||||||
|
|
||||||
// Function: reorient()
|
// Function: reorient()
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage: Square/Trapezoid Geometry
|
||||||
// reorient(anchor, spin, [orient], two_d, size, [size2], [shift], [cp], [offset], [anchors], [p]);
|
// reorient(anchor, spin, [orient], two_d, size, [size2], [shift], [cp], [offset], [anchors], [p]);
|
||||||
|
// Usage: Circle/Oval Geometry
|
||||||
// reorient(anchor, spin, [orient], two_d, r|d, [cp], [offset], [anchors], [p]);
|
// reorient(anchor, spin, [orient], two_d, r|d, [cp], [offset], [anchors], [p]);
|
||||||
|
// Usage: 2D Path/Polygon Geometry
|
||||||
// reorient(anchor, spin, [orient], two_d, path, [extent], [cp], [offset], [anchors], [p]);
|
// reorient(anchor, spin, [orient], two_d, path, [extent], [cp], [offset], [anchors], [p]);
|
||||||
|
// Usage: Cubical/Prismoidal Geometry
|
||||||
// reorient(anchor, spin, [orient], size, [size2], [shift], [cp], [offset], [anchors], [p]);
|
// reorient(anchor, spin, [orient], size, [size2], [shift], [cp], [offset], [anchors], [p]);
|
||||||
// reorient(anchor, spin, [orient], r|d, l, [offset], [cp], [anchors], [p]);
|
// Usage: Cylindrical Geometry
|
||||||
// reorient(anchor, spin, [orient], r1|d1, r2|d2, l, [cp], [offset], [anchors], [p]);
|
// reorient(anchor, spin, [orient], r|d, l, [offset], [axis], [cp], [anchors], [p]);
|
||||||
|
// Usage: Conical Geometry
|
||||||
|
// reorient(anchor, spin, [orient], r1|d1, r2|d2, l, [axis], [cp], [offset], [anchors], [p]);
|
||||||
|
// Usage: Spheroid/Ovoid Geometry
|
||||||
// reorient(anchor, spin, [orient], r|d, [cp], [offset], [anchors], [p]);
|
// reorient(anchor, spin, [orient], r|d, [cp], [offset], [anchors], [p]);
|
||||||
|
// Usage: VNF Geometry
|
||||||
// reorient(anchor, spin, [orient], vnf, [extent], [cp], [offset], [anchors], [p]);
|
// reorient(anchor, spin, [orient], vnf, [extent], [cp], [offset], [anchors], [p]);
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -638,6 +688,7 @@ function attachment_is_shown(tags) =
|
||||||
// offset = If given, offsets the perimeter of the volume around the centerpoint.
|
// offset = If given, offsets the perimeter of the volume around the centerpoint.
|
||||||
// anchors = If given as a list of anchor points, allows named anchor points.
|
// anchors = If given as a list of anchor points, allows named anchor points.
|
||||||
// two_d = If true, the attachable shape is 2D. If false, 3D. Default: false (3D)
|
// two_d = If true, the attachable shape is 2D. If false, 3D. Default: false (3D)
|
||||||
|
// axis = The vector pointing along the axis of a cylinder geometry. Default: UP
|
||||||
// p = The VNF, path, or point to transform.
|
// p = The VNF, path, or point to transform.
|
||||||
function reorient(
|
function reorient(
|
||||||
anchor=CENTER,
|
anchor=CENTER,
|
||||||
|
@ -651,6 +702,7 @@ function reorient(
|
||||||
cp=[0,0,0],
|
cp=[0,0,0],
|
||||||
anchors=[],
|
anchors=[],
|
||||||
two_d=false,
|
two_d=false,
|
||||||
|
axis=UP,
|
||||||
p=undef
|
p=undef
|
||||||
) = (anchor==CENTER && spin==0 && orient==UP && p!=undef)? p : let(
|
) = (anchor==CENTER && spin==0 && orient==UP && p!=undef)? p : let(
|
||||||
geom = attach_geom(
|
geom = attach_geom(
|
||||||
|
@ -659,7 +711,7 @@ function reorient(
|
||||||
d=d, d1=d1, d2=d2, l=l,
|
d=d, d1=d1, d2=d2, l=l,
|
||||||
vnf=vnf, path=path, extent=extent,
|
vnf=vnf, path=path, extent=extent,
|
||||||
cp=cp, offset=offset, anchors=anchors,
|
cp=cp, offset=offset, anchors=anchors,
|
||||||
two_d=two_d
|
two_d=two_d, axis=axis
|
||||||
),
|
),
|
||||||
$attach_to = undef
|
$attach_to = undef
|
||||||
) attach_transform(anchor,spin,orient,geom,p);
|
) attach_transform(anchor,spin,orient,geom,p);
|
||||||
|
@ -670,14 +722,21 @@ function reorient(
|
||||||
|
|
||||||
// Module: attachable()
|
// Module: attachable()
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage: Square/Trapezoid Geometry
|
||||||
// attachable(anchor, spin, [orient], two_d, size, [size2], [shift], [cp], [offset], [anchors] ...
|
// attachable(anchor, spin, [orient], two_d, size, [size2], [shift], [cp], [offset], [anchors] ...
|
||||||
|
// Usage: Circle/Oval Geometry
|
||||||
// attachable(anchor, spin, [orient], two_d, r|d, [cp], [offset], [anchors]) ...
|
// attachable(anchor, spin, [orient], two_d, r|d, [cp], [offset], [anchors]) ...
|
||||||
|
// Usage: 2D Path/Polygon Geometry
|
||||||
// attachable(anchor, spin, [orient], two_d, path, [extent], [cp], [offset], [anchors] ...
|
// attachable(anchor, spin, [orient], two_d, path, [extent], [cp], [offset], [anchors] ...
|
||||||
|
// Usage: Cubical/Prismoidal Geometry
|
||||||
// attachable(anchor, spin, [orient], size, [size2], [shift], [cp], [offset], [anchors] ...
|
// attachable(anchor, spin, [orient], size, [size2], [shift], [cp], [offset], [anchors] ...
|
||||||
// attachable(anchor, spin, [orient], r|d, l, [cp], [offset], [anchors]) ...
|
// Usage: Cylindrical Geometry
|
||||||
// attachable(anchor, spin, [orient], r1|d1, r2|d2, l, [cp], [offset], [anchors]) ...
|
// attachable(anchor, spin, [orient], r|d, l, [axis], [cp], [offset], [anchors]) ...
|
||||||
|
// Usage: Conical Geometry
|
||||||
|
// attachable(anchor, spin, [orient], r1|d1, r2|d2, l, [axis], [cp], [offset], [anchors]) ...
|
||||||
|
// Usage: Spheroid/Ovoid Geometry
|
||||||
// attachable(anchor, spin, [orient], r|d, [cp], [offset], [anchors]) ...
|
// attachable(anchor, spin, [orient], r|d, [cp], [offset], [anchors]) ...
|
||||||
|
// Usage: VNF Geometry
|
||||||
// attachable(anchor, spin, [orient], vnf, [extent], [cp], [offset], [anchors]) ...
|
// attachable(anchor, spin, [orient], vnf, [extent], [cp], [offset], [anchors]) ...
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -728,6 +787,7 @@ function reorient(
|
||||||
// offset = If given, offsets the perimeter of the volume around the centerpoint.
|
// offset = If given, offsets the perimeter of the volume around the centerpoint.
|
||||||
// anchors = If given as a list of anchor points, allows named anchor points.
|
// anchors = If given as a list of anchor points, allows named anchor points.
|
||||||
// two_d = If true, the attachable shape is 2D. If false, 3D. Default: false (3D)
|
// two_d = If true, the attachable shape is 2D. If false, 3D. Default: false (3D)
|
||||||
|
// axis = The vector pointing along the axis of a cylinder geometry. Default: UP
|
||||||
//
|
//
|
||||||
// Side Effects:
|
// Side Effects:
|
||||||
// `$parent_anchor` is set to the parent object's `anchor` value.
|
// `$parent_anchor` is set to the parent object's `anchor` value.
|
||||||
|
@ -753,18 +813,42 @@ function reorient(
|
||||||
// children();
|
// children();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Example(NORENDER): Cylindrical Shape
|
// Example(NORENDER): Cylindrical Shape, Z-Axis Aligned
|
||||||
// attachable(anchor, spin, orient, r=r, l=h) {
|
// attachable(anchor, spin, orient, r=r, l=h) {
|
||||||
// cyl(r=r, l=h);
|
// cyl(r=r, l=h);
|
||||||
// children();
|
// children();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Example(NORENDER): Conical Shape
|
// Example(NORENDER): Cylindrical Shape, Y-Axis Aligned
|
||||||
|
// attachable(anchor, spin, orient, r=r, l=h, axis=BACK) {
|
||||||
|
// cyl(r=r, l=h);
|
||||||
|
// children();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example(NORENDER): Cylindrical Shape, X-Axis Aligned
|
||||||
|
// attachable(anchor, spin, orient, r=r, l=h, axis=RIGHT) {
|
||||||
|
// cyl(r=r, l=h);
|
||||||
|
// children();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example(NORENDER): Conical Shape, Z-Axis Aligned
|
||||||
// attachable(anchor, spin, orient, r1=r1, r2=r2, l=h) {
|
// attachable(anchor, spin, orient, r1=r1, r2=r2, l=h) {
|
||||||
// cyl(r1=r1, r2=r2, l=h);
|
// cyl(r1=r1, r2=r2, l=h);
|
||||||
// children();
|
// children();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
// Example(NORENDER): Conical Shape, Y-Axis Aligned
|
||||||
|
// attachable(anchor, spin, orient, r1=r1, r2=r2, l=h, axis=BACK) {
|
||||||
|
// cyl(r1=r1, r2=r2, l=h);
|
||||||
|
// children();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example(NORENDER): Conical Shape, X-Axis Aligned
|
||||||
|
// attachable(anchor, spin, orient, r1=r1, r2=r2, l=h, axis=RIGHT) {
|
||||||
|
// cyl(r1=r1, r2=r2, l=h);
|
||||||
|
// children();
|
||||||
|
// }
|
||||||
|
//
|
||||||
// Example(NORENDER): Spherical Shape
|
// Example(NORENDER): Spherical Shape
|
||||||
// attachable(anchor, spin, orient, r=r) {
|
// attachable(anchor, spin, orient, r=r) {
|
||||||
// sphere(r=r);
|
// sphere(r=r);
|
||||||
|
@ -816,7 +900,8 @@ module attachable(
|
||||||
cp=[0,0,0],
|
cp=[0,0,0],
|
||||||
offset=[0,0,0],
|
offset=[0,0,0],
|
||||||
anchors=[],
|
anchors=[],
|
||||||
two_d=false
|
two_d=false,
|
||||||
|
axis=UP
|
||||||
) {
|
) {
|
||||||
assert($children==2, "attachable() expects exactly two children; the shape to manage, and the union of all attachment candidates.");
|
assert($children==2, "attachable() expects exactly two children; the shape to manage, and the union of all attachment candidates.");
|
||||||
assert(!is_undef(anchor), str("anchor undefined in attachable(). Did you forget to set a default value for anchor in ", parent_module(1)));
|
assert(!is_undef(anchor), str("anchor undefined in attachable(). Did you forget to set a default value for anchor in ", parent_module(1)));
|
||||||
|
@ -828,7 +913,7 @@ module attachable(
|
||||||
d=d, d1=d1, d2=d2, l=l,
|
d=d, d1=d1, d2=d2, l=l,
|
||||||
vnf=vnf, path=path, extent=extent,
|
vnf=vnf, path=path, extent=extent,
|
||||||
cp=cp, offset=offset, anchors=anchors,
|
cp=cp, offset=offset, anchors=anchors,
|
||||||
two_d=two_d
|
two_d=two_d, axis=axis
|
||||||
);
|
);
|
||||||
m = attach_transform(anchor,spin,orient,geom);
|
m = attach_transform(anchor,spin,orient,geom);
|
||||||
multmatrix(m) {
|
multmatrix(m) {
|
||||||
|
@ -1142,13 +1227,26 @@ module corner_mask(corners=CORNERS_ALL, except=[]) {
|
||||||
// Usage:
|
// Usage:
|
||||||
// tags(tags) ...
|
// tags(tags) ...
|
||||||
// Description:
|
// Description:
|
||||||
// Marks all children with the given tags.
|
// Marks all children with the given tags, so that they will `hide()`/`show()`/`diff()` correctly.
|
||||||
|
// This is especially useful for working with children that are not attachment enhanced, such as:
|
||||||
|
// - `square()` (or use [`rect()`](shapes2d.scad#rect))
|
||||||
|
// - `circle()` (or use [`oval()`](shapes2d.scad#oval))
|
||||||
|
// - `polygon()`
|
||||||
|
// - `text()`
|
||||||
|
// - `projection()`
|
||||||
|
// - `polyhedron()` (or use [`vnf_polyhedron()`](vnf.scad#vnf_polyhedron))
|
||||||
|
// - `linear_extrude()` (or use [`linear_sweep()`](regions.scad#linear_sweep))
|
||||||
|
// - `rotate_extrude()`
|
||||||
|
// - `surface()`
|
||||||
|
// - `import()`
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// tags = String containing space delimited set of tags to apply.
|
// tags = String containing space delimited set of tags to apply.
|
||||||
module tags(tags)
|
module tags(tags)
|
||||||
{
|
{
|
||||||
$tags = tags;
|
$tags = tags;
|
||||||
children();
|
if(attachment_is_shown(tags)) {
|
||||||
|
children();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,423];
|
BOSL_VERSION = [2,0,424];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue