mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Add $slop docs to modules that use $slop, fix stroke to accept
singletons, and fix cylinder to handle zero length case
This commit is contained in:
parent
eb286717ec
commit
21945263b6
8 changed files with 74 additions and 50 deletions
|
@ -2469,7 +2469,7 @@ function _find_anchor(anchor, geom) =
|
||||||
bot = point3d(v_mul(r1,axy), -l/2),
|
bot = point3d(v_mul(r1,axy), -l/2),
|
||||||
top = point3d(v_mul(r2,axy)+shift, l/2),
|
top = point3d(v_mul(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?UP:top-bot, p=point3d(axy)),
|
||||||
vvec = anch==CENTER? UP : unit([0,0,anch.z],UP),
|
vvec = anch==CENTER? UP : unit([0,0,anch.z],UP),
|
||||||
vec = anch==CENTER? CENTER :
|
vec = anch==CENTER? CENTER :
|
||||||
approx(axy,[0,0])? unit(anch,UP) :
|
approx(axy,[0,0])? unit(anch,UP) :
|
||||||
|
|
|
@ -105,7 +105,7 @@ module cubetruss_segment(size, strut, bracing, anchor=CENTER, spin=0, orient=UP)
|
||||||
|
|
||||||
// Module: cubetruss_support()
|
// Module: cubetruss_support()
|
||||||
// Usage:
|
// Usage:
|
||||||
// cubetruss_support([size], [strut]);
|
// cubetruss_support([size], [strut], [extents], [anchor], [spin], [orient]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a single cubetruss support.
|
// Creates a single cubetruss support.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -166,7 +166,7 @@ module cubetruss_support(size, strut, extents=1, anchor=CENTER, spin=0, orient=U
|
||||||
|
|
||||||
// Module: cubetruss_clip()
|
// Module: cubetruss_clip()
|
||||||
// Usage:
|
// Usage:
|
||||||
// cubetruss_clip(extents, [size], [strut], [clipthick]);
|
// cubetruss_clip(extents, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a pair of clips to add onto the end of a truss.
|
// Creates a pair of clips to add onto the end of a truss.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -175,6 +175,7 @@ module cubetruss_support(size, strut, extents=1, anchor=CENTER, spin=0, orient=U
|
||||||
// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3)
|
// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3)
|
||||||
// clipthick = The thickness of the clip. Default: `$cubetruss_clip_thickness` (usually 1.6)
|
// clipthick = The thickness of the clip. Default: `$cubetruss_clip_thickness` (usually 1.6)
|
||||||
// ---
|
// ---
|
||||||
|
// $slop = allowance for printer overextrusion
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
|
@ -230,7 +231,7 @@ module cubetruss_clip(extents=1, size, strut, clipthick, anchor=CENTER, spin=0,
|
||||||
|
|
||||||
// Module: cubetruss_foot()
|
// Module: cubetruss_foot()
|
||||||
// Usage:
|
// Usage:
|
||||||
// cubetruss_foot(w, [size], [strut], [clipthick]);
|
// cubetruss_foot(w, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a foot that can be clipped onto the bottom of a truss for support.
|
// Creates a foot that can be clipped onto the bottom of a truss for support.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -239,6 +240,7 @@ module cubetruss_clip(extents=1, size, strut, clipthick, anchor=CENTER, spin=0,
|
||||||
// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3)
|
// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3)
|
||||||
// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6)
|
// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6)
|
||||||
// ---
|
// ---
|
||||||
|
// $slop = make fit looser to allow for printer overextrusion
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
|
@ -306,7 +308,7 @@ module cubetruss_foot(w=1, size, strut, clipthick, anchor=CENTER, spin=0, orient
|
||||||
|
|
||||||
// Module: cubetruss_joiner()
|
// Module: cubetruss_joiner()
|
||||||
// Usage:
|
// Usage:
|
||||||
// cubetruss_joiner([w], [vert], [size], [strut], [clipthick]);
|
// cubetruss_joiner([w], [vert], [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a part to join two cubetruss trusses end-to-end.
|
// Creates a part to join two cubetruss trusses end-to-end.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -316,6 +318,7 @@ module cubetruss_foot(w=1, size, strut, clipthick, anchor=CENTER, spin=0, orient
|
||||||
// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3)
|
// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3)
|
||||||
// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6)
|
// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6)
|
||||||
// ---
|
// ---
|
||||||
|
// $slop = Make fit looser by this amount to allow for printer overextrusion
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
|
@ -373,7 +376,7 @@ module cubetruss_joiner(w=1, vert=true, size, strut, clipthick, anchor=CENTER, s
|
||||||
|
|
||||||
// Module: cubetruss_uclip()
|
// Module: cubetruss_uclip()
|
||||||
// Usage:
|
// Usage:
|
||||||
// cubetruss_uclip(dual, [size], [strut], [clipthick]);
|
// cubetruss_uclip(dual, [size], [strut], [clipthick], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a small clip that can snap around one or two adjacent struts.
|
// Creates a small clip that can snap around one or two adjacent struts.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -382,6 +385,7 @@ module cubetruss_joiner(w=1, vert=true, size, strut, clipthick, anchor=CENTER, s
|
||||||
// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3)
|
// strut = The width of the struts on the cubetruss cubes. Default: `$cubetruss_strut_size` (usually 3)
|
||||||
// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6)
|
// clipthick = The thickness of the clips. Default: `$cubetruss_clip_thickness` (usually 1.6)
|
||||||
// ---
|
// ---
|
||||||
|
// $slop = Make fit looser by this amount
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
|
|
75
drawing.scad
75
drawing.scad
|
@ -25,7 +25,10 @@
|
||||||
// Draws a 2D or 3D path with a given line width. Joints and each endcap can be replaced with
|
// Draws a 2D or 3D path with a given line width. Joints and each endcap can be replaced with
|
||||||
// various marker shapes, and can be assigned different colors. If passed a region instead of
|
// various marker shapes, and can be assigned different colors. If passed a region instead of
|
||||||
// a path, draws each path in the region as a closed polygon by default. If `closed=false` is
|
// a path, draws each path in the region as a closed polygon by default. If `closed=false` is
|
||||||
// given with a region, each subpath is drawn as an un-closed line path.
|
// given with a region or list of paths, then each path is drawn without the closing line segment.
|
||||||
|
// To facilitate debugging, stroke() accepts "paths" that have a single point. These are drawn with
|
||||||
|
// the style of endcap1, but have their own scale parameter, `singleton_scale`, which defaults to 2
|
||||||
|
// so that singleton dots with endcap "round" are clearly visible.
|
||||||
// Figure(Med,NoAxes,2D,VPR=[0,0,0],VPD=250): Endcap Types
|
// Figure(Med,NoAxes,2D,VPR=[0,0,0],VPD=250): Endcap Types
|
||||||
// cap_pairs = [
|
// cap_pairs = [
|
||||||
// ["butt", "chisel" ],
|
// ["butt", "chisel" ],
|
||||||
|
@ -84,6 +87,7 @@
|
||||||
// endcap_color2 = If given, sets the color of the ending endcap. Overrides `color=`, `dots_color=`, and `endcap_color=`.
|
// endcap_color2 = If given, sets the color of the ending endcap. Overrides `color=`, `dots_color=`, and `endcap_color=`.
|
||||||
// joint_color = If given, sets the color of the joints. Overrides `color=` and `dots_color=`.
|
// joint_color = If given, sets the color of the joints. Overrides `color=` and `dots_color=`.
|
||||||
// dots_color = If given, sets the color of the endcaps and joints. Overrides `color=`.
|
// dots_color = If given, sets the color of the endcaps and joints. Overrides `color=`.
|
||||||
|
// singleton_scale = Change the scale of the endcap shape drawn for singleton paths. Default: 2.
|
||||||
// convexity = Max number of times a line could intersect a wall of an endcap.
|
// convexity = Max number of times a line could intersect a wall of an endcap.
|
||||||
// Example(2D): Drawing a Path
|
// Example(2D): Drawing a Path
|
||||||
// path = [[0,100], [100,100], [200,0], [100,-100], [100,0]];
|
// path = [[0,100], [100,100], [200,0], [100,-100], [100,0]];
|
||||||
|
@ -100,7 +104,7 @@
|
||||||
// Example(2D): Mixed Endcaps
|
// Example(2D): Mixed Endcaps
|
||||||
// path = [[0,100], [100,100], [200,0], [100,-100], [100,0]];
|
// path = [[0,100], [100,100], [200,0], [100,-100], [100,0]];
|
||||||
// stroke(path, width=10, endcap1="tail2", endcap2="arrow2");
|
// stroke(path, width=10, endcap1="tail2", endcap2="arrow2");
|
||||||
// Example(2D): Plotting Points
|
// Example(2D): Plotting Points. Setting endcap_angle to zero results in the weird arrow orientation.
|
||||||
// path = [for (a=[0:30:360]) [a-180, 60*sin(a)]];
|
// path = [for (a=[0:30:360]) [a-180, 60*sin(a)]];
|
||||||
// stroke(path, width=3, joints="diamond", endcaps="arrow2", endcap_angle=0, endcap_width=5, joint_angle=0, joint_width=5);
|
// stroke(path, width=3, joints="diamond", endcaps="arrow2", endcap_angle=0, endcap_width=5, joint_angle=0, joint_width=5);
|
||||||
// Example(2D): Joints and Endcaps
|
// Example(2D): Joints and Endcaps
|
||||||
|
@ -147,6 +151,12 @@
|
||||||
// ]
|
// ]
|
||||||
// ];
|
// ];
|
||||||
// stroke(paths, closed=false, width=5);
|
// stroke(paths, closed=false, width=5);
|
||||||
|
// Example(2D): Paths with a singleton. Note that the singleton is not a single point, but a list containing a single point.
|
||||||
|
// stroke([
|
||||||
|
// [[0,0],[1,1]],
|
||||||
|
// [[1.5,1.5]],
|
||||||
|
// [[2,2],[3,3]]
|
||||||
|
// ],width=0.2,closed=false,$fn=16);
|
||||||
function stroke(
|
function stroke(
|
||||||
path, width=1, closed,
|
path, width=1, closed,
|
||||||
endcaps, endcap1, endcap2, joints, dots,
|
endcaps, endcap1, endcap2, joints, dots,
|
||||||
|
@ -155,7 +165,7 @@ function stroke(
|
||||||
endcap_extent, endcap_extent1, endcap_extent2, joint_extent, dots_extent,
|
endcap_extent, endcap_extent1, endcap_extent2, joint_extent, dots_extent,
|
||||||
endcap_angle, endcap_angle1, endcap_angle2, joint_angle, dots_angle,
|
endcap_angle, endcap_angle1, endcap_angle2, joint_angle, dots_angle,
|
||||||
endcap_color, endcap_color1, endcap_color2, joint_color, dots_color, color,
|
endcap_color, endcap_color1, endcap_color2, joint_color, dots_color, color,
|
||||||
trim, trim1, trim2,
|
trim, trim1, trim2, singleton_scale=2,
|
||||||
convexity=10
|
convexity=10
|
||||||
) = no_function("stroke");
|
) = no_function("stroke");
|
||||||
|
|
||||||
|
@ -168,7 +178,7 @@ module stroke(
|
||||||
endcap_extent, endcap_extent1, endcap_extent2, joint_extent, dots_extent,
|
endcap_extent, endcap_extent1, endcap_extent2, joint_extent, dots_extent,
|
||||||
endcap_angle, endcap_angle1, endcap_angle2, joint_angle, dots_angle,
|
endcap_angle, endcap_angle1, endcap_angle2, joint_angle, dots_angle,
|
||||||
endcap_color, endcap_color1, endcap_color2, joint_color, dots_color, color,
|
endcap_color, endcap_color1, endcap_color2, joint_color, dots_color, color,
|
||||||
trim, trim1, trim2,
|
trim, trim1, trim2, singleton_scale=2,
|
||||||
convexity=10
|
convexity=10
|
||||||
) {
|
) {
|
||||||
no_children($children);
|
no_children($children);
|
||||||
|
@ -201,8 +211,8 @@ module stroke(
|
||||||
assert(false, str("Invalid cap or joint: ",cap));
|
assert(false, str("Invalid cap or joint: ",cap));
|
||||||
|
|
||||||
function _shape_path(cap,linewidth,w,l,l2) = (
|
function _shape_path(cap,linewidth,w,l,l2) = (
|
||||||
(cap=="butt" || cap==false || cap==undef)? [] :
|
cap=="butt" || cap==false || cap==undef ? [] :
|
||||||
(cap=="round" || cap==true)? scale([w,l], p=circle(d=1, $fn=max(8, segs(w/2)))) :
|
cap=="round" || cap==true ? scale([w,l], p=circle(d=1, $fn=max(8, segs(w/2)))) :
|
||||||
cap=="chisel"? scale([w,l], p=circle(d=1,$fn=4)) :
|
cap=="chisel"? scale([w,l], p=circle(d=1,$fn=4)) :
|
||||||
cap=="diamond"? circle(d=w,$fn=4) :
|
cap=="diamond"? circle(d=w,$fn=4) :
|
||||||
cap=="square"? scale([w,l], p=square(1,center=true)) :
|
cap=="square"? scale([w,l], p=square(1,center=true)) :
|
||||||
|
@ -239,47 +249,47 @@ module stroke(
|
||||||
endcap_width1 = first_defined([endcap_width1, endcap_width, dots_width, endcap1_dflts[0]]);
|
endcap_width1 = first_defined([endcap_width1, endcap_width, dots_width, endcap1_dflts[0]]);
|
||||||
endcap_width2 = first_defined([endcap_width2, endcap_width, dots_width, endcap2_dflts[0]]);
|
endcap_width2 = first_defined([endcap_width2, endcap_width, dots_width, endcap2_dflts[0]]);
|
||||||
joint_width = first_defined([joint_width, dots_width, joint_dflts[0]]);
|
joint_width = first_defined([joint_width, dots_width, joint_dflts[0]]);
|
||||||
check3 =
|
|
||||||
assert(is_num(endcap_width1))
|
|
||||||
assert(is_num(endcap_width2))
|
|
||||||
assert(is_num(joint_width));
|
|
||||||
|
|
||||||
endcap_length1 = first_defined([endcap_length1, endcap_length, dots_length, endcap1_dflts[1]*endcap_width1]);
|
endcap_length1 = first_defined([endcap_length1, endcap_length, dots_length, endcap1_dflts[1]*endcap_width1]);
|
||||||
endcap_length2 = first_defined([endcap_length2, endcap_length, dots_length, endcap2_dflts[1]*endcap_width2]);
|
endcap_length2 = first_defined([endcap_length2, endcap_length, dots_length, endcap2_dflts[1]*endcap_width2]);
|
||||||
joint_length = first_defined([joint_length, dots_length, joint_dflts[1]*joint_width]);
|
joint_length = first_defined([joint_length, dots_length, joint_dflts[1]*joint_width]);
|
||||||
check4 =
|
|
||||||
assert(is_num(endcap_length1))
|
|
||||||
assert(is_num(endcap_length2))
|
|
||||||
assert(is_num(joint_length));
|
|
||||||
|
|
||||||
endcap_extent1 = first_defined([endcap_extent1, endcap_extent, dots_extent, endcap1_dflts[2]*endcap_width1]);
|
endcap_extent1 = first_defined([endcap_extent1, endcap_extent, dots_extent, endcap1_dflts[2]*endcap_width1]);
|
||||||
endcap_extent2 = first_defined([endcap_extent2, endcap_extent, dots_extent, endcap2_dflts[2]*endcap_width2]);
|
endcap_extent2 = first_defined([endcap_extent2, endcap_extent, dots_extent, endcap2_dflts[2]*endcap_width2]);
|
||||||
joint_extent = first_defined([joint_extent, dots_extent, joint_dflts[2]*joint_width]);
|
joint_extent = first_defined([joint_extent, dots_extent, joint_dflts[2]*joint_width]);
|
||||||
check5 =
|
|
||||||
assert(is_num(endcap_extent1))
|
|
||||||
assert(is_num(endcap_extent2))
|
|
||||||
assert(is_num(joint_extent));
|
|
||||||
|
|
||||||
endcap_angle1 = first_defined([endcap_angle1, endcap_angle, dots_angle]);
|
endcap_angle1 = first_defined([endcap_angle1, endcap_angle, dots_angle]);
|
||||||
endcap_angle2 = first_defined([endcap_angle2, endcap_angle, dots_angle]);
|
endcap_angle2 = first_defined([endcap_angle2, endcap_angle, dots_angle]);
|
||||||
joint_angle = first_defined([joint_angle, dots_angle]);
|
joint_angle = first_defined([joint_angle, dots_angle]);
|
||||||
check6 =
|
|
||||||
assert(is_undef(endcap_angle1)||is_num(endcap_angle1))
|
check3 =
|
||||||
assert(is_undef(endcap_angle2)||is_num(endcap_angle2))
|
assert(all_nonnegative([endcap_length1]))
|
||||||
assert(is_undef(joint_angle)||is_num(joint_angle));
|
assert(all_nonnegative([endcap_length2]))
|
||||||
|
assert(all_nonnegative([joint_length]));
|
||||||
|
assert(all_nonnegative([endcap_extent1]))
|
||||||
|
assert(all_nonnegative([endcap_extent2]))
|
||||||
|
assert(all_nonnegative([joint_extent]));
|
||||||
|
assert(is_undef(endcap_angle1)||is_finite(endcap_angle1))
|
||||||
|
assert(is_undef(endcap_angle2)||is_finite(endcap_angle2))
|
||||||
|
assert(is_undef(joint_angle)||is_finite(joint_angle))
|
||||||
|
assert(all_positive([singleton_scale]))
|
||||||
|
assert(all_positive(width));
|
||||||
|
|
||||||
endcap_color1 = first_defined([endcap_color1, endcap_color, dots_color, color]);
|
endcap_color1 = first_defined([endcap_color1, endcap_color, dots_color, color]);
|
||||||
endcap_color2 = first_defined([endcap_color2, endcap_color, dots_color, color]);
|
endcap_color2 = first_defined([endcap_color2, endcap_color, dots_color, color]);
|
||||||
joint_color = first_defined([joint_color, dots_color, color]);
|
joint_color = first_defined([joint_color, dots_color, color]);
|
||||||
paths = force_region(path);
|
|
||||||
check7 = assert(is_region(paths),"The path argument must be a list of 2D or 3D points, or a region.");
|
// We want to allow "paths" with length 1, so we can't use the normal path/region checks
|
||||||
|
paths = is_matrix(path) ? [path] : path;
|
||||||
|
assert(is_list(paths),"The path argument must be a list of 2D or 3D points, or a region.");
|
||||||
for (path = paths) {
|
for (path = paths) {
|
||||||
assert(len(path)==1 || is_path(path,[2,3]), "The path argument must be a list of 2D or 3D points, or a region.");
|
pathvalid = is_path(path,[2,3]) || same_shape(path,[[0,0]]) || same_shape(path,[[0,0,0]]);
|
||||||
|
assert(pathvalid,"The path argument must be a list of 2D or 3D points, or a region.");
|
||||||
path = deduplicate( closed? close_path(path) : path );
|
path = deduplicate( closed? close_path(path) : path );
|
||||||
|
|
||||||
check8 = assert(is_num(width) || (is_vector(width) && len(width)==len(path)));
|
check4 = assert(is_num(width) || len(width)==len(path),
|
||||||
|
"width must be a number or a vector the same length as the path (or all components of a region)");
|
||||||
width = is_num(width)? [for (x=path) width] : width;
|
width = is_num(width)? [for (x=path) width] : width;
|
||||||
check9 = assert(all([for (w=width) w>0]));
|
|
||||||
|
|
||||||
endcap_shape1 = _shape_path(endcap1, width[0], endcap_width1, endcap_length1, endcap_extent1);
|
endcap_shape1 = _shape_path(endcap1, width[0], endcap_width1, endcap_length1, endcap_extent1);
|
||||||
endcap_shape2 = _shape_path(endcap2, last(width), endcap_width2, endcap_length2, endcap_extent2);
|
endcap_shape2 = _shape_path(endcap2, last(width), endcap_width2, endcap_length2, endcap_extent2);
|
||||||
|
@ -290,7 +300,6 @@ module stroke(
|
||||||
(endcap1=="arrow2")? endcap_length1*3/4 :
|
(endcap1=="arrow2")? endcap_length1*3/4 :
|
||||||
0
|
0
|
||||||
]);
|
]);
|
||||||
check10 = assert(is_num(trim1));
|
|
||||||
|
|
||||||
trim2 = last(width) * first_defined([
|
trim2 = last(width) * first_defined([
|
||||||
trim2, trim,
|
trim2, trim,
|
||||||
|
@ -298,8 +307,8 @@ module stroke(
|
||||||
(endcap2=="arrow2")? endcap_length2*3/4 :
|
(endcap2=="arrow2")? endcap_length2*3/4 :
|
||||||
0
|
0
|
||||||
]);
|
]);
|
||||||
check11 = assert(is_num(trim2));
|
check10 = assert(is_finite(trim1))
|
||||||
|
assert(is_finite(trim2));
|
||||||
|
|
||||||
if (len(path) == 1) {
|
if (len(path) == 1) {
|
||||||
if (len(path[0]) == 2) {
|
if (len(path[0]) == 2) {
|
||||||
|
@ -307,7 +316,7 @@ module stroke(
|
||||||
setcolor(endcap_color1) {
|
setcolor(endcap_color1) {
|
||||||
translate(path[0]) {
|
translate(path[0]) {
|
||||||
mat = is_undef(endcap_angle1)? ident(3) : zrot(endcap_angle1);
|
mat = is_undef(endcap_angle1)? ident(3) : zrot(endcap_angle1);
|
||||||
multmatrix(mat) polygon(endcap_shape1);
|
multmatrix(mat) polygon(scale(singleton_scale,endcap_shape1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -685,7 +694,7 @@ function arc(n, r, angle, d, cp, points, corner, width, thickness, start, wedge=
|
||||||
is_def(angle)? (
|
is_def(angle)? (
|
||||||
let(
|
let(
|
||||||
parmok = !any_defined([points,width,thickness]) &&
|
parmok = !any_defined([points,width,thickness]) &&
|
||||||
((is_vector(angle,2) && is_undef(start)) || is_num(angle))
|
((is_vector(angle,2) && is_undef(start)) || is_finite(angle))
|
||||||
)
|
)
|
||||||
assert(parmok,"Invalid parameters in arc")
|
assert(parmok,"Invalid parameters in arc")
|
||||||
let(
|
let(
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
// Module: apply_folding_hinges_and_snaps()
|
// Module: apply_folding_hinges_and_snaps()
|
||||||
// Usage:
|
// Usage:
|
||||||
// apply_folding_hinges_and_snaps(thick, [foldangle=], [hinges=], [snaps=], [sockets=], [snaplen=], [snapdiam=], [hingegap=], [layerheight=]) CHILDREN;
|
// apply_folding_hinges_and_snaps(thick, [foldangle=], [hinges=], [snaps=], [sockets=], [snaplen=], [snapdiam=], [hingegap=], [layerheight=], [$slop=]) CHILDREN;
|
||||||
// Description:
|
// Description:
|
||||||
// Adds snaplocks and create hinges in children at the given positions.
|
// Adds snaplocks and create hinges in children at the given positions.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -26,6 +26,8 @@
|
||||||
// snapdiam = Diameter/width of locking snaps.
|
// snapdiam = Diameter/width of locking snaps.
|
||||||
// hingegap = Size in mm of the gap at the bottom of the hinge, to make room for folding.
|
// hingegap = Size in mm of the gap at the bottom of the hinge, to make room for folding.
|
||||||
// layerheight = The expected printing layer height in mm.
|
// layerheight = The expected printing layer height in mm.
|
||||||
|
// ---
|
||||||
|
// $slop = increase hinge gap by twice this amount
|
||||||
// Example(Med):
|
// Example(Med):
|
||||||
// size=100;
|
// size=100;
|
||||||
// apply_folding_hinges_and_snaps(
|
// apply_folding_hinges_and_snaps(
|
||||||
|
@ -93,7 +95,7 @@ module apply_folding_hinges_and_snaps(thick, foldangle=90, hinges=[], snaps=[],
|
||||||
|
|
||||||
// Module: folding_hinge_mask()
|
// Module: folding_hinge_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// folding_hinge_mask(l, thick, [layerheight=], [foldangle=], [hingegap=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
// folding_hinge_mask(l, thick, [layerheight=], [foldangle=], [hingegap=], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a mask to be differenced away from a plate to create a foldable hinge.
|
// Creates a mask to be differenced away from a plate to create a foldable hinge.
|
||||||
// Center the mask at the bottom of the plate you want to make a hinge in.
|
// Center the mask at the bottom of the plate you want to make a hinge in.
|
||||||
|
@ -105,6 +107,7 @@ module apply_folding_hinges_and_snaps(thick, foldangle=90, hinges=[], snaps=[],
|
||||||
// layerheight = The expected printing layer height in mm.
|
// layerheight = The expected printing layer height in mm.
|
||||||
// foldangle = The interior angle in degrees of the joint to be created with the hinge. Default: 90
|
// foldangle = The interior angle in degrees of the joint to be created with the hinge. Default: 90
|
||||||
// hingegap = Size in mm of the gap at the bottom of the hinge, to make room for folding.
|
// hingegap = Size in mm of the gap at the bottom of the hinge, to make room for folding.
|
||||||
|
// $slop = Increase size of hinge gap by double this amount
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
|
@ -124,7 +127,7 @@ module folding_hinge_mask(l, thick, layerheight=0.2, foldangle=90, hingegap=unde
|
||||||
|
|
||||||
// Module: snap_lock()
|
// Module: snap_lock()
|
||||||
// Usage:
|
// Usage:
|
||||||
// snap_lock(thick, [snaplen=], [snapdiam=], [layerheight=], [foldangle=], [hingegap=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
// snap_lock(thick, [snaplen=], [snapdiam=], [layerheight=], [foldangle=], [hingegap=], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates the central snaplock part.
|
// Creates the central snaplock part.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -135,6 +138,7 @@ module folding_hinge_mask(l, thick, layerheight=0.2, foldangle=90, hingegap=unde
|
||||||
// layerheight = The expected printing layer height in mm.
|
// layerheight = The expected printing layer height in mm.
|
||||||
// foldangle = The interior angle in degrees of the joint to be created with the hinge. Default: 90
|
// foldangle = The interior angle in degrees of the joint to be created with the hinge. Default: 90
|
||||||
// hingegap = Size in mm of the gap at the bottom of the hinge, to make room for folding.
|
// hingegap = Size in mm of the gap at the bottom of the hinge, to make room for folding.
|
||||||
|
// $slop = increase size of hinge gap by double this amount
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
|
@ -159,7 +163,7 @@ module snap_lock(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, hi
|
||||||
|
|
||||||
// Module: snap_socket()
|
// Module: snap_socket()
|
||||||
// Usage:
|
// Usage:
|
||||||
// snap_socket(thick, [snaplen=], [snapdiam=], [layerheight=], [foldangle=], [hingegap=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
// snap_socket(thick, [snaplen=], [snapdiam=], [layerheight=], [foldangle=], [hingegap=], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates the outside snaplock socketed part.
|
// Creates the outside snaplock socketed part.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -170,6 +174,7 @@ module snap_lock(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, hi
|
||||||
// layerheight = The expected printing layer height in mm.
|
// layerheight = The expected printing layer height in mm.
|
||||||
// foldangle = The interior angle in degrees of the joint to be created with the hinge. Default: 90
|
// foldangle = The interior angle in degrees of the joint to be created with the hinge. Default: 90
|
||||||
// hingegap = Size in mm of the gap at the bottom of the hinge, to make room for folding.
|
// hingegap = Size in mm of the gap at the bottom of the hinge, to make room for folding.
|
||||||
|
// $slop = Increase size of hinge gap by double this amount
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
// Module: nema_stepper_motor()
|
// Module: nema_stepper_motor()
|
||||||
// Usage:
|
// Usage:
|
||||||
// nema_stepper_motor(size, h, shaft_len, ...) [attachments];
|
// nema_stepper_motor(size, h, shaft_len, [$slop=], ...) [ATTACHMENTS];
|
||||||
// Topics: Parts, Motors
|
// Topics: Parts, Motors
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a model of a NEMA standard stepper motor.
|
// Creates a model of a NEMA standard stepper motor.
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
// ---
|
// ---
|
||||||
// details = If false, creates a very rough motor shape, suitable for using as a mask. Default: true
|
// details = If false, creates a very rough motor shape, suitable for using as a mask. Default: true
|
||||||
// atype = The attachment set type to use when anchoring. Default: `"body"`
|
// atype = The attachment set type to use when anchoring. Default: `"body"`
|
||||||
|
// $slop = If details is false then increase size of the model by double this amount (for use as a mask)
|
||||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `TOP`
|
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `TOP`
|
||||||
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
|
@ -117,7 +118,7 @@ module nema_stepper_motor(size=17, h=24, shaft_len=20, details=true, atype="body
|
||||||
|
|
||||||
// Module: nema_mount_mask()
|
// Module: nema_mount_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// nema_mount_mask(size, depth, l, ...);
|
// nema_mount_mask(size, depth, l, [$slop], ...);
|
||||||
// Topics: Parts, Motors
|
// Topics: Parts, Motors
|
||||||
// Description: Creates a mask to use when making standard NEMA stepper motor mounts.
|
// Description: Creates a mask to use when making standard NEMA stepper motor mounts.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
|
|
@ -399,7 +399,7 @@ function _partition_cutpath(l, h, cutsize, cutpath, gap) =
|
||||||
|
|
||||||
// Module: partition_mask()
|
// Module: partition_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// partition_mask(l, w, h, [cutsize], [cutpath], [gap], [inverse], [spin], [orient]) [ATTACHMENTS];
|
// partition_mask(l, w, h, [cutsize], [cutpath], [gap], [inverse], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a mask that you can use to difference or intersect with an object to remove half of it, leaving behind a side designed to allow assembly of the sub-parts.
|
// Creates a mask that you can use to difference or intersect with an object to remove half of it, leaving behind a side designed to allow assembly of the sub-parts.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -449,7 +449,7 @@ module partition_mask(l=100, w=100, h=100, cutsize=10, cutpath="jigsaw", gap=0,
|
||||||
|
|
||||||
// Module: partition_cut_mask()
|
// Module: partition_cut_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// partition_cut_mask(l, w, h, [cutsize], [cutpath], [gap], [inverse], [spin], [orient]) [ATTACHMENTS];
|
// partition_cut_mask(l, w, h, [cutsize], [cutpath], [gap], [inverse], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a mask that you can use to difference with an object to cut it into two sub-parts that can be assembled.
|
// Creates a mask that you can use to difference with an object to cut it into two sub-parts that can be assembled.
|
||||||
// The `$slop` value is important to get the proper fit and should probably be smaller than 0.2. The examples below
|
// The `$slop` value is important to get the proper fit and should probably be smaller than 0.2. The examples below
|
||||||
|
@ -463,7 +463,7 @@ module partition_mask(l=100, w=100, h=100, cutsize=10, cutpath="jigsaw", gap=0,
|
||||||
// gap = Empty gaps between cutpath iterations. Default: 0
|
// gap = Empty gaps between cutpath iterations. Default: 0
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||||
// $slop = The width of the cut mask, to correct for printer-specific fitting. Min: 0.05.
|
// $slop = The width of the cut mask, to correct for printer-specific fitting.
|
||||||
// Examples:
|
// Examples:
|
||||||
// partition_cut_mask(gap=0, cutpath="dovetail");
|
// partition_cut_mask(gap=0, cutpath="dovetail");
|
||||||
// partition_cut_mask(gap=30, cutpath="dovetail");
|
// partition_cut_mask(gap=30, cutpath="dovetail");
|
||||||
|
@ -492,7 +492,7 @@ module partition_cut_mask(l=100, h=100, cutsize=10, cutpath="jigsaw", gap=0, anc
|
||||||
|
|
||||||
// Module: partition()
|
// Module: partition()
|
||||||
// Usage:
|
// Usage:
|
||||||
// partition(size, [spread], [cutsize], [cutpath], [gap], [spin]) CHILDREN;
|
// partition(size, [spread], [cutsize], [cutpath], [gap], [spin], [$slop=]) CHILDREN;
|
||||||
// Description:
|
// Description:
|
||||||
// Partitions an object into two parts, spread apart a small distance, with matched joining edges.
|
// Partitions an object into two parts, spread apart a small distance, with matched joining edges.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -502,6 +502,8 @@ module partition_cut_mask(l=100, h=100, cutsize=10, cutpath="jigsaw", gap=0, anc
|
||||||
// cutpath = The cutpath to use. Standard named paths are "flat", "sawtooth", "sinewave", "comb", "finger", "dovetail", "hammerhead", and "jigsaw". Alternatively, you can give a cutpath as a 2D path, where X is between 0 and 1, and Y is between -0.5 and 0.5.
|
// cutpath = The cutpath to use. Standard named paths are "flat", "sawtooth", "sinewave", "comb", "finger", "dovetail", "hammerhead", and "jigsaw". Alternatively, you can give a cutpath as a 2D path, where X is between 0 and 1, and Y is between -0.5 and 0.5.
|
||||||
// gap = Empty gaps between cutpath iterations. Default: 0
|
// gap = Empty gaps between cutpath iterations. Default: 0
|
||||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||||
|
// ---
|
||||||
|
// $slop = Extra gap to leave to correct for printer-specific fitting.
|
||||||
// Examples(Med):
|
// Examples(Med):
|
||||||
// partition(spread=12, cutpath="dovetail") cylinder(h=50, d=80, center=false);
|
// partition(spread=12, cutpath="dovetail") cylinder(h=50, d=80, center=false);
|
||||||
// partition(spread=12, gap=30, cutpath="dovetail") cylinder(h=50, d=80, center=false);
|
// partition(spread=12, gap=30, cutpath="dovetail") cylinder(h=50, d=80, center=false);
|
||||||
|
|
|
@ -285,7 +285,7 @@ function torx_depth(size) = torx_info(size)[2];
|
||||||
|
|
||||||
// Module: robertson_mask()
|
// Module: robertson_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// robertson_mask(size, [extra]);
|
// robertson_mask(size, [extra], [ang], [$slop=]);
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a mask for creating a Robertson/Square drive recess given the drive size as an integer.
|
// Creates a mask for creating a Robertson/Square drive recess given the drive size as an integer.
|
||||||
// The width of the recess will be oversized by `2 * $slop`. Note that this model is based
|
// The width of the recess will be oversized by `2 * $slop`. Note that this model is based
|
||||||
|
@ -295,6 +295,7 @@ function torx_depth(size) = torx_info(size)[2];
|
||||||
// size = The size of the square drive, as an integer from 0 to 4.
|
// size = The size of the square drive, as an integer from 0 to 4.
|
||||||
// extra = Extra length of drive mask to create.
|
// extra = Extra length of drive mask to create.
|
||||||
// ang = taper angle of each face. Default: 2.5
|
// ang = taper angle of each face. Default: 2.5
|
||||||
|
// ---
|
||||||
// $slop = enlarge recess by this twice amount. Default: 0
|
// $slop = enlarge recess by this twice amount. Default: 0
|
||||||
// Example:
|
// Example:
|
||||||
// robertson_mask(size=2);
|
// robertson_mask(size=2);
|
||||||
|
|
|
@ -2547,6 +2547,7 @@ module teardrop(h, r, ang=45, cap_h, r1, r2, d, d1, d2, cap_h1, cap_h2, l, lengt
|
||||||
chamfer, chamfer1, chamfer2,anchor=CENTER, spin=0, orient=UP)
|
chamfer, chamfer1, chamfer2,anchor=CENTER, spin=0, orient=UP)
|
||||||
{
|
{
|
||||||
length = one_defined([l, h, length, height],"l,h,length,height");
|
length = one_defined([l, h, length, height],"l,h,length,height");
|
||||||
|
dummy=assert(is_finite(length) && length>0, "length must be positive");
|
||||||
r1 = get_radius(r=r, r1=r1, d=d, d1=d1);
|
r1 = get_radius(r=r, r1=r1, d=d, d1=d1);
|
||||||
r2 = get_radius(r=r, r1=r2, d=d, d1=d2);
|
r2 = get_radius(r=r, r1=r2, d=d, d1=d2);
|
||||||
tip_y1 = r1/cos(90-ang);
|
tip_y1 = r1/cos(90-ang);
|
||||||
|
@ -2574,6 +2575,7 @@ function teardrop(h, r, ang=45, cap_h, r1, r2, d, d1, d2, cap_h1, cap_h2, chamf
|
||||||
r1 = get_radius(r=r, r1=r1, d=d, d1=d1, dflt=1),
|
r1 = get_radius(r=r, r1=r1, d=d, d1=d1, dflt=1),
|
||||||
r2 = get_radius(r=r, r1=r2, d=d, d1=d2, dflt=1),
|
r2 = get_radius(r=r, r1=r2, d=d, d1=d2, dflt=1),
|
||||||
length = one_defined([l, h, length, height],"l,h,length,height"),
|
length = one_defined([l, h, length, height],"l,h,length,height"),
|
||||||
|
dummy0=assert(is_finite(length) && length>0, "length must be positive"),
|
||||||
cap_h1 = first_defined([cap_h1, cap_h]),
|
cap_h1 = first_defined([cap_h1, cap_h]),
|
||||||
cap_h2 = first_defined([cap_h2, cap_h]),
|
cap_h2 = first_defined([cap_h2, cap_h]),
|
||||||
chamfer1 = first_defined([chamfer1,chamfer,0]),
|
chamfer1 = first_defined([chamfer1,chamfer,0]),
|
||||||
|
|
Loading…
Reference in a new issue