mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Minor tweaks to Shapes2d tutorital.
This commit is contained in:
parent
592e367cfb
commit
8d9d1f46a6
3 changed files with 102 additions and 22 deletions
|
@ -16,7 +16,7 @@
|
||||||
// Creates a mask for creating a Phillips drive recess given the Phillips size. Each mask can
|
// Creates a mask for creating a Phillips drive recess given the Phillips size. Each mask can
|
||||||
// be lowered to different depths to create different sizes of recess.
|
// be lowered to different depths to create different sizes of recess.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// size = The size of the bit as a number or string. "#0", "#1", "#2", "#3", or "#4"
|
// size = The size of the bit as an integer or string. "#0", "#1", "#2", "#3", or "#4"
|
||||||
// ---
|
// ---
|
||||||
// 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 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`
|
||||||
|
@ -323,4 +323,46 @@ module torx_mask(size, l=5, center, anchor, spin=0, orient=UP) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Section: Robertson/Square Drives
|
||||||
|
|
||||||
|
// Module: robertson_mask()
|
||||||
|
// Usage:
|
||||||
|
// robertson_mask(size, [extra]);
|
||||||
|
// Description:
|
||||||
|
// Creates a mask for creating a Robertson/Square drive recess given the drive size as an integer.
|
||||||
|
// Arguments:
|
||||||
|
// size = The size of the square drive, as an integer from 0 to 4.
|
||||||
|
// extra = Extra length of drive mask to create.
|
||||||
|
// Example:
|
||||||
|
// robertson_mask(size=2);
|
||||||
|
// Example:
|
||||||
|
// difference() {
|
||||||
|
// cyl(d1=2, d2=8, h=4, anchor=TOP);
|
||||||
|
// robertson_mask(size=2);
|
||||||
|
// }
|
||||||
|
module robertson_mask(size, extra=1) {
|
||||||
|
assert(is_int(size) && size>=0 && size<=4);
|
||||||
|
Mmin = [0.0696, 0.0900, 0.1110, 0.1315, 0.1895][size];
|
||||||
|
Mmax = [0.0710, 0.0910, 0.1126, 0.1330, 0.1910][size];
|
||||||
|
M = (Mmin + Mmax) / 2 * INCH;
|
||||||
|
Tmin = [0.063, 0.105, 0.119, 0.155, 0.191][size];
|
||||||
|
Tmax = [0.073, 0.113, 0.140, 0.165, 0.201][size];
|
||||||
|
T = (Tmin + Tmax) / 2 * INCH;
|
||||||
|
Fmin = [0.032, 0.057, 0.065, 0.085, 0.090][size];
|
||||||
|
Fmax = [0.038, 0.065, 0.075, 0.095, 0.100][size];
|
||||||
|
F = (Fmin + Fmax) / 2 * INCH;
|
||||||
|
ang = 2;
|
||||||
|
h = T + extra;
|
||||||
|
down(T) {
|
||||||
|
intersection(){
|
||||||
|
Mtop = M + 2*adj_ang_to_opp(F+extra,ang);
|
||||||
|
Mbot = M - 2*adj_ang_to_opp(T-F,ang);
|
||||||
|
prismoid([Mbot,Mbot],[Mtop,Mtop],h=h,anchor=BOT);
|
||||||
|
cyl(d1=0, d2=M/(T-F)*sqrt(2)*h, h=h, anchor=BOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
|
@ -729,11 +729,11 @@ module octagon(r, d, or, od, ir, id, side, rounding=0, realign=false, align_tip,
|
||||||
// ---
|
// ---
|
||||||
// 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 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`
|
||||||
// Example:
|
// Example(2D):
|
||||||
// right_triangle([40,30]);
|
// right_triangle([40,30]);
|
||||||
// Example: With `center=true`
|
// Example(2D): With `center=true`
|
||||||
// right_triangle([40,30], center=true);
|
// right_triangle([40,30], center=true);
|
||||||
// Example: Anchors
|
// Example(2D): Anchors
|
||||||
// right_triangle([40,30])
|
// right_triangle([40,30])
|
||||||
// show_anchors();
|
// show_anchors();
|
||||||
function right_triangle(size=[1,1], center, anchor, spin=0) =
|
function right_triangle(size=[1,1], center, anchor, spin=0) =
|
||||||
|
|
|
@ -133,7 +133,7 @@ square(50, center=true)
|
||||||
|
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
square(50, center=true)
|
square(50, center=true)
|
||||||
#square([30,50], anchor=FWD);
|
#square([20,40], anchor=FWD);
|
||||||
```
|
```
|
||||||
|
|
||||||
By adding the `position()` module, you can position the child at any anchorpoint on the parent:
|
By adding the `position()` module, you can position the child at any anchorpoint on the parent:
|
||||||
|
@ -177,25 +177,25 @@ module. It does not position the child. It only rotates it:
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
square(50, center=true)
|
square(50, center=true)
|
||||||
orient(anchor=LEFT)
|
orient(anchor=LEFT)
|
||||||
#square([10,50], anchor=FWD);
|
#square([10,40], anchor=FWD);
|
||||||
```
|
```
|
||||||
|
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
square(50, center=true)
|
square(50, center=true)
|
||||||
orient(anchor=FWD)
|
orient(anchor=FWD)
|
||||||
#square([10,50], anchor=FWD);
|
#square([10,40], anchor=FWD);
|
||||||
```
|
```
|
||||||
|
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
square(50, center=true)
|
square(50, center=true)
|
||||||
orient(anchor=RIGHT)
|
orient(anchor=RIGHT)
|
||||||
#square([10,50], anchor=FWD);
|
#square([10,40], anchor=FWD);
|
||||||
```
|
```
|
||||||
|
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
circle(d=50)
|
circle(d=50)
|
||||||
orient(polar_to_xy(1,30))
|
orient(polar_to_xy(1,30))
|
||||||
#square([10,50], anchor=FWD);
|
#square([10,40], anchor=FWD);
|
||||||
```
|
```
|
||||||
|
|
||||||
You can use `position()` and `orient()` together to both position and orient to an anchorpoint:
|
You can use `position()` and `orient()` together to both position and orient to an anchorpoint:
|
||||||
|
@ -204,7 +204,7 @@ You can use `position()` and `orient()` together to both position and orient to
|
||||||
square(50, center=true)
|
square(50, center=true)
|
||||||
position(RIGHT+BACK)
|
position(RIGHT+BACK)
|
||||||
orient(anchor=RIGHT+BACK)
|
orient(anchor=RIGHT+BACK)
|
||||||
#square([10,50], anchor=FWD);
|
#square([10,40], anchor=FWD);
|
||||||
```
|
```
|
||||||
|
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
|
@ -219,13 +219,13 @@ But it's simpler to just use the `attach()` module to do both at once:
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
square(50, center=true)
|
square(50, center=true)
|
||||||
attach(LEFT+BACK)
|
attach(LEFT+BACK)
|
||||||
#square([10,50], anchor=FWD);
|
#square([10,40], anchor=FWD);
|
||||||
```
|
```
|
||||||
|
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
circle(d=50)
|
circle(d=50)
|
||||||
attach(polar_to_xy(1,30))
|
attach(polar_to_xy(1,30))
|
||||||
#square([10,50], center=true);
|
#square([10,40], center=true);
|
||||||
```
|
```
|
||||||
|
|
||||||
Instead of specifying the `anchor=` in the child, you can pass a second argument to `attach()`
|
Instead of specifying the `anchor=` in the child, you can pass a second argument to `attach()`
|
||||||
|
@ -234,18 +234,18 @@ that tells it which side of the child to attach to the parent:
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
square([10,50], center=true)
|
square([10,50], center=true)
|
||||||
attach(BACK, LEFT)
|
attach(BACK, LEFT)
|
||||||
#square([10,50], center=true);
|
#square([10,40], center=true);
|
||||||
```
|
```
|
||||||
|
|
||||||
```openscad-2D
|
```openscad-2D
|
||||||
circle(d=50)
|
circle(d=50)
|
||||||
attach(polar_to_xy(1,30), LEFT)
|
attach(polar_to_xy(1,30), LEFT)
|
||||||
#square([10,50], center=true);
|
#square([10,40], center=true);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### `rect()`
|
#### Rectangles
|
||||||
|
|
||||||
The BOSL2 library provides an alternative to `square()`, that support more features. It is
|
The BOSL2 library provides an alternative to `square()`, that support more features. It is
|
||||||
called `rect()`. You can use it in the same way you use `square()`, but it also provides
|
called `rect()`. You can use it in the same way you use `square()`, but it also provides
|
||||||
|
@ -298,7 +298,7 @@ a corner, specify a 0 chamfer for that corner, and vice versa:
|
||||||
rect([60,40], rounding=[5,0,10,0], chamfer=[0,5,0,15]);
|
rect([60,40], rounding=[5,0,10,0], chamfer=[0,5,0,15]);
|
||||||
```
|
```
|
||||||
|
|
||||||
### `ellipse()`
|
#### Ellipses
|
||||||
|
|
||||||
The BOSL2 library also provides an enhanced equivalent of `circle()` called `ellipse()`.
|
The BOSL2 library also provides an enhanced equivalent of `circle()` called `ellipse()`.
|
||||||
You can use it in the same way you use `circle()`, but it also provides extended
|
You can use it in the same way you use `circle()`, but it also provides extended
|
||||||
|
@ -362,9 +362,47 @@ ellipse(d=50)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Trapezoids
|
#### Right Triangles
|
||||||
|
The BOSL2 library provides a simple way to make a 2D right triangle by using the `right_triangle()` module:
|
||||||
|
|
||||||
OpenSCAD doesn't provide a simple way to make 2D triangles, trapezoids, or parallelograms.
|
```openscad-2D
|
||||||
|
right_triangle([40,30]);
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use `xflip()` and `yflip()` to change which quadrant the triangle is formed in:
|
||||||
|
|
||||||
|
```openscad-2D
|
||||||
|
xflip() right_triangle([40,30]);
|
||||||
|
```
|
||||||
|
|
||||||
|
```openscad-2D
|
||||||
|
yflip() right_triangle([40,30]);
|
||||||
|
```
|
||||||
|
|
||||||
|
```openscad-2D
|
||||||
|
xflip() yflip() right_triangle([40,30]);
|
||||||
|
```
|
||||||
|
|
||||||
|
Or, alternatively, just rotate it into the correct quadrant with `spin=`:
|
||||||
|
|
||||||
|
```openscad-2D
|
||||||
|
right_triangle([40,30], spin=90);
|
||||||
|
```
|
||||||
|
|
||||||
|
```openscad-2D
|
||||||
|
right_triangle([40,30], spin=-90);
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also use anchoring with right triangles:
|
||||||
|
|
||||||
|
```openscad-2D
|
||||||
|
right_triangle([40,30], anchor=FWD+RIGHT);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Trapezoids
|
||||||
|
|
||||||
|
OpenSCAD doesn't provide a simple way to make general 2D triangles, trapezoids, or parallelograms.
|
||||||
The BOSL2 library can provide all of these shapes with the `trapezoid()` module.
|
The BOSL2 library can provide all of these shapes with the `trapezoid()` module.
|
||||||
|
|
||||||
To make a simple triangle, just make one of the widths zero:
|
To make a simple triangle, just make one of the widths zero:
|
||||||
|
@ -417,7 +455,7 @@ trapezoid(w1=30, w2=50, h=50)
|
||||||
show_anchors();
|
show_anchors();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Regular N-Gons
|
#### Regular N-Gons
|
||||||
|
|
||||||
OpenSCAD lets you make regular N-gons (pentagon, hexagon, etc) by using `circle()` with `$fn`.
|
OpenSCAD lets you make regular N-gons (pentagon, hexagon, etc) by using `circle()` with `$fn`.
|
||||||
While this is concise, it may be less than obvious at first glance:
|
While this is concise, it may be less than obvious at first glance:
|
||||||
|
@ -507,7 +545,7 @@ pentagon(d=30)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Stars
|
#### Stars
|
||||||
|
|
||||||
The BOSL2 library has stars as a basic supported shape. They can have any number of points.
|
The BOSL2 library has stars as a basic supported shape. They can have any number of points.
|
||||||
You can specify a star's shape by point count, inner and outer vertex radius/diameters:
|
You can specify a star's shape by point count, inner and outer vertex radius/diameters:
|
||||||
|
@ -583,7 +621,7 @@ star(n=5, step=2, d=40)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Teardrop2D
|
#### Teardrop2D
|
||||||
|
|
||||||
Often when 3D printing, you may want to make a circular hole in a vertical wall. If the hole is
|
Often when 3D printing, you may want to make a circular hole in a vertical wall. If the hole is
|
||||||
too big, however, the overhang at the top of the hole can cause problems with printing on an
|
too big, however, the overhang at the top of the hole can cause problems with printing on an
|
||||||
|
@ -625,7 +663,7 @@ teardrop2d(d=50, ang=30, cap_h=30)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Glued Circles
|
#### Glued Circles
|
||||||
|
|
||||||
A more unusal shape that BOSL2 provides is Glued Circles. It's basically a pair of circles,
|
A more unusal shape that BOSL2 provides is Glued Circles. It's basically a pair of circles,
|
||||||
connected by what looks like a gloopy glued miniscus:
|
connected by what looks like a gloopy glued miniscus:
|
||||||
|
|
Loading…
Reference in a new issue