tscad GitHub

Selectors

Fillets, chamfers and shells act on edges or faces that you pick with a selector. A selector is a filter over the finished body: "the edges at the top", "the vertical edges", "the circles of radius 3". Because it describes geometry rather than naming an edge, it survives parameter changes.

import { edges, faces } from "tscad"

<fillet radius={2} edges={edges.vertical()}>…</fillet>
<chamfer distance={1} edges=">Z">…</chamfer>
<shell thickness={2} open={faces.top()}>…</shell>

Every edges= / open= prop accepts a string, a builder (edges.… / faces.…) or a raw IR selector object. Leave edges out to take every edge.

Cheatsheet

PicksStringBuilder
everything"*"edges.all()
nothing"none"faces.none()
at the top (max Z)">Z"edges.top() · edges.max("z")
at the bottom (min Z)"<Z"edges.bottom() · edges.min("z")
at max / min X, Y">X" "<Y"edges.max("x") edges.min("y")
straight edges along Z"|Z"edges.vertical() · edges.parallel("z")
straight edges along X"|X"edges.parallel("x")
circles about Z"#Z"edges.circles() · edges.circles("z")
circles of radius rn/aedges.radius(3)
inside a boxn/aedges.within([x0, y0, z0], [x1, y1, z1])
by record indexn/aedges.index(4, 7)
both">Z and |X"edges.top().and(edges.parallel("x")) · edges.top().parallel("x")
either">Z or |Z"edges.top().or(edges.vertical())
not"not <Z"edges.bottom().not()

Strings are case-insensitive; not binds tighter than and, which binds tighter than or; use parentheses to group: "(>Z or <Z) and #Z". Chaining builder filters ANDs them: edges.top().circles() is "circles at the top".

What they mean

SelectorOn edgesOn faces
max / min axisedges lying wholly at the body's extreme along the axisfaces lying wholly there
parallel axisstraight edges along the axisplanar faces whose normal is ±axis
perpendicular axiscircles about the axisplanar faces whose normal is square to the axis
radius rcircles of radius rn/a
within boxedges whose sample points are all insidefaces likewise

Things to know:

Finding a selector