mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 00:09:41 +00:00
Reworked edge descriptors, first pass.
This commit is contained in:
parent
fbc5f3b119
commit
3c0ab0795a
8 changed files with 214 additions and 155 deletions
|
@ -8,6 +8,23 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Default values for attachment code.
|
||||
$color = undef;
|
||||
$overlap = 0.01;
|
||||
$attach_to = undef;
|
||||
$attach_anchor = [CENTER, CENTER, UP, 0];
|
||||
$attach_norot = false;
|
||||
$parent_size = undef;
|
||||
$parent_size2 = undef;
|
||||
$parent_shift = [0,0];
|
||||
$parent_orient = ORIENT_Z;
|
||||
$parent_anchor = CENTER;
|
||||
$parent_anchors = [];
|
||||
$tags_shown = [];
|
||||
$tags_hidden = [];
|
||||
$tags = "";
|
||||
|
||||
|
||||
// Section: Functions
|
||||
|
||||
|
||||
|
@ -404,4 +421,5 @@ module intersect(a, b=undef, keep=undef)
|
|||
}
|
||||
|
||||
|
||||
|
||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
|
148
constants.scad
148
constants.scad
|
@ -29,11 +29,11 @@ LEFT = [-1, 0, 0];
|
|||
// cuboid(20, anchor=RIGHT);
|
||||
RIGHT = [ 1, 0, 0];
|
||||
|
||||
// Constant: FWD
|
||||
// Constant: FRONT
|
||||
// Description: Vector pointing forward. [0,-1,0]
|
||||
// Example(3D): Usage with `anchor`
|
||||
// cuboid(20, anchor=FWD);
|
||||
FWD = [ 0, -1, 0];
|
||||
// cuboid(20, anchor=FRONT);
|
||||
FRONT = [ 0, -1, 0];
|
||||
|
||||
// Constant: BACK
|
||||
// Description: Vector pointing back. [0,1,0]
|
||||
|
@ -41,17 +41,17 @@ FWD = [ 0, -1, 0];
|
|||
// cuboid(20, anchor=BACK);
|
||||
BACK = [ 0, 1, 0];
|
||||
|
||||
// Constant: DOWN
|
||||
// Constant: BOTTOM
|
||||
// Description: Vector pointing down. [0,0,-1]
|
||||
// Example(3D): Usage with `anchor`
|
||||
// cuboid(20, anchor=DOWN);
|
||||
DOWN = [ 0, 0, -1];
|
||||
// cuboid(20, anchor=BOTTOM);
|
||||
BOTTOM = [ 0, 0, -1];
|
||||
|
||||
// Constant: UP
|
||||
// Constant: TOP
|
||||
// Description: Vector pointing up. [0,0,1]
|
||||
// Example(3D): Usage with `anchor`
|
||||
// cuboid(20, anchor=UP);
|
||||
UP = [ 0, 0, 1];
|
||||
// cuboid(20, anchor=TOP);
|
||||
TOP = [ 0, 0, 1];
|
||||
|
||||
// Constant: ALLPOS
|
||||
// Description: Vector pointing right, back, and up. [1,1,1]
|
||||
|
@ -75,17 +75,12 @@ CENTER = [ 0, 0, 0]; // Centered zero vector.
|
|||
// Section: Vector Aliases
|
||||
// Useful aliases for use with `anchor`.
|
||||
|
||||
ABOVE = UP; // Vector pointing up, alias to `UP`.
|
||||
BELOW = DOWN; // Vector pointing down, alias to `DOWN`.
|
||||
BEFORE = FWD; // Vector pointing forward, alias to `FWD`.
|
||||
BEHIND = BACK; // Vector pointing back, alias to `BACK`.
|
||||
|
||||
TOP = UP; // Vector pointing up, alias to `UP`.
|
||||
BOTTOM = DOWN; // Vector pointing down, alias to `DOWN`.
|
||||
FRONT = FWD; // Vector pointing forward, alias to `FWD`.
|
||||
REAR = BACK; // Vector pointing back, alias to `BACK`.
|
||||
|
||||
FORWARD = FWD; // Vector pointing forward, alias to `FWD`.
|
||||
UP = TOP; // Vector pointing up, alias to `TOP`.
|
||||
DOWN = BOTTOM; // Vector pointing down, alias to `BOTTOM`.
|
||||
BTM = BOTTOM; // Vector pointing down, alias to `BOTTOM`.
|
||||
BOT = BOTTOM; // Vector pointing down, alias to `BOTTOM`.
|
||||
FWD = FRONT; // Vector pointing forward, alias to `FRONT`.
|
||||
FORWARD = FRONT; // Vector pointing forward, alias to `FRONT`.
|
||||
|
||||
|
||||
|
||||
|
@ -179,117 +174,4 @@ ORIENT_YNEG_270 = [ 90, 90, 0]; // Orient reversed along the Y axis, then ro
|
|||
ORIENT_ZNEG_270 = [ 0, 180, 90]; // Orient reversed along the Z axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.
|
||||
|
||||
|
||||
// Section: Individual Edges
|
||||
// Constants for specifying edges for `cuboid()`, etc.
|
||||
|
||||
EDGE_TOP_BK = [[1,0,0,0], [0,0,0,0], [0,0,0,0]]; // Top Back edge.
|
||||
EDGE_TOP_FR = [[0,1,0,0], [0,0,0,0], [0,0,0,0]]; // Top Front edge.
|
||||
EDGE_BOT_FR = [[0,0,1,0], [0,0,0,0], [0,0,0,0]]; // Bottom Front Edge.
|
||||
EDGE_BOT_BK = [[0,0,0,1], [0,0,0,0], [0,0,0,0]]; // Bottom Back Edge.
|
||||
|
||||
EDGE_TOP_RT = [[0,0,0,0], [1,0,0,0], [0,0,0,0]]; // Top Right edge.
|
||||
EDGE_TOP_LF = [[0,0,0,0], [0,1,0,0], [0,0,0,0]]; // Top Left edge.
|
||||
EDGE_BOT_LF = [[0,0,0,0], [0,0,1,0], [0,0,0,0]]; // Bottom Left edge.
|
||||
EDGE_BOT_RT = [[0,0,0,0], [0,0,0,1], [0,0,0,0]]; // Bottom Right edge.
|
||||
|
||||
EDGE_BK_RT = [[0,0,0,0], [0,0,0,0], [1,0,0,0]]; // Back Right edge.
|
||||
EDGE_BK_LF = [[0,0,0,0], [0,0,0,0], [0,1,0,0]]; // Back Left edge.
|
||||
EDGE_FR_LF = [[0,0,0,0], [0,0,0,0], [0,0,1,0]]; // Front Left edge.
|
||||
EDGE_FR_RT = [[0,0,0,0], [0,0,0,0], [0,0,0,1]]; // Front Right edge.
|
||||
|
||||
// Section: Sets of Edges
|
||||
// Constants for specifying edges for `cuboid()`, etc.
|
||||
|
||||
EDGES_X_TOP = [[1,1,0,0], [0,0,0,0], [0,0,0,0]]; // Both X-aligned Top edges.
|
||||
EDGES_X_BOT = [[0,0,1,1], [0,0,0,0], [0,0,0,0]]; // Both X-aligned Bottom edges.
|
||||
EDGES_X_FR = [[0,1,1,0], [0,0,0,0], [0,0,0,0]]; // Both X-aligned Front edges.
|
||||
EDGES_X_BK = [[1,0,0,1], [0,0,0,0], [0,0,0,0]]; // Both X-aligned Back edges.
|
||||
EDGES_X_ALL = [[1,1,1,1], [0,0,0,0], [0,0,0,0]]; // All four X-aligned edges.
|
||||
|
||||
EDGES_Y_TOP = [[0,0,0,0], [1,1,0,0], [0,0,0,0]]; // Both Y-aligned Top edges.
|
||||
EDGES_Y_BOT = [[0,0,0,0], [0,0,1,1], [0,0,0,0]]; // Both Y-aligned Bottom edges.
|
||||
EDGES_Y_LF = [[0,0,0,0], [0,1,1,0], [0,0,0,0]]; // Both Y-aligned Left edges.
|
||||
EDGES_Y_RT = [[0,0,0,0], [1,0,0,1], [0,0,0,0]]; // Both Y-aligned Right edges.
|
||||
EDGES_Y_ALL = [[0,0,0,0], [1,1,1,1], [0,0,0,0]]; // All four Y-aligned edges.
|
||||
|
||||
EDGES_Z_BK = [[0,0,0,0], [0,0,0,0], [1,1,0,0]]; // Both Z-aligned Back edges.
|
||||
EDGES_Z_FR = [[0,0,0,0], [0,0,0,0], [0,0,1,1]]; // Both Z-aligned Front edges.
|
||||
EDGES_Z_LF = [[0,0,0,0], [0,0,0,0], [0,1,1,0]]; // Both Z-aligned Left edges.
|
||||
EDGES_Z_RT = [[0,0,0,0], [0,0,0,0], [1,0,0,1]]; // Both Z-aligned Right edges.
|
||||
EDGES_Z_ALL = [[0,0,0,0], [0,0,0,0], [1,1,1,1]]; // All four Z-aligned edges.
|
||||
|
||||
EDGES_LEFT = [[0,0,0,0], [0,1,1,0], [0,1,1,0]]; // All four Left edges.
|
||||
EDGES_RIGHT = [[0,0,0,0], [1,0,0,1], [1,0,0,1]]; // All four Right edges.
|
||||
EDGES_FRONT = [[0,1,1,0], [0,0,0,0], [0,0,1,1]]; // All four Front edges.
|
||||
EDGES_BACK = [[1,0,0,1], [0,0,0,0], [1,1,0,0]]; // All four Back edges.
|
||||
EDGES_BOTTOM = [[0,0,1,1], [0,0,1,1], [0,0,0,0]]; // All four Bottom edges.
|
||||
EDGES_TOP = [[1,1,0,0], [1,1,0,0], [0,0,0,0]]; // All four Top edges.
|
||||
|
||||
EDGES_NONE = [[0,0,0,0], [0,0,0,0], [0,0,0,0]]; // No edges.
|
||||
EDGES_ALL = [[1,1,1,1], [1,1,1,1], [1,1,1,1]]; // All edges.
|
||||
|
||||
|
||||
// Section: Edge Helpers
|
||||
|
||||
EDGE_OFFSETS = [ // Array of XYZ offsets to the center of each edge.
|
||||
[[0, 1, 1], [ 0,-1, 1], [ 0,-1,-1], [0, 1,-1]],
|
||||
[[1, 0, 1], [-1, 0, 1], [-1, 0,-1], [1, 0,-1]],
|
||||
[[1, 1, 0], [-1, 1, 0], [-1,-1, 0], [1,-1, 0]]
|
||||
];
|
||||
|
||||
|
||||
// Function: corner_edge_count()
|
||||
// Description: Counts how many given edges intersect at a specific corner.
|
||||
// Arguments:
|
||||
// edges = Standard edges array.
|
||||
// v = Vector pointing to the corner to count edge intersections at.
|
||||
function corner_edge_count(edges, v) =
|
||||
(v[2]<=0)? (
|
||||
(v[1]<=0)? (
|
||||
(v[0]<=0)? (
|
||||
edges[0][2] + edges[1][2] + edges[2][2]
|
||||
) : (
|
||||
edges[0][2] + edges[1][3] + edges[2][3]
|
||||
)
|
||||
) : (
|
||||
(v[0]<=0)? (
|
||||
edges[0][3] + edges[1][2] + edges[2][1]
|
||||
) : (
|
||||
edges[0][3] + edges[1][3] + edges[2][0]
|
||||
)
|
||||
)
|
||||
) : (
|
||||
(v[1]<=0)? (
|
||||
(v[0]<=0)? (
|
||||
edges[0][1] + edges[1][1] + edges[2][2]
|
||||
) : (
|
||||
edges[0][1] + edges[1][0] + edges[2][3]
|
||||
)
|
||||
) : (
|
||||
(v[0]<=0)? (
|
||||
edges[0][0] + edges[1][1] + edges[2][1]
|
||||
) : (
|
||||
edges[0][0] + edges[1][0] + edges[2][0]
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Default values for attachment code.
|
||||
$color = undef;
|
||||
$overlap = 0.01;
|
||||
$attach_to = undef;
|
||||
$attach_anchor = [CENTER, CENTER, UP, 0];
|
||||
$attach_norot = false;
|
||||
$parent_size = undef;
|
||||
$parent_size2 = undef;
|
||||
$parent_shift = [0,0];
|
||||
$parent_orient = ORIENT_Z;
|
||||
$parent_anchor = CENTER;
|
||||
$parent_anchors = [];
|
||||
$tags_shown = [];
|
||||
$tags_hidden = [];
|
||||
$tags = "";
|
||||
|
||||
|
||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
|
158
edges.scad
Normal file
158
edges.scad
Normal file
|
@ -0,0 +1,158 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
// LibFile: edges.scad
|
||||
// Routines to work with edge sets and edge set descriptors.
|
||||
// To use this, add the following line to the top of your file.
|
||||
// ```
|
||||
// include <BOSL2/std.scad>
|
||||
// ```
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Section: Sets of Edges
|
||||
// Constants for specifying edges for `cuboid()`, etc.
|
||||
|
||||
EDGES_NONE = [[0,0,0,0], [0,0,0,0], [0,0,0,0]]; // No edges.
|
||||
EDGES_ALL = [[1,1,1,1], [1,1,1,1], [1,1,1,1]]; // All edges.
|
||||
|
||||
|
||||
// Section: Edge Helpers
|
||||
|
||||
// Function: is_edge_array()
|
||||
// Usage:
|
||||
// is_edge_array(v)
|
||||
// Description:
|
||||
// Returns true if the given value has the form of an edge array.
|
||||
function is_edge_array(v) = is_list(v) && is_vector(v[0]) && len(v)==3 && len(v[0])==4;
|
||||
|
||||
|
||||
// Function: edge()
|
||||
// Usage:
|
||||
// edge(v);
|
||||
// Description:
|
||||
// Takes an edge set descriptor and returns the EDGE array representing those edges.
|
||||
// This function is useful for modules that take `edges` arguments, like `cuboid()`.
|
||||
// An edge set descriptor can be any of:
|
||||
// - A raw EDGE array.
|
||||
// - A vector pointing towards an edge, indicating just that edge.
|
||||
// - A vector pointing towards a face, indicating all edges surrounding that face.
|
||||
// - A vector pointing towards a corner, indicating all edges that meet at that corner.
|
||||
// - The string "X", indicating all X axis aligned edges.
|
||||
// - The string "Y", indicating all Y axis aligned edges.
|
||||
// - The string "Z", indicating all Y axis aligned edges.
|
||||
// - The string "ALL", indicating all edges.
|
||||
// - The string "NONE", indicating no edges at all.
|
||||
function edge_set(v) =
|
||||
is_edge_array(v)? v : [
|
||||
for (ax=[0:2]) [
|
||||
for (b=[-1,1], a=[-1,1]) let(
|
||||
v2=[[0,a,b],[a,0,b],[a,b,0]][ax]
|
||||
) (
|
||||
is_string(v)? (
|
||||
v=="X"? (ax==0) : // Return all X axis aligned edges.
|
||||
v=="Y"? (ax==1) : // Return all Y axis aligned edges.
|
||||
v=="Z"? (ax==2) : // Return all Z axis aligned edges.
|
||||
v=="ALL"? true : // Return all edges.
|
||||
v=="NONE"? false : // Return no edges.
|
||||
let(valid_values = ["X", "Y", "Z", "ALL", "NONE"])
|
||||
assert(
|
||||
in_list(v, valid_values),
|
||||
str(v, " must be a vector, edge array, or one of ", valid_values)
|
||||
) v
|
||||
) :
|
||||
let(nonz = sum(vabs(v)))
|
||||
nonz==2? (v==v2) : // Edge: return matching edge.
|
||||
let(
|
||||
matches = count_true([
|
||||
for (i=[0:2]) v[i] && (v[i]==v2[i])
|
||||
])
|
||||
)
|
||||
nonz==1? (matches==1) : // Face: return surrounding edges.
|
||||
(matches==2) // Corner: return touching edges.
|
||||
)? 1 : 0
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
// Function: normalize_edges()
|
||||
// Usage:
|
||||
// normalize_edges(v);
|
||||
// Description:
|
||||
// Normalizes all values in an edge array to be `1`, if it was originally greater than `0`,
|
||||
// or `0`, if it was originally less than or equal to `0`.
|
||||
function normalize_edges(v) = [for (ax=v) [for (edge=ax) edge>0? 1 : 0]];
|
||||
|
||||
|
||||
// Function: edges()
|
||||
// Usage:
|
||||
// edges(v)
|
||||
// edges(v, except)
|
||||
// Description:
|
||||
// Takes a list of edge set descriptors, and returns a normalized EDGE array
|
||||
// that represents all those given edges. If the `except` argument is given
|
||||
// a list of edge set descriptors, then all those edges will be removed
|
||||
// from the returned EDGE array. If either argument only has a single edge
|
||||
// set descriptor, you do not have to pass it in a list.
|
||||
// Each edge set descriptor can be any of:
|
||||
// - A raw EDGE array.
|
||||
// - A vector pointing towards an edge.
|
||||
// - A vector pointing towards a face, indicating all edges surrounding that face.
|
||||
// - A vector pointing towards a corner, indicating all edges touching that corner.
|
||||
// - The string "X", indicating all X axis aligned edges.
|
||||
// - The string "Y", indicating all Y axis aligned edges.
|
||||
// - The string "Z", indicating all Y axis aligned edges.
|
||||
// - The string "ALL", indicating all edges.
|
||||
// - The string "NONE", indicating no edges at all.
|
||||
// Example: Just the front-top edge
|
||||
// edges(FRONT+TOP)
|
||||
// Example: All edges surrounding either the front or top faces
|
||||
// edges([FRONT,TOP])
|
||||
// Example: All edges around the bottom face, except any that are also on the front
|
||||
// edges(BTM, except=FRONT)
|
||||
// Example: All edges except those around the bottom face.
|
||||
// edges("ALL", except=BOTTOM)
|
||||
// Example: All Z-aligned edges except those around the back face.
|
||||
// edges("Z", except=BACK)
|
||||
// Example: All edges around the bottom or front faces, except the bottom-front edge.
|
||||
// edges([BOTTOM,FRONT], except=BOTTOM+FRONT)
|
||||
// Example: All edges, except Z-aligned edges on the front.
|
||||
// edges("ALL", except=edges("Z", except=BACK))
|
||||
function edges(v, except=[]) =
|
||||
(is_string(v) || is_vector(v) || is_edge_array(v))? edges([v], except=except) :
|
||||
(is_string(except) || is_vector(except) || is_edge_array(except))? edges(v, except=[except]) :
|
||||
except==[]? normalize_edges(sum([for (x=v) edge_set(x)])) :
|
||||
normalize_edges(
|
||||
normalize_edges(sum([for (x=v) edge_set(x)])) -
|
||||
sum([for (x=except) edge_set(x)])
|
||||
);
|
||||
|
||||
|
||||
EDGE_OFFSETS = [ // Array of XYZ offsets to the center of each edge.
|
||||
[
|
||||
[ 0,-1,-1],
|
||||
[ 0, 1,-1],
|
||||
[ 0,-1, 1],
|
||||
[ 0, 1, 1]
|
||||
], [
|
||||
[-1, 0,-1],
|
||||
[ 1, 0,-1],
|
||||
[-1, 0, 1],
|
||||
[ 1, 0, 1]
|
||||
], [
|
||||
[-1,-1, 0],
|
||||
[ 1,-1, 0],
|
||||
[-1, 1, 0],
|
||||
[ 1, 1, 0]
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
// Function: corner_edge_count()
|
||||
// Description: Counts how many given edges intersect at a specific corner.
|
||||
// Arguments:
|
||||
// edges = Standard edges array.
|
||||
// v = Vector pointing to the corner to count edge intersections at.
|
||||
function corner_edge_count(edges, v) =
|
||||
let(u = (v+[1,1,1])/2) edges[0][u.y+u.z*2] + edges[1][u.x+u.z*2] + edges[2][u.x+u.y*2];
|
||||
|
||||
|
||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
24
masks.scad
24
masks.scad
|
@ -246,21 +246,21 @@ module chamfer_mask_z(l=1.0, chamfer=1.0, anchor=CENTER) {
|
|||
// Arguments:
|
||||
// chamfer = Inset of the chamfer from the edge. (Default: 1)
|
||||
// size = The size of the rectangular cuboid we want to chamfer.
|
||||
// edges = Which edges do we want to chamfer. Recommend to use EDGE constants from constants.scad.
|
||||
// edges = Which edges to chamfer. Use of [`edges()`](edges.scad#edges) from [`edges.scad`](edges.scad) is recommend.
|
||||
// Description:
|
||||
// You should use `EDGE` constants from `constants.scad` with the `edge` argument.
|
||||
// You should use [`edges()`](edges.scad#edges) from [`edges.scad`](edges.scad) with the `edge` argument.
|
||||
// However, if you must handle it raw, the edge ordering is this:
|
||||
// [
|
||||
// [Y+Z+, Y-Z+, Y-Z-, Y+Z-],
|
||||
// [X+Z+, X-Z+, X-Z-, X+Z-],
|
||||
// [X+Y+, X-Y+, X-Y-, X+Y-]
|
||||
// [Y-Z-, Y+Z-, Y-Z+, Y+Z+],
|
||||
// [X-Z-, X+Z-, X-Z+, X+Z+],
|
||||
// [X-Y-, X+Y-, X-Y+, X+Y+]
|
||||
// ]
|
||||
// Example(FR):
|
||||
// chamfer(chamfer=2, size=[20,40,30]) {
|
||||
// cube(size=[20,40,30], center=true);
|
||||
// }
|
||||
// Example(FR):
|
||||
// chamfer(chamfer=2, size=[20,40,30], edges=EDGES_TOP - EDGE_TOP_LF + EDGE_FR_RT) {
|
||||
// chamfer(chamfer=2, size=[20,40,30], edges=edges([TOP,FRONT+RIGHT], except=TOP+LEFT)) {
|
||||
// cube(size=[20,40,30], center=true);
|
||||
// }
|
||||
module chamfer(chamfer=1, size=[1,1,1], edges=EDGES_ALL)
|
||||
|
@ -446,21 +446,21 @@ module rounding_mask_z(l=1.0, r=1.0, anchor=CENTER) rounding_mask(l=l, r=r, orie
|
|||
// Arguments:
|
||||
// r = Radius of the rounding. (Default: 1)
|
||||
// size = The size of the rectangular cuboid we want to chamfer.
|
||||
// edges = Which edges do we want to chamfer. Recommend to use EDGE constants from constants.scad.
|
||||
// edges = Which edges to chamfer. Use of [`edges()`](edges.scad#edges) from [`edges.scad`](edges.scad) is recommend.
|
||||
// Description:
|
||||
// You should use `EDGE` constants from `constants.scad` with the `edge` argument.
|
||||
// You should use [`edges()`](edges.scad#edges) from [`edges.scad`](edges.scad) to generate the edge array for the `edge` argument.
|
||||
// However, if you must handle it raw, the edge ordering is this:
|
||||
// [
|
||||
// [Y+Z+, Y-Z+, Y-Z-, Y+Z-],
|
||||
// [X+Z+, X-Z+, X-Z-, X+Z-],
|
||||
// [X+Y+, X-Y+, X-Y-, X+Y-]
|
||||
// [Y-Z-, Y+Z-, Y-Z+, Y+Z+],
|
||||
// [X-Z-, X+Z-, X-Z+, X+Z+],
|
||||
// [X-Y-, X+Y-, X-Y+, X+Y+]
|
||||
// ]
|
||||
// Example(FR):
|
||||
// rounding(r=10, size=[50,100,150], $fn=24) {
|
||||
// cube(size=[50,100,150], center=true);
|
||||
// }
|
||||
// Example(FR,FlatSpin):
|
||||
// rounding(r=10, size=[50,50,75], edges=EDGES_TOP - EDGE_TOP_LF + EDGE_FR_RT, $fn=24) {
|
||||
// rounding(r=10, size=[50,50,75], edges=edges([TOP,FRONT+RIGHT], except=TOP+LEFT), $fn=24) {
|
||||
// cube(size=[50,50,75], center=true);
|
||||
// }
|
||||
module rounding(r=1, size=[1,1,1], edges=EDGES_ALL)
|
||||
|
|
|
@ -136,7 +136,7 @@ module nema11_stepper(h=24, shaft=5, shaft_len=20, orient=ORIENT_Z, anchor=DOWN)
|
|||
union() {
|
||||
difference() {
|
||||
color([0.4, 0.4, 0.4])
|
||||
cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, anchor=TOP);
|
||||
cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
|
||||
color("silver")
|
||||
xspread(screw_spacing)
|
||||
yspread(screw_spacing)
|
||||
|
@ -199,7 +199,7 @@ module nema14_stepper(h=24, shaft=5, shaft_len=24, orient=ORIENT_Z, anchor=DOWN)
|
|||
union() {
|
||||
difference() {
|
||||
color([0.4, 0.4, 0.4])
|
||||
cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, anchor=TOP);
|
||||
cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
|
||||
color("silver")
|
||||
xspread(screw_spacing)
|
||||
yspread(screw_spacing)
|
||||
|
@ -262,7 +262,7 @@ module nema17_stepper(h=34, shaft=5, shaft_len=20, orient=ORIENT_Z, anchor=TOP)
|
|||
union() {
|
||||
difference() {
|
||||
color([0.4, 0.4, 0.4])
|
||||
cuboid([motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, anchor=TOP);
|
||||
cuboid([motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
|
||||
color("silver")
|
||||
xspread(screw_spacing)
|
||||
yspread(screw_spacing)
|
||||
|
@ -345,7 +345,7 @@ module nema23_stepper(h=50, shaft=6.35, shaft_len=25, orient=ORIENT_Z, anchor=TO
|
|||
difference() {
|
||||
union() {
|
||||
color([0.4, 0.4, 0.4])
|
||||
cuboid([motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, anchor=TOP);
|
||||
cuboid([motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
|
||||
color([0.4, 0.4, 0.4])
|
||||
cylinder(h=plinth_height, d=plinth_diam);
|
||||
color("silver")
|
||||
|
@ -410,7 +410,7 @@ module nema34_stepper(h=75, shaft=12.7, shaft_len=32, orient=ORIENT_Z, anchor=TO
|
|||
difference() {
|
||||
union() {
|
||||
color([0.4, 0.4, 0.4])
|
||||
cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, anchor=TOP);
|
||||
cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
|
||||
color([0.4, 0.4, 0.4])
|
||||
cylinder(h=plinth_height, d=plinth_diam);
|
||||
color("silver")
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// size = The size of the cube.
|
||||
// chamfer = Size of chamfer, inset from sides. Default: No chamferring.
|
||||
// rounding = Radius of the edge rounding. Default: No rounding.
|
||||
// edges = Edges to chamfer/rounding. Use `EDGE` constants from constants.scad. Default: `EDGES_ALL`
|
||||
// edges = Edges to chamfer/round. It's recommended to use [`edges()`](edges.scad#edges) from [`edges.scad`](edges.scad). Default: All edges.
|
||||
// trimcorners = If true, rounds or chamfers corners where three chamferred/rounded edges meet. Default: `true`
|
||||
// p1 = Align the cuboid's corner at `p1`, if given. Forces `anchor=ALLNEG`.
|
||||
// p2 = If given with `p1`, defines the cornerpoints of the cuboid.
|
||||
|
@ -44,9 +44,9 @@
|
|||
// Example: Rectangular cube with rounded edges, without trimmed corners.
|
||||
// cuboid([30,40,50], rounding=10, trimcorners=false);
|
||||
// Example: Rectangular cube with only some edges chamferred.
|
||||
// cuboid([30,40,50], chamfer=5, edges=EDGE_TOP_FR+EDGE_TOP_RT+EDGE_FR_RT, $fn=24);
|
||||
// cuboid([30,40,50], chamfer=5, edges=edges([TOP+FRONT,TOP+RIGHT,FRONT+RIGHT]), $fn=24);
|
||||
// Example: Rectangular cube with only some edges rounded.
|
||||
// cuboid([30,40,50], rounding=5, edges=EDGE_TOP_FR+EDGE_TOP_RT+EDGE_FR_RT, $fn=24);
|
||||
// cuboid([30,40,50], rounding=5, edges=edges([TOP+FRONT,TOP+RIGHT,FRONT+RIGHT]), $fn=24);
|
||||
// Example: Standard Connectors
|
||||
// cuboid(40, chamfer=5) show_anchors();
|
||||
module cuboid(
|
||||
|
|
|
@ -37,11 +37,11 @@ module slider(l=30, w=10, h=10, base=10, wall=5, ang=30, slop=PRINTER_SLOP, orie
|
|||
orient_and_anchor([full_width, l, h+2*base], orient, anchor, orig_orient=ORIENT_Y, chain=true) {
|
||||
down(base+h/2) {
|
||||
// Base
|
||||
cuboid([full_width, l, base-slop], chamfer=2, edges=EDGE_TOP_FR+EDGE_TOP_BK+EDGES_Z_ALL, anchor=UP);
|
||||
cuboid([full_width, l, base-slop], chamfer=2, edges=edges([FRONT,BACK], except=BOT), anchor=UP);
|
||||
|
||||
// Wall
|
||||
xflip_copy(offset=w/2+slop) {
|
||||
cuboid([wall, l, full_height], chamfer=2, edges=EDGE_TOP_RT+EDGE_FR_RT+EDGE_BK_RT, anchor=UP+RIGHT);
|
||||
cuboid([wall, l, full_height], chamfer=2, edges=edges(RIGHT, except=BOT), anchor=UP+RIGHT);
|
||||
}
|
||||
|
||||
// Sliders
|
||||
|
|
1
std.scad
1
std.scad
|
@ -9,6 +9,7 @@
|
|||
|
||||
|
||||
include <constants.scad>
|
||||
include <edges.scad>
|
||||
include <compat.scad>
|
||||
include <math.scad>
|
||||
include <arrays.scad>
|
||||
|
|
Loading…
Reference in a new issue