mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-30 00:09:37 +00:00
bug fixes
This commit is contained in:
parent
174fb02e2b
commit
0007f1286c
2 changed files with 18 additions and 4 deletions
14
strings.scad
14
strings.scad
|
@ -332,6 +332,20 @@ function upcase(str) =
|
||||||
str_join([for(char=str) let(code=ord(char)) code>=97 && code<=122 ? chr(code-32) : char]);
|
str_join([for(char=str) let(code=ord(char)) code>=97 && code<=122 ? chr(code-32) : char]);
|
||||||
|
|
||||||
|
|
||||||
|
// Section: Random strings
|
||||||
|
|
||||||
|
// Function: rand_str()
|
||||||
|
// Usage:
|
||||||
|
// str = rand_str(n, [charset], [seed]);
|
||||||
|
// Description:
|
||||||
|
// Produce a random string of length `n`. If you give a string `charset` then the
|
||||||
|
// characters of the random string are drawn from that list, weighted by the number
|
||||||
|
// of times each character appears in the list. If you do not give a character set
|
||||||
|
// then the string is generated with characters ranging from 0 to z (based on
|
||||||
|
// character code).
|
||||||
|
function rand_str(n, charset, seed) =
|
||||||
|
is_undef(charset)? str_join([for(c=rand_int(48,122,n,seed)) chr(c)])
|
||||||
|
: str_join([for(i=rand_int(0,len(charset)-1,n,seed)) charset[i]]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -445,14 +445,14 @@ tag("keep")cube(100, center=true)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
If you need to mark multiple children with a tag, you can use the `tags()` module.
|
If you need to mark multiple children with a tag, you can use the `tag()` module.
|
||||||
|
|
||||||
```openscad-3D
|
```openscad-3D
|
||||||
include <BOSL2/std.scad>
|
include <BOSL2/std.scad>
|
||||||
diff("hole")
|
diff("hole")
|
||||||
cube(100, center=true)
|
cube(100, center=true)
|
||||||
attach([FRONT,TOP], overlap=20)
|
attach([FRONT,TOP], overlap=20)
|
||||||
tags("hole") {
|
tag("hole") {
|
||||||
cylinder(h=20.1, d1=0, d2=95);
|
cylinder(h=20.1, d1=0, d2=95);
|
||||||
down(10) cylinder(h=30, d=30);
|
down(10) cylinder(h=30, d=30);
|
||||||
}
|
}
|
||||||
|
@ -475,14 +475,14 @@ Some notable non-attachable modules are `text()`, `linear_extrude()`, `rotate_ex
|
||||||
`intersection()`, `offset()`, `hull()`, and `minkowski()`.
|
`intersection()`, `offset()`, `hull()`, and `minkowski()`.
|
||||||
|
|
||||||
To allow you to use tags-based operations with non-attachable shapes, you can wrap them with the
|
To allow you to use tags-based operations with non-attachable shapes, you can wrap them with the
|
||||||
`force_tags()` module to specify their tags. For example:
|
`force_tag()` module to specify their tags. For example:
|
||||||
|
|
||||||
```openscad-3D
|
```openscad-3D
|
||||||
include <BOSL2/std.scad>
|
include <BOSL2/std.scad>
|
||||||
diff("hole")
|
diff("hole")
|
||||||
cuboid(50)
|
cuboid(50)
|
||||||
attach(TOP)
|
attach(TOP)
|
||||||
force_tags("hole")
|
force_tag("hole")
|
||||||
rotate_extrude()
|
rotate_extrude()
|
||||||
right(15)
|
right(15)
|
||||||
square(10,center=true);
|
square(10,center=true);
|
||||||
|
|
Loading…
Reference in a new issue