Browse the docs
betti script
Run a script of operations, in Starlark.
Usage
betti script [flags] file.star [arg...]A script is a Starlark program (a dialect of Python) whose functions are the operations: the core ones by name (info, box, verify, convert), the others in their module, as fix.repair, mesh.remesh, cad.heal or volume.tet. Inputs are positional, meshes and models or file names; options are keywords, named as the command's flags with - as _, as mesh.remesh(m, size = "1%", quads = True).
An operation that makes something returns it, or a tuple (shape.cut returns below and above); with report = True, a struct of its report and what it makes. One that only reports returns its report, as info(m).holes; output flags asked for, as map = True, come back as values in it.
read(path) reads a mesh, read_cad(path) a CAD model, read_volume(path) a volume mesh; save(value, path) writes any of them, or what an operation made, by the extension of path. args holds the words after the script's name; json and math are Starlark's modules.
Each operation checks its own module's licence, as on the command line. Ctrl-C stops the script.
Examples
betti script prepare.star part.stl
betti script -q batch.star parts/*.stl
betti script -v mesh-all.starThe language
| values | numbers (1, 2.5, 1e-3; integers of any size), strings ("a", a, """lines"""), True, False, None, lists [1, 2], tuples (1, 2), dicts {"k": 1}, set([1, 2]) |
|---|---|
| names | x = 1; a, b = pair; x += 1. Blocks are indented, after a line ending in a colon; # starts a comment |
| arithmetic | + - * / // % and the bit operators; / always gives a float, // rounds down. No **: math.pow(x, 2), math.sqrt(x) |
| comparison | == != < <= > >=, in, not in, and, or, not, and x if c else y. Comparisons do not chain: a < b and b < c |
| control | if c: elif c: else:, for x in seq:, while c:, break, continue, pass. range(n), range(a, b, step) |
| functions | def f(a, b = 2, *rest, **kw): return a + b; lambda x: x * 2. A function reads globals but cannot assign them: return the value instead |
| comprehensions | [x * 2 for x in xs if x > 0], {k: v for k, v in d.items()} |
| strings | s[0], s[1:3], len(s), "b" in s, s.split(","), ",".join(l), s.strip(), s.replace(a, b), s.startswith(p), s.removesuffix(".stl"), s.upper(). Not iterable: for c in s.elems() |
| formatting | "%s has %d faces" % (name, n), with %s %d %f %e %g %r; "{} {}".format(a, b). No precision (%.3f): round as math.round(x * 1000) / 1000 |
| lists | l[i], l[-1], l[a:b], l.append(x), l.extend(m), l.pop(), l.insert(i, x), l.remove(x), l.index(x), l + m, sorted(l, key = f, reverse = True) |
| dicts | d[k], d[k] = v, d.get(k, default), k in d, d.keys(), d.values(), d.items(), d.pop(k), d.update(e); kept in insertion order |
| built-ins | len range sorted reversed enumerate zip min max abs any all int float str bool repr type dir getattr hasattr print fail |
| not in Starlark | classes, import, try/except (an error stops the script; fail("why") stops it on purpose), f-strings, is, **, round, global |
The full guide, with worked scripts: https://betti.dev/docs/scripting/
Output flags
| Flag | Takes | Default | Meaning |
|---|---|---|---|
-json | switch | off | print the result as JSON |
-q | switch | off | print nothing but errors |
-skip | names | none | switch off steps of the work by their names, separated by commas, as the built-in help lists them |
-v | switch | off | also show the stages of each step, and their times |
This page is generated from betti help script. Lengths are absolute, or a percentage of the part's bounding-box diagonal, as in -size 1%.