mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-04 03:09:45 +00:00
Merge pull request #612 from revarbat/revarbat_dev
Explain using tags-based operations with non-attachable shapes.
This commit is contained in:
commit
7e75d03f6a
2 changed files with 52 additions and 6 deletions
|
@ -1629,6 +1629,20 @@ module show(tags="")
|
|||
// rounding_mask_z(l=p.z, r=25);
|
||||
// }
|
||||
// }
|
||||
// Example: Working with Non-Attachables Like rotate_extrude()
|
||||
// back_half()
|
||||
// diff("remove")
|
||||
// cuboid(40) {
|
||||
// attach(TOP)
|
||||
// recolor("lightgreen")
|
||||
// cyl(l=10,d=30);
|
||||
// position(TOP+RIGHT)
|
||||
// tags("remove")
|
||||
// xrot(90)
|
||||
// rotate_extrude()
|
||||
// right(20)
|
||||
// circle(5);
|
||||
// }
|
||||
module diff(neg, pos, keep)
|
||||
{
|
||||
// Don't perform the operation if the current tags are hidden
|
||||
|
@ -1680,6 +1694,19 @@ module diff(neg, pos, keep)
|
|||
// attach(CENTER) cube([40,100,100], anchor=CENTER, $tags="mask");
|
||||
// attach(CENTER) xcyl(d=40, l=100, $tags="axle");
|
||||
// }
|
||||
// Example: Working with Non-Attachables
|
||||
// intersect("A", "B")
|
||||
// cuboid(50, $tags="A") {
|
||||
// tags("B")
|
||||
// hull() {
|
||||
// down(25)
|
||||
// linear_extrude(height=0.01)
|
||||
// square(55,center=true);
|
||||
// up(25)
|
||||
// linear_extrude(height=0.01)
|
||||
// circle(d=45);
|
||||
// }
|
||||
// }
|
||||
module intersect(a, b=undef, keep=undef)
|
||||
{
|
||||
// Don't perform the operation if the current tags are hidden
|
||||
|
|
|
@ -387,6 +387,25 @@ cube([20,11,45], center=true, $tags="hole")
|
|||
cube([40,10,90], center=true, $tags="body");
|
||||
```
|
||||
|
||||
Tags (and therefore tag-based operations like `diff()`) only work correctly with attachable children.
|
||||
However, a number of built-in modules for making shapes are *not* attachable. Some notable
|
||||
non-attachable modules are `circle()`, `square()`, `text()`, `linear_extrude()`, `rotate_extrude()`,
|
||||
`polygon()`, `polyhedron()`, `import()`, `surface()`, `union()`, `difference()`, `intersection()`,
|
||||
`offset()`, `hull()`, and `minkowski()`.
|
||||
|
||||
To allow you to use tags-based operations with non-attachable shapes, you can wrap them with the
|
||||
`tags()` module to specify their tags. For example:
|
||||
|
||||
```openscad
|
||||
diff("hole")
|
||||
cuboid(50)
|
||||
attach(TOP)
|
||||
tags("hole")
|
||||
rotate_extrude()
|
||||
right(15)
|
||||
square(10,center=true);
|
||||
```
|
||||
|
||||
### `intersect(a, <b>, <keep>)`
|
||||
|
||||
To perform an intersection of attachables, you can use the `intersect()` module. If given one
|
||||
|
@ -481,9 +500,9 @@ rounding a corner:
|
|||
```openscad
|
||||
module round_corner(r) difference() {
|
||||
translate(-[1,1,1])
|
||||
cube(r+1);
|
||||
cube(r+1);
|
||||
translate([r,r,r])
|
||||
sphere(r=r, style="aligned", $fn=quantup(segs(r),4));
|
||||
sphere(r=r, style="aligned", $fn=quantup(segs(r),4));
|
||||
}
|
||||
round_corner(r=10);
|
||||
```
|
||||
|
@ -493,9 +512,9 @@ You can use that mask to round various corners of a cube:
|
|||
```openscad
|
||||
module round_corner(r) difference() {
|
||||
translate(-[1,1,1])
|
||||
cube(r+1);
|
||||
cube(r+1);
|
||||
translate([r,r,r])
|
||||
sphere(r=r, style="aligned", $fn=quantup(segs(r),4));
|
||||
sphere(r=r, style="aligned", $fn=quantup(segs(r),4));
|
||||
}
|
||||
diff("mask")
|
||||
cube([50,60,70],center=true)
|
||||
|
@ -509,9 +528,9 @@ You can use `edge_mask()` and `corner_mask()` together as well:
|
|||
```openscad
|
||||
module round_corner(r) difference() {
|
||||
translate(-[1,1,1])
|
||||
cube(r+1);
|
||||
cube(r+1);
|
||||
translate([r,r,r])
|
||||
sphere(r=r, style="aligned", $fn=quantup(segs(r),4));
|
||||
sphere(r=r, style="aligned", $fn=quantup(segs(r),4));
|
||||
}
|
||||
module round_edge(l,r) difference() {
|
||||
translate([-1,-1,-l/2])
|
||||
|
|
Loading…
Reference in a new issue