-
Notifications
You must be signed in to change notification settings - Fork 178
partitions.scad
Cut objects with a plane, or partition them into interlocking pieces for easy printing of large objects.
To use, add the following lines to the beginning of your file:
include <BOSL2/std.scad>
-
-
half_of()– Masks half of an object at a cut plane. [Geom] [VNF] [Path] [Region] -
left_half()– Masks the right half of an object along the Y-Z plane, leaving the left half. [Geom] [VNF] [Path] [Region] -
right_half()– Masks the left half of an object along the Y-Z plane, leaving the right half. [Geom] [VNF] [Path] [Region] -
front_half()– Masks the back half of an object along the X-Z plane, leaving the front half. [Geom] [VNF] [Path] [Region] -
back_half()– Masks the front half of an object along the X-Z plane, leaving the back half. [Geom] [VNF] [Path] [Region] -
bottom_half()– Masks the top half of an object along the X-Y plane, leaving the bottom half. [Geom] [VNF] [Path] [Region] -
top_half()– Masks the bottom half of an object along the X-Y plane, leaving the top half. [Geom] [VNF] [Path] [Region]
-
-
Section: Partioning into Interlocking Pieces
-
partition_mask()– Creates a mask to remove half an object with the remaining half suitable for reassembly. [Geom] -
partition_cut_mask()– Creates a mask to cut an object into two subparts that can be reassembled. [Geom] -
partition()– Cuts an object in two with matched joining edges, then separates the parts. [Geom] [VNF] [Path] [Region] -
ptn_sect()– Creates a partition path section from a description. [Path] -
partition_path()– Creates a partition path from a path description. [Path]
-
Synopsis: Masks half of an object at a cut plane. [Geom] [VNF] [Path] [Region]
Topics: Partitions, Masking
See Also: back_half(), front_half(), left_half(), right_half(), top_half(), bottom_half(), intersection()
Usage: as module
- half_of(v, [cp], [s], [planar]) CHILDREN;
Usage: as function
- result = half_of(p,v,[cp]);
Description:
Slices an object at a cut plane, and masks away everything that is on one side. The v parameter
is either a plane specification or a normal vector. The s parameter is needed for the module
version to control the size of the masking cube. If s is too large then the preview display
will flip around and display the wrong half, but if it is too small it won't fully mask your
model. When called as a function, you must supply a vnf, path or region in p. If planar is set
to true for the module version the operation is performed in 2D and UP and DOWN are treated as
equivalent to BACK and FWD respectively.
Arguments:
| By Position | What it does |
|---|---|
p |
path, region or VNF to slice. (Function version) |
v |
Normal of plane to slice at. Keeps everything on the side the normal points to. Default: [0,0,1] (UP) |
cp |
If given as a scalar, moves the cut plane along the normal by the given amount. If given as a point, specifies a point on the cut plane. Default: [0,0,0] |
s |
Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, OpenSCAD's preview rendering may display the wrong half. (Module version) Default: 100 |
planar |
If true, perform a 2D operation. When planar, a v of UP or DOWN becomes equivalent of BACK and FWD respectively. (Module version). Default: false. |
cut_path |
If given a path, uses it to form the partition cut face. Negative X values in the path will be interpreted as being to the left of the cut plane, when looking at it from the cut-away side, with Z+ up, (or back, if v is UP or DOWN). Positive X values will be interpreted as being to the right side. Path Y values equal to 0 are interpreted as being on the cut plane. Positive Y values are interpreted as being in the direction of the cut plane normal (into the kept side). Default: undef (cut using a flat plane) |
cut_angle |
The angle in degrees to rotate the cut mask around the plane normal vector, before partitioning. Only makes sense when using with cut_path= and planar=false. Module only. Default: 0 |
offset |
The amount to increase the size of the partitioning mask, using offset(). Note: this might be imperfect in the functional form. Default: 0 |
show_frameref |
If true, draws a frame reference arrow set in the center of the cut plane, to give you a clear idea on how the cut_path slice will be oriented. Module only. Default: false |
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
Example 1:
include <BOSL2/std.scad>
half_of(DOWN+BACK, cp=[0,-10,0]) cylinder(h=40, r1=10, r2=0, center=false);
Example 2:
include <BOSL2/std.scad>
half_of(DOWN+LEFT, s=200) sphere(d=150);
Example 3:
include <BOSL2/std.scad>
half_of([1,1], planar=true) circle(d=50);
Example 4: Using a cut path in 2D
include <BOSL2/std.scad>
ppath = partition_path([
40,
"jigsaw",
10,
"dovetail yflip",
5,
"hammerhead 30x20",
5,
"dovetail yflip",
10,
"sawtooth",
40,
],
$fn=24
);
half_of(LEFT+BACK, cut_path=ppath, s=500, planar=true)
square(200, center=true);
Example 5: Using a cut path in 3D
include <BOSL2/std.scad>
ppath = partition_path([
40,
"jigsaw",
10,
"dovetail yflip",
5,
"hammerhead 30x20",
5,
"dovetail yflip",
10,
"sawtooth",
40,
],
$fn=24
);
half_of(LEFT+BACK, cut_path=ppath, s=500)
cube(200, center=true);
Synopsis: Masks the right half of an object along the Y-Z plane, leaving the left half. [Geom] [VNF] [Path] [Region]
Topics: Partitions, Masking
See Also: back_half(), front_half(), right_half(), top_half(), bottom_half(), half_of(), intersection()
Usage: as module
- left_half([s], [x]) CHILDREN;
- left_half(planar=true, [s], [x]) CHILDREN;
Usage: as function
- result = left_half(p, [x]);
Description:
Slices an object at a vertical Y-Z cut plane, and masks away everything that is right of it.
The s parameter is needed for the module version to control the size of the masking cube.
If s is too large then the preview display will flip around and display the wrong half,
but if it is too small it won't fully mask your model.
Arguments:
| By Position | What it does |
|---|---|
p |
VNF, region or path to slice (function version) |
s |
Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, OpenSCAD's preview rendering may display the wrong half. (Module version) Default: 100 |
x |
The X coordinate of the cut-plane. Default: 0 |
planar |
If true, perform a 2D operation. (Module version) Default: false. |
cut_path |
If given a path, uses it to form the partition cut face. Negative X values in the path will be interpreted as being to the left of the cut plane, when looking at it from the cut-away side, with Z+ up, (or back, if v is UP or DOWN). Positive X values will be interpreted as being to the right side. Path Y values equal to 0 are interpreted as being on the cut plane. Positive Y values are interpreted as being in the direction of the cut plane normal (into the kept side). Default: undef (cut using a flat plane) |
cut_angle |
The angle in degrees to rotate the cut mask around the plane normal vector, before partitioning. Only makes sense when using with cut_path= and planar=false. Module only. Default: 0 |
offset |
The amount to increase the size of the partitioning mask, using offset(). Note: this might be imperfect in the functional form. Default: 0 |
show_frameref |
If true, draws a frame reference arrow set in the center of the cut plane, to give you a clear idea on how the cut_path slice will be oriented. Module only. Default: false |
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
Example 1:
include <BOSL2/std.scad>
left_half() sphere(r=20);
Example 2:
include <BOSL2/std.scad>
left_half(x=-8) sphere(r=20);
Example 3:
include <BOSL2/std.scad>
left_half(planar=true) circle(r=20);
Example 4: Using a cut path in 2D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
left_half(cut_path=ppath, s=310, planar=true) square(300, center=true);
Example 5: Using a cut path in 3D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
left_half(cut_path=ppath, s=310)
cube(300, center=true);
Synopsis: Masks the left half of an object along the Y-Z plane, leaving the right half. [Geom] [VNF] [Path] [Region]
Topics: Partitions, Masking
See Also: back_half(), front_half(), left_half(), top_half(), bottom_half(), half_of(), intersection()
Usage: as module
- right_half([s=], [x=]) CHILDREN;
- right_half(planar=true, [s=], [x=]) CHILDREN;
Usage: as function
- result = right_half(p, [x=]);
Description:
Slices an object at a vertical Y-Z cut plane, and masks away everything that is left of it.
The s parameter is needed for the module version to control the size of the masking cube.
If s is too large then the preview display will flip around and display the wrong half,
but if it is too small it won't fully mask your model.
Arguments:
| By Position | What it does |
|---|---|
p |
VNF, region or path to slice (function version) |
s |
Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, OpenSCAD's preview rendering may display the wrong half. (Module version) Default: 100 |
x |
The X coordinate of the cut-plane. Default: 0 |
planar |
If true, perform a 2D operation. (Module version) Default: false. |
cut_path |
If given a path, uses it to form the partition cut face. Negative X values in the path will be interpreted as being to the left of the cut plane, when looking at it from the cut-away side, with Z+ up, (or back, if v is UP or DOWN). Positive X values will be interpreted as being to the right side. Path Y values equal to 0 are interpreted as being on the cut plane. Positive Y values are interpreted as being in the direction of the cut plane normal (into the kept side). Default: undef (cut using a flat plane) |
cut_angle |
The angle in degrees to rotate the cut mask around the plane normal vector, before partitioning. Only makes sense when using with cut_path= and planar=false. Module only. Default: 0 |
offset |
The amount to increase the size of the partitioning mask, using offset(). Note: this might be imperfect in the functional form. Default: 0 |
show_frameref |
If true, draws a frame reference arrow set in the center of the cut plane, to give you a clear idea on how the cut_path slice will be oriented. Module only. Default: false |
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
Example 1:
include <BOSL2/std.scad>
right_half() sphere(r=20);
Example 2:
include <BOSL2/std.scad>
right_half(x=-5) sphere(r=20);
Example 3:
include <BOSL2/std.scad>
right_half(planar=true) circle(r=20);
Example 4: Using a cut path in 2D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
right_half(cut_path=ppath, s=310, planar=true) square(300, center=true);
Example 5: Using a cut path in 3D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
right_half(cut_path=ppath, s=310)
cube(300, center=true);
Synopsis: Masks the back half of an object along the X-Z plane, leaving the front half. [Geom] [VNF] [Path] [Region]
Topics: Partitions, Masking
See Also: back_half(), left_half(), right_half(), top_half(), bottom_half(), half_of(), intersection()
Usage:
- front_half([s], [y]) CHILDREN;
- front_half(planar=true, [s], [y]) CHILDREN;
Usage: as function
- result = front_half(p, [y]);
Description:
Slices an object at a vertical X-Z cut plane, and masks away everything that is behind it.
The s parameter is needed for the module version to control the size of the masking cube.
If s is too large then the preview display will flip around and display the wrong half,
but if it is too small it won't fully mask your model.
Arguments:
| By Position | What it does |
|---|---|
p |
VNF, region or path to slice (function version) |
s |
Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, OpenSCAD's preview rendering may display the wrong half. (Module version) Default: 100 |
y |
The Y coordinate of the cut-plane. Default: 0 |
planar |
If true, perform a 2D operation. (Module version) Default: false. |
cut_path |
If given a path, uses it to form the partition cut face. Negative X values in the path will be interpreted as being to the left of the cut plane, when looking at it from the cut-away side, with Z+ up, (or back, if v is UP or DOWN). Positive X values will be interpreted as being to the right side. Path Y values equal to 0 are interpreted as being on the cut plane. Positive Y values are interpreted as being in the direction of the cut plane normal (into the kept side). Default: undef (cut using a flat plane) |
cut_angle |
The angle in degrees to rotate the cut mask around the plane normal vector, before partitioning. Only makes sense when using with cut_path= and planar=false. Module only. Default: 0 |
offset |
The amount to increase the size of the partitioning mask, using offset(). Note: this might be imperfect in the functional form. Default: 0 |
show_frameref |
If true, draws a frame reference arrow set in the center of the cut plane, to give you a clear idea on how the cut_path slice will be oriented. Module only. Default: false |
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
Example 1:
include <BOSL2/std.scad>
front_half() sphere(r=20);
Example 2:
include <BOSL2/std.scad>
front_half(y=5) sphere(r=20);
Example 3:
include <BOSL2/std.scad>
front_half(planar=true) circle(r=20);
Example 4: Using a cut path in 2D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
front_half(cut_path=ppath, s=310, planar=true) square(300, center=true);
Example 5: Using a cut path in 3D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
front_half(cut_path=ppath, s=310)
cube(300, center=true);
Synopsis: Masks the front half of an object along the X-Z plane, leaving the back half. [Geom] [VNF] [Path] [Region]
Topics: Partitions, Masking
See Also: front_half(), left_half(), right_half(), top_half(), bottom_half(), half_of(), intersection()
Usage:
- back_half([s], [y]) CHILDREN;
- back_half(planar=true, [s], [y]) CHILDREN;
Usage: as function
- result = back_half(p, [y]);
Description:
Slices an object at a vertical X-Z cut plane, and masks away everything that is in front of it.
The s parameter is needed for the module version to control the size of the masking cube.
If s is too large then the preview display will flip around and display the wrong half,
but if it is too small it won't fully mask your model.
Arguments:
| By Position | What it does |
|---|---|
p |
VNF, region or path to slice (function version) |
s |
Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, OpenSCAD's preview rendering may display the wrong half. (Module version) Default: 100 |
y |
The Y coordinate of the cut-plane. Default: 0 |
planar |
If true, perform a 2D operation. (Module version) Default: false. |
cut_path |
If given a path, uses it to form the partition cut face. Negative X values in the path will be interpreted as being to the left of the cut plane, when looking at it from the cut-away side, with Z+ up, (or back, if v is UP or DOWN). Positive X values will be interpreted as being to the right side. Path Y values equal to 0 are interpreted as being on the cut plane. Positive Y values are interpreted as being in the direction of the cut plane normal (into the kept side). Default: undef (cut using a flat plane) |
cut_angle |
The angle in degrees to rotate the cut mask around the plane normal vector, before partitioning. Only makes sense when using with cut_path= and planar=false. Module only. Default: 0 |
offset |
The amount to increase the size of the partitioning mask, using offset(). Note: this might be imperfect in the functional form. Default: 0 |
show_frameref |
If true, draws a frame reference arrow set in the center of the cut plane, to give you a clear idea on how the cut_path slice will be oriented. Module only. Default: false |
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
Example 1:
include <BOSL2/std.scad>
back_half() sphere(r=20);
Example 2:
include <BOSL2/std.scad>
back_half(y=8) sphere(r=20);
Example 3:
include <BOSL2/std.scad>
back_half(planar=true) circle(r=20);
Example 4: Using a cut path in 2D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
back_half(cut_path=ppath, s=310, planar=true) square(300, center=true);
Example 5: Using a cut path in 3D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
back_half(cut_path=ppath, s=310)
cube(300, center=true);
Synopsis: Masks the top half of an object along the X-Y plane, leaving the bottom half. [Geom] [VNF] [Path] [Region]
Topics: Partitions, Masking
See Also: back_half(), front_half(), left_half(), right_half(), top_half(), half_of(), intersection()
Usage:
- bottom_half([s], [z]) CHILDREN;
Usage: as function
- result = bottom_half(p, [z]);
Description:
Slices an object at a horizontal X-Y cut plane, and masks away everything that is above it.
The s parameter is needed for the module version to control the size of the masking cube.
If s is too large then the preview display will flip around and display the wrong half,
but if it is too small it won't fully mask your model.
Arguments:
| By Position | What it does |
|---|---|
p |
VNF, region or path to slice (function version) |
s |
Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, OpenSCAD's preview rendering may display the wrong half. (Module version) Default: 100 |
z |
The Z coordinate of the cut-plane. Default: 0 |
planar |
If true, perform a 2D operation. When planar, becomes equivalent of front_half(). (Module version). Default: false. |
cut_path |
If given a path, uses it to form the partition cut face. Negative X values in the path will be interpreted as being to the left of the cut plane, when looking at it from the cut-away side, with Z+ up, (or back, if v is UP or DOWN). Positive X values will be interpreted as being to the right side. Path Y values equal to 0 are interpreted as being on the cut plane. Positive Y values are interpreted as being in the direction of the cut plane normal (into the kept side). Default: undef (cut using a flat plane) |
cut_angle |
The angle in degrees to rotate the cut mask around the plane normal vector, before partitioning. Only makes sense when using with cut_path= and planar=false. Module only. Default: 0 |
offset |
The amount to increase the size of the partitioning mask, using offset(). Note: this might be imperfect in the functional form. Default: 0 |
show_frameref |
If true, draws a frame reference arrow set in the center of the cut plane, to give you a clear idea on how the cut_path slice will be oriented. Module only. Default: false |
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
Example 1:
include <BOSL2/std.scad>
bottom_half() sphere(r=20);
Example 2:
include <BOSL2/std.scad>
bottom_half(z=-10) sphere(r=20);
Example 3: Working in 2D
include <BOSL2/std.scad>
bottom_half(z=5,planar=true) circle(r=20);
Example 4: Using a cut path in 2D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
bottom_half(cut_path=ppath, s=310, planar=true) square(300, center=true);
Example 5: Using a cut path in 3D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
bottom_half(cut_path=ppath, s=310)
cube(300, center=true);
Synopsis: Masks the bottom half of an object along the X-Y plane, leaving the top half. [Geom] [VNF] [Path] [Region]
Topics: Partitions, Masking
See Also: back_half(), front_half(), left_half(), right_half(), bottom_half(), half_of(), intersection()
Usage: as module
- top_half([s], [z]) CHILDREN;
Usage: as function
- result = top_half(p, [z]);
Description:
Slices an object at a horizontal X-Y cut plane, and masks away everything that is below it.
The s parameter is needed for the module version to control the size of the masking cube.
If s is too large then the preview display will flip around and display the wrong half,
but if it is too small it won't fully mask your model.
Arguments:
| By Position | What it does |
|---|---|
p |
VNF, region or path to slice (function version) |
s |
Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, OpenSCAD's preview rendering may display the wrong half. (Module version) Default: 100 |
z |
The Z coordinate of the cut-plane. Default: 0 |
planar |
If true, perform a 2D operation. When planar, becomes equivalent of back_half(). (Module version). Default: false. |
cut_path |
If given a path, uses it to form the partition cut face. Negative X values in the path will be interpreted as being to the left of the cut plane, when looking at it from the cut-away side, with Z+ up, (or back, if v is UP or DOWN). Positive X values will be interpreted as being to the right side. Path Y values equal to 0 are interpreted as being on the cut plane. Positive Y values are interpreted as being in the direction of the cut plane normal (into the kept side). Default: undef (cut using a flat plane) |
cut_angle |
The angle in degrees to rotate the cut mask around the plane normal vector, before partitioning. Only makes sense when using with cut_path= and planar=false. Module only. Default: 0 |
offset |
The amount to increase the size of the partitioning mask, using offset(). Note: this might be imperfect in the functional form. Default: 0 |
show_frameref |
If true, draws a frame reference arrow set in the center of the cut plane, to give you a clear idea on how the cut_path slice will be oriented. Module only. Default: false |
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
Example 1:
include <BOSL2/std.scad>
top_half() sphere(r=20);
Example 2:
include <BOSL2/std.scad>
top_half(z=5) sphere(r=20);
Example 3: Working in 2D
include <BOSL2/std.scad>
top_half(z=5,planar=true) circle(r=20);
Example 4: Using a cut path in 2D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
top_half(cut_path=ppath, s=310, planar=true) square(300, center=true);
Example 5: Using a cut path in 3D
include <BOSL2/std.scad>
ppath = partition_path([
40, "jigsaw", "dovetail yflip", 40,
"hammerhead 30x20",
40, "dovetail yflip", "sawtooth", 40,
],
altpath=[[-200,0],[-40,0],[-20,20],[20,20],[40,0],[200,0]],
$fn=24
);
top_half(cut_path=ppath, s=310)
cube(300, center=true);
Synopsis: Creates a mask to remove half an object with the remaining half suitable for reassembly. [Geom]
Topics: Partitions, Masking, Paths
See Also: partition_cut_mask(), partition(), dovetail()
Usage:
- partition_mask(l, w, h, [cutsize], [cutpath], [gap], [inverse], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
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.
Arguments:
| By Position | What it does |
|---|---|
l |
The length of the cut axis. |
w |
The width of the part to be masked, back from the cut plane. |
h |
The height of the part to be masked. |
cutsize |
The width of the cut pattern to be used. |
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 |
cutpath_centered |
Ensures the cutpath is always centered. Default: true |
inverse |
If true, create a cutpath that is meant to mate to a non-inverted cutpath. |
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
spin |
Rotate this many degrees around the Z axis. See spin. Default: 0
|
orient |
Vector to rotate top towards. See orient. Default: UP
|
$slop |
The amount to shrink the mask by, to correct for printer-specific fitting. |
Example 1:
include <BOSL2/std.scad>
partition_mask(w=50, gap=0, cutpath="jigsaw", $fn=12);
Example 2:
include <BOSL2/std.scad>
partition_mask(w=50, gap=10, cutpath="jigsaw", $fn=12);
Example 3:
include <BOSL2/std.scad>
partition_mask(w=50, gap=10, cutpath="jigsaw", inverse=true, $fn=12);
Example 4:
include <BOSL2/std.scad>
partition_mask(w=50, gap=10, cutsize=4, cutpath="jigsaw", $fn=12);
Example 5:
include <BOSL2/std.scad>
partition_mask(w=50, gap=10, cutsize=4, cutpath="jigsaw", cutpath_centered=false, $fn=12);
Example 6:
include <BOSL2/std.scad>
partition_mask(w=50, gap=10, cutsize=[4,20], cutpath="jigsaw", $fn=12);
Example 7:
include <BOSL2/std.scad>
partition_mask(w=20, cutpath="sawtooth");
Example 8:
include <BOSL2/std.scad>
partition_mask(w=20, cutpath="sinewave", $fn=12);
Example 9:
include <BOSL2/std.scad>
partition_mask(w=20, cutpath="comb");
Example 10:
include <BOSL2/std.scad>
partition_mask(w=20, cutpath="finger");
Example 11:
include <BOSL2/std.scad>
partition_mask(w=20, cutpath="dovetail");
Example 12:
include <BOSL2/std.scad>
partition_mask(w=20, cutpath="hammerhead");
Example 13:
include <BOSL2/std.scad>
partition_mask(w=20, cutpath="jigsaw", $fn=12);
Synopsis: Creates a mask to cut an object into two subparts that can be reassembled. [Geom]
Topics: Partitions, Masking, Paths
See Also: partition_mask(), partition(), dovetail()
Usage:
- partition_cut_mask(l, [cutsize], [cutpath], [gap], [inverse], [$slop=], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
Description:
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
use larger values to make the mask easier to see.
Arguments:
| By Position | What it does |
|---|---|
l |
The length of the cut axis. |
h |
The height of the part to be masked. |
cutsize |
The width of the cut pattern to be used. Default: 10 |
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. Default: "jigsaw" |
gap |
Empty gaps between cutpath iterations. Default: 0 |
cutpath_centered |
Ensures the cutpath is always centered. Default: true |
spin |
Rotate this many degrees around the Z axis. See spin. Default: 0
|
orient |
Vector to rotate top towards. See orient. Default: UP
|
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
$slop |
The width of the cut mask, to correct for printer-specific fitting. |
Example 1:
include <BOSL2/std.scad>
partition_cut_mask(gap=0, cutpath="dovetail");
Example 2:
include <BOSL2/std.scad>
partition_cut_mask(gap=10, cutpath="dovetail");
Example 3:
include <BOSL2/std.scad>
partition_cut_mask(gap=10, cutsize=15, cutpath="dovetail");
Example 4:
include <BOSL2/std.scad>
partition_cut_mask(gap=10, cutsize=[15,15], cutpath="dovetail");
Example 5:
include <BOSL2/std.scad>
partition_cut_mask(gap=10, cutsize=[15,15], cutpath="dovetail", cutpath_centered=false);
Example 6:
include <BOSL2/std.scad>
partition_cut_mask(cutpath="sawtooth",$slop=0.5);
Example 7:
include <BOSL2/std.scad>
partition_cut_mask(cutpath="sinewave",$slop=0.5,$fn=12);
Example 8:
include <BOSL2/std.scad>
partition_cut_mask(cutpath="comb",$slop=0.5);
Example 9:
include <BOSL2/std.scad>
partition_cut_mask(cutpath="finger",$slop=0.5);
Example 10:
include <BOSL2/std.scad>
partition_cut_mask(cutpath="dovetail",$slop=1);
Example 11:
include <BOSL2/std.scad>
partition_cut_mask(cutpath="hammerhead",$slop=1);
Example 12:
include <BOSL2/std.scad>
partition_cut_mask(cutpath="jigsaw",h=10,$slop=0.5,$fn=12);
Synopsis: Cuts an object in two with matched joining edges, then separates the parts. [Geom] [VNF] [Path] [Region]
Topics: Partitions, Masking, Paths
See Also: partition_cut_mask(), partition_mask(), dovetail()
Usage:
- partition(size, [spread], [cutsize], [cutpath], [gap], [spin], [$slop=]) CHILDREN;
Description:
Partitions an object into two parts, spread apart a small distance, with matched joining edges.
If you only need one side of the partition you can use $idx in the children.
Arguments:
| By Position | What it does |
|---|---|
size |
The [X,Y,Z] size of the object to partition. |
spread |
The distance to spread the two parts by. Default: 10 |
| By Name | What it does |
|---|---|
cutsize |
The width of the cut pattern to be used. Default: 10 |
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. Default: "jigsaw" |
gap |
Empty gaps between cutpath iterations. Default: 0 |
cutpath_centered |
Ensures the cutpath is always centered. Default: true |
spin |
Rotate this many degrees around the Z axis. See spin. Default: 0
|
convexity |
Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10 |
$slop |
Extra gap to leave to correct for printer-specific fitting. |
Side Effects:
-
$idxis set to 0 on the back part and 1 on the front part.
Example 1:
include <BOSL2/std.scad>
partition(spread=12, cutpath="dovetail") cylinder(h=50, d=80, center=false);
Example 2:
include <BOSL2/std.scad>
partition(spread=12, gap=10, cutpath="dovetail") cylinder(h=50, d=80, center=false);
Example 3:
include <BOSL2/std.scad>
partition(spread=12, gap=10, cutpath="dovetail", cutpath_centered=false) cylinder(h=50, d=80, center=false);
Example 4:
include <BOSL2/std.scad>
partition(spread=20, gap=10, cutsize=15, cutpath="dovetail") cylinder(h=50, d=80, center=false);
Example 5:
include <BOSL2/std.scad>
partition(spread=25, gap=10, cutsize=[20,20], cutpath="dovetail") cylinder(h=50, d=80, center=false);
Example 6:
include <BOSL2/std.scad>
partition(cutpath="sawtooth") cylinder(h=50, d=80, center=false);
Example 7:
include <BOSL2/std.scad>
partition(cutpath="sinewave") cylinder(h=50, d=80, center=false);
Example 8:
include <BOSL2/std.scad>
partition(cutpath="comb") cylinder(h=50, d=80, center=false);
Example 9:
include <BOSL2/std.scad>
partition(cutpath="finger") cylinder(h=50, d=80, center=false);
Example 10:
include <BOSL2/std.scad>
partition(spread=12, cutpath="dovetail") cylinder(h=50, d=80, center=false);
Example 11:
include <BOSL2/std.scad>
partition(spread=12, cutpath="hammerhead") cylinder(h=50, d=80, center=false);
Example 12:
include <BOSL2/std.scad>
partition(cutpath="jigsaw", $fn=12) cylinder(h=50, d=80, center=false);
Example 13: Using $idx to display only the back piece of the partition
include <BOSL2/std.scad>
partition(cutpath="jigsaw", $fn=12)
if ($idx==0) cylinder(h=50, d=80, center=false);
Synopsis: Creates a partition path section from a description. [Path]
Topics: Partitions, Masking, Paths
See Also: partition_path(), partition_cut_mask(), partition()
Usage:
- path = ptn_sect(type, [length], [width], [invert=]);
Description:
Creates a partition path section based on a name or description. The result is intended to be fed to partition_path().
If the type= argument is given as a scalar, the pattern returned will be for a "flat" section of that given length.
If the type= argument is given as a 2D path, the pattern returned will be scaled from the input path by length= and width=.
If the type= argument is given as a string, it is expected to be the name of a standard section pattern:
Accepted section pattern names are:
-
"flat": A flat section. -
"sawtooth": A sawtooth halfwave, with the peak to the left. -
"square": A square halfwave. -
"triangle": A triangular halfwave, with the peak in the center. -
"halfsine": Half of a sine-wave. -
"semicircle": The top half of a circle. -
"sinewave": A full sine wave. -
"comb": A modified square halfwave, with walls at a 2° angle. -
"finger": A modified square halfwave with walls at a 20° angle. -
"dovetail": A modified square halfwave with walls dovetailed out by 9°. -
"hammerhead": A shape useful for making T-slots. -
"jigsaw": The classic interlocking jigsaw puzzle tab shape. Section pattern names can be suffixed by one or more modifiers, separated by spaces. Accepted modifier forms are: -
"sawtooth 3x": repeats the sawtooth wave 3 times. -
"triangle 20x30": Resize the triangle wave to be 20x30 in size. -
"sawtooth xflip": Mirrors the sawtooth wave along the X axis. -
"sawtooth yflip": Mirrors the sawtooth wave along the Y axis. -
"sawtooth addflip": Equivalent to a combination of "sawtooth" and "sawtooth xflip yflip". -
"sawtooth wave": Same as "sawtooth addflip". -
"square skew:15": Skews the squarewave shape by 15 degrees. -
"square pinch:33": Pinches the top of the squarewave shape to 33% the size of the bottom. Modifiers are processed left to right in order. Ifinvert=true, behaves as if a " yflip" modifier was added to the end.
Arguments:
| By Position | What it does |
|---|---|
type |
The general description of the partition path section. This can be a string name, a 2D path, or a scalar length for a flat section. Valid names are listed in the section description above. |
length |
The X axis length of the section. Default: 25 |
width |
The Y axis length of the section. Default: 25 |
| By Name | What it does |
|---|---|
invert |
If true, the returned section is flipped back-to-front. Default: false |
Example 1:
include <BOSL2/std.scad>
stroke(ptn_sect("flat"));
Example 2:
include <BOSL2/std.scad>
stroke(ptn_sect("sawtooth"));
Example 3:
include <BOSL2/std.scad>
stroke(ptn_sect("square"));
Example 4:
include <BOSL2/std.scad>
stroke(ptn_sect("triangle"));
Example 5:
include <BOSL2/std.scad>
stroke(ptn_sect("halfsine", $fn=24));
Example 6:
include <BOSL2/std.scad>
stroke(ptn_sect("semicircle", $fn=24));
Example 7:
include <BOSL2/std.scad>
stroke(ptn_sect("comb"));
Example 8:
include <BOSL2/std.scad>
stroke(ptn_sect("finger"));
Example 9:
include <BOSL2/std.scad>
stroke(ptn_sect("dovetail"));
Example 10:
include <BOSL2/std.scad>
stroke(ptn_sect("hammerhead"));
Example 11:
include <BOSL2/std.scad>
stroke(ptn_sect("jigsaw", $fn=24));
Example 12: Giving length and width arguments scales the shape differently.
include <BOSL2/std.scad>
stroke(ptn_sect("jigsaw", length=40, width=20, $fn=36));
Example 13: Giving invert=true will flip the pattern front-to-back
include <BOSL2/std.scad>
stroke(ptn_sect("jigsaw", invert=true, $fn=36));
Example 14: Suffixing the name with " yflip" will also flip the pattern front-to-back.
include <BOSL2/std.scad>
stroke(ptn_sect("hammerhead yflip"));
Example 15: Suffixing the name with " xflip" will reverse the pattern left-to-right.
include <BOSL2/std.scad>
stroke(ptn_sect("sawtooth xflip"));
Example 16: Suffixing the name with " addflip" will construct a full wave pattern from the named halfwave pattern.
include <BOSL2/std.scad>
stroke(ptn_sect("sawtooth addflip"));
Example 17: Suffixing the name with a string like " 5x" will construct 5 repetitions of the pattern.
include <BOSL2/std.scad>
stroke(ptn_sect("sawtooth 5x"));
Example 18: Suffixing the name with a string like " 40x20" will scale the pattern to a size of 40 by 20. By default a pattern will be 20 by 20 in size.
include <BOSL2/std.scad>
stroke(ptn_sect("jigsaw 40x20"));
Example 19: You can add multiple space delimited suffixes to apply multiple effects.
include <BOSL2/std.scad>
stroke(ptn_sect("halfsine addflip yflip 40x30 3x"));
Example 20: Suffix ordering can matter, since they are applied in order.
include <BOSL2/std.scad>
stroke(ptn_sect("halfsine 3x addflip yflip 40x30"));
Example 21: Giving a scalar is a shortcut for a "flat" section of the given length.
include <BOSL2/std.scad>
stroke(ptn_sect(30));
Example 22: Suffixing the name with a string like " skew:15" will skew the waveform by 15 degrees.
include <BOSL2/std.scad>
stroke(ptn_sect("square skew:15"));
Example 23: Suffixing the name with a string like " pinch:30" will pinch the top of the waveform in to 30% of the size of the bottom.
include <BOSL2/std.scad>
stroke(ptn_sect("square pinch:30"));
Example 24: Using a custom section shape. Input is expected to start at [0,0], and end at [1,0]. It is scaled by length= and width=.
include <BOSL2/std.scad>
cust_path = yscale(2, p=arc(n=15, r=0.5, cp=[0.5,0], start=180, angle=-180));
stroke(ptn_sect(cust_path, length=40, width=30));
Synopsis: Creates a partition path from a path description. [Path]
Topics: Partitions, Masking, Paths
See Also: ptn_sect(), partition_cut_mask(), partition()
Usage:
- path = partition_path(pathdesc, [repeat=], [y=], [altpath=]);
Description:
Creates a partition path based on a list of section descriptors, as would be passed to ptn_sect().
Arguments:
| By Position | What it does |
|---|---|
pathdesc |
A list describing one or more partition path segments. Each item is either a numeric length, a string naming a segment pattern as would be passed to ptn_sect(), or a full explicit path. |
| By Name | What it does |
|---|---|
repeat |
Number of times to repeat the full pathdesc sequence along the path. Default: 1 |
y |
If given, closes the generated path by connecting its ends at this Y coordinate, and orients the closed path based on the sign of y. |
altpath |
Optional alternate base path which the generated partition pattern will be aligned to. Default: [[-9999,0], [+9999,0]]
|
Example 1: You can stroke() an unclosed partition path with a given width= to make a wall that you can use to divide a part into two pieces.
include <BOSL2/std.scad>
linear_extrude(height=100)
stroke(
partition_path([
40, "jigsaw", 10, "jigsaw yflip", 40,
"hammerhead 30x20",
40, "jigsaw yflip", 10, "jigsaw", 40,
],
$fn=24
),
width=1
);
Example 2: Use repeat= to repeat a pattern.
include <BOSL2/std.scad>
linear_extrude(height=100)
stroke(
partition_path(
["jigsaw", "jigsaw yflip"],
repeat=3, $fn=24
),
width=1
);
Example 3: To make a mask that you can intersect with or difference from a part, you can extrude a polygon made from a closed path, offset by a slop width.
include <BOSL2/std.scad>
$slop = 0.2;
linear_extrude(height=100)
offset(r=-$slop)
polygon(
partition_path([
40, "jigsaw", 10, "jigsaw yflip", 40,
ptn_sect("hammerhead", length=30, width=20),
40, "jigsaw yflip", 10, "jigsaw", 40,
],
y=150,
$fn=24
)
);
Example 4: You can use list comprehensions in constructing partition path descriptions.
include <BOSL2/std.scad>
$slop = 0.2;
linear_extrude(height=100)
offset(r=-$slop)
polygon(
partition_path([
50,
"jigsaw",
30,
for (i=[1:4]) each ["sawtooth", "triangle"],
30,
"jigsaw yflip",
50,
],
y=150,
$fn=24
)
);
Table of Contents
Function Index
Topics Index
Glossary
Cheat Sheet
Tutorials
Basic Modeling:
- constants.scad STD
- transforms.scad STD
- attachments.scad STD
- shapes2d.scad STD
- shapes3d.scad STD
- masks.scad STD
- drawing.scad STD
- distributors.scad STD
- color.scad STD
- partitions.scad STD
- miscellaneous.scad STD
Advanced Modeling:
- paths.scad STD
- regions.scad STD
- skin.scad STD
- vnf.scad STD
- beziers.scad STD
- nurbs.scad
- rounding.scad STD
- turtle3d.scad
- isosurface.scad
Math:
- math.scad STD
- linalg.scad STD
- vectors.scad STD
- coords.scad STD
- geometry.scad STD
- trigonometry.scad STD
Data Management:
- version.scad STD
- comparisons.scad STD
- lists.scad STD
- utility.scad STD
- strings.scad STD
- structs.scad STD
- fnliterals.scad
Threaded Parts:
Parts:
- ball_bearings.scad
- cubetruss.scad
- gears.scad
- hinges.scad
- joiners.scad
- linear_bearings.scad
- modular_hose.scad
- nema_steppers.scad
- polyhedra.scad
- sliders.scad
- tripod_mounts.scad
- walls.scad
- wiring.scad
- hooks.scad
STD = Included in std.scad