Pipe reference

Every Pipe primitive, operation, selector, transform, material, query and expression, with parameters, defaults and a working example.

This page lists everything the Pipe language can do. Every example on it builds on the real engine. New to Pipe? Read the language guide first.

Signatures use name=default for optional parameters. Most parameters can be passed by position or by name: cyl(5, 10, segs=64) and cyl(r=5, h=10, segs=64) are the same.

Syntax at a glance

Pipe
# A comment. Everything after # on a line is ignored.units("mm")                       # set the model unit firstwall = 2                          # a number (scalar)base = box(60, 40, 10, z0=0)      # a named partbase = base | fillet(vertical, 4) # pipe the part through an operationbase = base  | shell(wall)                   # a pipeline can span several lines  | color(0.2, 0.6, 0.9)_cutter = cyl(3, 50)              # names starting with _ are helpers, not partsbase = base | cut(_cutter, at=[(-20, 0, 0), (20, 0, 0)])
ElementFormNotes
Partname = exprA solid with a name. Every top-level mesh variable is a visible part: name helpers and cutters with _.
Helper_name = exprLocal to the step. Never shown, exported or kept.
Scalarname = 2.5Numbers persist between steps.
Macrodef f(x, h=5) = exprKept for later steps (undo removes it).
Pipelinea | op(...) | op(...)Each operation takes the solid on its left.
Function formop(a, ...)add(a, b) is the same as a | add(b).
Point(x, y, z)2D points are (x, y).
List[a, b, c]Lists of points, profiles, numbers.
String"text"For text3d, mat names, quoted selectors. "a" + "b" joins; str(3) is "3".
Keywordname=valueOptional parameters, in any order after the positional ones.

Placement options for primitives

Every primitive accepts these keywords, with two exceptions: in extrude2d, z0 is the start height of the extrusion, and arc_tube is placed with center= instead of at=. They are applied in this order: rot, then at, then z0.

KeywordMeaning
rot=(rx, ry, rz)Rotate in degrees about the X, Y, then Z axis (around the origin, before moving).
at=(x, y, z)Move the primitive's centre to this point (not its base: use z0 for that).
at=[(x, y, z), ...]Place one copy at each point and join them into one solid.
z0=zMove the primitive up or down so its lowest point sits at z.

Primitives are centred on the origin unless you place them. z0=0 is the usual way to stand a part on the bed.

Pipe
units("mm")post = cyl(4, 30, z0=0)                                  # stands on z = 0posts = cyl(2, 10, z0=0, at=[(-10, 0, 0), (10, 0, 0)])   # two copies, one parttilted = box(20, 5, 5, rot=(0, 0, 45), at=(0, 30, 0))

Primitives

box

box(sx, sy=sx, sz=sy) · aliases for the sizes: x/w/width, y/d/depth, z/h/height

An axis-aligned box of size sx × sy × sz, centred on the origin. box(10) is a 10 mm cube.

Pipe
units("mm")plate = box(80, 50, 4, z0=0)

cyl

cyl(r, h, segs=32, axis=z) · alias cylinder

A cylinder of radius r and height h along axis: x, y, z, or a direction (dx, dy, dz) to point it anywhere. segs is the number of sides (3–1024): use 48–96 for round holes you will measure, 6 for a hexagon (vertices at 0°, 60°, …).

Pipe
units("mm")rod = cyl(5, 40, segs=64, z0=0)hex = cyl(6, 4, segs=6, at=(20, 0, 0))axle = cyl(2, 30, axis=x, at=(0, 20, 5))

cone

cone(r0, r1, h, segs=32, axis=z) · alias frustum

A cone or frustum: radius r0 at the bottom, r1 at the top. Set one radius to 0 for a point. axis works as for cyl; a direction (dx, dy, dz) points the cone from its r0 end to its r1 end, so pointing a spike needs no rotation maths.

Pipe
units("mm")funnel = cone(20, 6, 25, z0=0, segs=64)spike = cone(5, 0, 12, at=(40, 0, 0))horn = cone(3, 0, 15, axis=(1, 1, 1), at=(70, 0, 10))

sphere

sphere(r, segs=32)

A closed UV sphere. segs (4–1024) sets smoothness.

Pipe
units("mm")ball = sphere(10, segs=64, z0=0)

torus

torus(R, r, segs=32)

A ring with major radius R (centre to tube centre) and tube radius r, lying flat in the XY plane.

Pipe
units("mm")ring = torus(20, 3, segs=64, z0=0)

pipe

pipe(ro, ri, h, segs=32, axis=z) · alias hollow_cyl

A hollow cylinder (tube) with outer radius ro, inner radius ri and height h. Faster and cleaner than cutting one cylinder from another.

Pipe
units("mm")spacer = pipe(6, 3.2, 10, segs=64, z0=0)

revolve

revolve([(r, z), ...], segs=32)

Spins a profile of (radius, height) points around the Z axis (a lathe). An outline that touches the axis closes itself to it. An outline that never touches the axis is a closed cross-section and makes a ring (a watch bezel, a tyre), unless joining its two ends would cross it (a vase wall, which still closes to the axis). For a hollow shape that touches the axis, trace the outer wall, the rim and the inner wall back to r = 0. segs (3–1024) is the number of sides: segs=4 makes a square pyramid roof.

Pipe
units("mm")bowl = revolve([(0, 0), (50, 0), (55, 20), (48, 20), (32, 2), (0, 2)], segs=96)knob = revolve([(0, 0), (12, 0), (12, 6), (8, 14), (0, 16)], segs=64, at=(100, 0, 0))bezel = revolve([(22.3, 10), (24.4, 10), (24.25, 11.2), (23.4, 11.9), (22.3, 11.6)], segs=96, at=(0, 100, 0))roof = revolve([(0, 0), (10, 0), (0, 8)], segs=4, at=(100, 100, 0))

extrude2d

extrude2d([(x, y), ...], z0=0, z1=1, holes=[])

Extrudes a closed 2D polygon from height z0 to z1. holes is a list of inner polygons that become through-holes, with no boolean needed. Placement: rot and at (not z0, which is the start height here).

Pipe
units("mm")bracket = extrude2d([(0, 0), (40, 0), (40, 6), (6, 6), (6, 30), (0, 30)], 0, 20)frame = extrude2d([(0, 0), (30, 0), (30, 20), (0, 20)], 0, 3,  holes=[[(5, 5), (25, 5), (25, 15), (5, 15)]]) | move(60, 0, 0)

Generate smooth outlines with a list comprehension:

Pipe
units("mm")n = 72star = extrude2d([((20 + 4 * cos(6 * i * 2 * pi / n)) * cos(i * 2 * pi / n),                   (20 + 4 * cos(6 * i * 2 * pi / n)) * sin(i * 2 * pi / n)) for i in range(n)], 0, 8)

loft

loft([(z, [(x, y), ...]), ...], segs=24)

A smooth solid through 2D cross-sections at heights z. Sections may have different point counts. segs (8–1024) sets the smoothness between sections.

Pipe
units("mm")square = [(-15, -15), (15, -15), (15, 15), (-15, 15)]small = [(-6, -6), (6, -6), (6, 6), (-6, 6)]tower = loft([(0, square), (40, small), (60, square)])

sweep

sweep(profile2d, path3d, scale_end=1.0, twist=0.0, closed=false)

Sweeps a 2D profile along a 3D path. scale_end scales the profile at the end of the path (taper), twist rotates it in degrees along the way, closed=true joins a looped path.

Pipe
units("mm")square = [(-3, -3), (3, -3), (3, 3), (-3, 3)]horn = sweep(square, bezier([(0, 0, 0), (0, 0, 40), (40, 0, 40)]), scale_end=0.4)column = sweep(square, [(0, 0, 0), (0, 0, 50)], twist=90) | move(60, 0, 0)

tube

tube([(x, y, z), ...], r=0.08, segs=12, closed=false, caps="flat")

A round tube along a 3D polyline, or a smooth bezier() / nurbs() path. closed=true makes a loop. caps="round" ends an open tube in hemispheres (fingers, cables, limbs).

Pipe
units("mm")handle = tube(bezier([(0, 0, 0), (0, 0, 40), (60, 0, 40), (60, 0, 0)]), r=4, segs=24)loop = tube([(0, 0, 0), (20, 0, 0), (20, 20, 0), (0, 20, 0)], r=1.5, closed=true) | move(0, 40, 0)finger = tube([(0, 0, 0), (0, 0, 12), (3, 0, 20)], r=2, caps="round") | move(0, 80, 0)

arc_tube

arc_tube(center=(0, 0, 0), rx=, rz=rx, start=-90, end=90, r=0.08, segs=16)

A tube along an elliptical arc in the XZ plane: radii rx and rz, from angle start to end in degrees (0° points along +X, 90° up). Good for handles.

Pipe
units("mm")mug = cyl(40, 90, z0=0, segs=96) | shell(3)handle = arc_tube(center=(42, 0, 45), rx=18, rz=25, start=-85, end=85, r=5)mug = mug | add(handle)

sheet

sheet([[(x, y, z), ...], ...], t=0.02, closed=false)

A thin solid through a grid of 3D points (rows of the same length), thickened by t. closed=true wraps each row into a loop. Use it for curved panels.

Pipe
units("mm")panel = sheet([[(0, 0, 0), (20, 0, 0), (40, 0, 0)],               [(0, 20, 6), (20, 20, 10), (40, 20, 6)],               [(0, 40, 0), (20, 40, 0), (40, 40, 0)]], t=2)

thread

thread(r0, r1=1.15·r0, pitch=0.3·r0, turns=4, segs=28) · alias helix

A helical screw thread with minor radius r0, major radius r1, pitch (rise per turn) and number of turns. It starts at z = 0 and rises pitch × turns. Add it to a core cylinder for a bolt, cut it from a bore for a nut. See Threaded jar.

Pipe
units("mm")_core = cyl(4.2, 18, z0=0, segs=48)screw = thread(4, 5, 1.25, 12) | add(_core) | add(cyl(7, 4, segs=6, z0=-3.9))

gear

gear(teeth, m=1.0, h=1.0, pressure_angle=20, bore=0) · aliases module=, z=/n= for teeth

An involute spur gear with teeth teeth of module m (pitch diameter = m × teeth), thickness h and an optional centre hole of radius bore. Tooth 0 points along +X.

Two gears mesh when their centres are m × (z1 + z2) / 2 apart. Rotate the second gear by 180 / z2 degrees when z2 is even (0° when odd).

Pipe
units("mm")m = 2big = gear(24, m=m, h=6, bore=2.5)small = gear(12, m=m, h=6, bore=2.5) | rot(0, 0, 180 / 12) | move(m * (24 + 12) / 2, 0, 0)

text3d

text3d("text", height=0.5, depth=0.1) · aliases size= for height, text(...) for the function

Solid extruded lettering, centred on the origin in X and Y and extruded from z = 0 up to depth. height is the letter height.

Pipe
units("mm")plate = box(70, 20, 3, z0=0) | fillet(vertical, 3)label = text3d("ZOLID", height=10, depth=1) | move(0, 0, 3)

load

load("file.stl") reads a mesh (.stl, .obj or .glb) as a solid. In Zolid, the file must be imported into the project first: the studio's Import button (or drop it on the viewer) and the agent's import tool do that and write the load() step for you, for example:

Text
# import bracket.stlbracket = load("bracket.stl") | scale(0.1, 0.1, 0.1)

STL and OBJ have no unit and are read as millimetres; the scale turns them into the project's unit (here cm). GLB is in metres and needs no scale. The mesh must be one closed solid. Projects with imported files can't be shared as a /v#… link; a share page works.

Curves

Curves return a list of 3D points. Use them as paths for tube, sweep and deform("curve").

FunctionSignatureNotes
bezierbezier([(x, y, z), ...], segs=24)Smooth curve pulled towards the control points; passes through the first and last.
nurbsnurbs([(x, y, z), ...], degree=3, segs=32, weights=)Clamped NURBS curve; weights per control point. Alias bspline.
Pipe
units("mm")path = nurbs([(0, 0, 0), (20, 20, 0), (40, 0, 20), (60, 20, 20)], degree=3)cable = tube(path, r=2, segs=16)

Booleans

add(b, at=, fillet=0, segs=6) · cut(b, at=, fillet=0, segs=6) · intersect(b)

OperationAliasesResult
add(b)unionJoins b to the part. b may be a list of meshes; add([a, b, c]) joins a list.
cut(b)sub, diffRemoves b from the part.
intersect(b)Keeps only what the two share.

Options for add and cut:

  • at=(x, y, z) moves b there first; at=[...] uses one copy per point in a single fast batch. Prefer this to chaining many cut calls.
  • fillet=r rounds the seam where the two solids meet with radius r: a fillet for add, a rounded edge for cut. segs (default 6) sets the number of strips; segs=1 gives a chamfer.
Pipe
units("mm")plate = box(80, 50, 4, z0=0) | fillet(vertical, 6)plate = plate | cut(cyl(2.6, 20, segs=48), at=[(-32, -17, 0), (32, -17, 0), (-32, 17, 0), (32, 17, 0)])plate = plate | add(cyl(6, 16, z0=3.9), fillet=2)plate = plate | cut(cyl(3, 40, segs=48), fillet=1)
Pipe
units("mm")lens = sphere(20) | intersect(sphere(20, at=(24, 0, 0)))

Tips:

  • Make cutters longer than the part, so they pass cleanly through (a 4 mm plate, a 20 mm cutter).
  • Overlap solids you add by a little (0.1 mm) instead of letting them touch at one face.
  • fillet= must fit: a radius larger than the material around the seam fails.
  • fillet= needs a closed seam, such as a boss standing on a face or a hole through it. If the seam runs off the edge of the part (a wall as wide as its base), the step fails; use fillet(edges, r) on the result instead.

Edge finishing

fillet

fillet(edges, r, segs=4)

Rounds the selected edges with radius r. segs sets the number of strips around each round.

Pipe
units("mm")block = box(40, 30, 20, z0=0) | fillet(vertical, 5) | fillet(top_rim, 2)

bevel

bevel(edges, w, segs=1)

Cuts the selected edges back by w. With segs=1 it is a chamfer; more segments approximate a round.

Pipe
units("mm")block = box(40, 30, 20, z0=0) | bevel(top_rim, 2)soft = box(40, 30, 20, z0=0, at=(50, 0, 0)) | bevel(vertical, 6, segs=4)

Edge selectors

Pass these to fillet and bevel. Bare words work; selectors with punctuation need quotes.

SelectorSelects
allEvery edge.
verticalEdges parallel to Z (the corners of a box seen from above).
horizontalEdges in the XY plane.
top_rimEdges around the top face.
bottom_rimEdges around the bottom face.
outer_rimTop and bottom rims.
sharpEdges where faces meet at more than 35°.
"sharp:20"Edges sharper than the given angle in degrees.
"between:top,front"Edges shared by two face groups (any face selectors).
boundaryOpen edges (rare in a watertight solid).
Pipe
units("mm")wedge = box(40, 20, 20, z0=0) | fillet("between:top,front", 6)

A radius too large for the edge fails without changing anything:

Pipe · fails on purpose
units("mm")block = box(10, 10, 10) | fillet(vertical, 6)# error: radius 6 is too large

Faces

extrude

extrude(faces, d)

Pushes the selected faces outwards by d (negative pulls them in).

Pipe
units("mm")block = box(20, 20, 10, z0=0) | extrude(top, 5)

inset

inset(faces, amt, depth=0)

Shrinks the selected faces inwards by amt, leaving a border. A negative depth sinks the new face to make a recess; a positive one raises it. Inset needs a flat face wider than twice amt: apply it before fillets or bevels that split the face.

Pipe
units("mm")tray = box(60, 40, 10, z0=0) | inset(top, 4, depth=-6)

Face selectors

SelectorSelects
top, bottomFaces pointing up (+Z) or down (−Z).
front, backFaces pointing to −Y or +Y.
left, rightFaces pointing to −X or +X.
sidesFaces roughly vertical.
allEvery face.
"z>5", "x<0", …Faces whose centre is above or below a coordinate.

Hollowing

shell

shell(t, open_top=true)

Hollows a solid, leaving walls of thickness t. By default the top is open (a box, a cup). open_top=false makes a closed hollow part. Round the outside before shelling so the inside follows it.

Pipe
units("mm")cup = cyl(30, 60, z0=0, segs=96) | fillet(bottom_rim, 4) | shell(2)

solidify

solidify(t, offset=-1.0, open_top=false)

Offsets the surface along its normals to make a shell of thickness t. Safer than shell on curved or concave shapes. offset=-1 grows the wall inwards, 1 outwards.

Pipe
units("mm")bowl = sphere(30, segs=64) | bisect() | solidify(2, open_top=true)

Smoothing

subsurf

subsurf(levels=1, crease=false) · alias subdiv

Catmull-Clark subdivision: rounds a blocky shape into a smooth one. levels 1–4. crease=true keeps edges sharper than 55° (or pass an angle). The shape shrinks slightly.

Pipe
units("mm")pebble = box(40, 30, 16) | subsurf(3)cap = cyl(15, 10, segs=16, at=(50, 0, 0)) | subsurf(2, crease=true)

Patterns

array

array(n, (dx, dy, dz), union=true) · alias pattern_linear

n copies in total, each moved by the step from the previous one. With union=false the copies stay separate pieces of the same part.

Pipe
units("mm")teeth = box(4, 10, 6, z0=0) | array(8, (7, 0, 0))

radial

radial(n, r=0, axis=z, union=true) · alias pattern_radial

n copies evenly spaced around axis, each placed at distance r from it.

Pipe
units("mm")wheel = cyl(30, 6, z0=0, segs=96)wheel = wheel | cut(cyl(5, 20) | radial(6, r=18))

mirror

mirror(x|y|z, union=true)

Mirrors across the plane through the origin normal to the axis and keeps the original plus the mirrored copy (symmetrise one half). To flip a part without keeping the original, use union=false.

Pipe
units("mm")half = box(20, 10, 10, at=(15, 0, 0)) | fillet(vertical, 3)pair = half | mirror(x)

Patterns with at=

For holes and studs, a point list is often clearer. Comprehensions build grids:

Pipe
units("mm")board = box(100, 60, 3, z0=0)board = board | cut(cyl(1.5, 10, segs=32), at=[(-40 + 10 * (i % 9), -20 + 10 * floor(i / 9), 0) for i in range(45)])

Transforms

OperationMeaning
move(x, y, z)Translate. Alias translate.
rot(rx, ry, rz, about=)Rotate in degrees about X, then Y, then Z. Around the origin unless about= is given.
scale(sx, sy=sx, sz=sy, about=)Scale. scale(2) doubles every axis. Around the origin unless about= is given.
align(axis, min|center|max, val=0)Move along one axis so the part's min, centre or max lands on val.
align_z0(z=0)Move so the lowest point is at z. Same as align(z, min, z).
on(base, gap=0)Move the part up or down so it rests on top of base (plus gap). X and Y stay where they are.

about= takes a point (x, y, z), "center" (bounding-box centre) or "base" (centre of the bottom).

Pipe
units("mm")table = box(80, 50, 4, z0=0)vase = cyl(10, 30, segs=64) | on(table)arm = box(40, 6, 6) | rot(0, 0, 30, about="center") | align(x, min, 50)big = sphere(5) | scale(2, 2, 1, about="base") | move(0, 40, 0)

Deform

deform(mode, axis=z, angle=45, factor=0.5, subdivs=0)

Bends, twists or tapers a part along an axis. The part is subdivided automatically so the result is smooth.

ModeParametersEffect
"twist"axis, angleRotates cross-sections progressively, angle degrees end to end.
"bend"axis, angleCurves the part by angle degrees along axis.
"taper"axis, factorScales cross-sections along axis: positive factor flares, negative narrows.
"curve"path, axisBends the part so its axis follows a 3D path.
"lattice"cornersFree-form warp by moving the 8 corners of the bounding box, ordered 000, 100, 010, 110, 001, 101, 011, 111 (x, y, z bits).
Pipe
units("mm")twisted = box(20, 20, 60, z0=0) | deform("twist", axis=z, angle=90)bent = box(8, 8, 60, z0=0, at=(40, 0, 0)) | deform("bend", axis=z, angle=60)flared = cyl(10, 50, z0=0, segs=64, at=(-40, 0, 0)) | deform("taper", axis=z, factor=0.6)
Pipe
units("mm")rail = box(60, 6, 6) | deform("curve", path=bezier([(0, 0, 0), (30, 20, 0), (60, 0, 0)]), axis=x)

Cutting and repair

OperationMeaning
bisect(normal=(0, 0, 1), offset=0, clear_inner=false)Cuts the part with a plane and caps it. Keeps the side behind the plane: with the default normal, everything below z = offset. Flip the normal to keep the other side.
remesh(voxel_size=0)Rebuilds the surface on a voxel grid; heals messy or multi-shell meshes into one watertight solid. 0 picks a size automatically.
decimate(ratio=0.5, faces=)Reduces the triangle count while staying watertight. faces= targets a face count. Alias lod.
Pipe
units("mm")half = sphere(20, segs=64) | bisect()top = sphere(20, segs=64, at=(50, 0, 0)) | bisect(normal=(0, 0, -1), offset=5)light = sphere(20, segs=96, at=(100, 0, 0)) | decimate(0.3)

Colour and materials

color

color(r, g, b, a=1, faces=)

Sets the display colour, with each channel from 0 to 1. faces= colours only the selected faces. Colours show in the viewer, previews and GLB exports.

Pipe
units("mm")tile = box(30, 30, 4, z0=0) | color(0.95, 0.95, 0.97) | color(0.56, 0.43, 1, faces=top)

mat

mat(name, color=(r, g, b[, a]), metallic=0, roughness=0.5, alpha=1, emissive=(r, g, b), emissive_strength=1, transmission=0, ior=1.5, double_sided=false, faces=)

A full physically based material for renders and GLB: metals, glass, glowing parts. A material is defined once and reused by name: mat("brushed steel") with no other properties gives a part the last definition of that name, in this step or any later one. Giving properties again redefines it for later uses; parts painted before keep theirs. The studio, the live view and share pages show it as your agent's preview does: metal and roughness, the glow, and glass you can see through (alpha, or transmission alone).

Pipe
units("mm")knob = cyl(10, 8, z0=0, segs=64) | mat("brushed steel", color=(0.62, 0.66, 0.72), metallic=0.9, roughness=0.3)lamp = sphere(8, at=(30, 0, 8)) | mat("glow", color=(1, 0.9, 0.7), emissive=(1, 0.78, 0.45), emissive_strength=2)glass = cyl(8, 20, z0=0, at=(60, 0, 0)) | mat("glass", color=(0.9, 0.95, 1), transmission=0.9, roughness=0.05)

Shading and UVs

These change how a part looks in the viewer and in GLB files, not its shape.

OperationMeaning
smooth(angle=35, weighted=true)Smooth shading across edges flatter than angle.
flat()Faceted shading.
unwrap(angle=45, margin=0.01)Automatic UV unwrap for textures. Alias uv.
box_uv(tile=1)Box-projected UVs, one repeat per tile units.
vcolor(color=, low=, high=, axis=z, ...)Bakes vertex colours: gradients from low to high along axis, sun and shadow ramps, ambient occlusion.
Pipe
units("mm")egg = sphere(20, segs=64) | scale(1, 1, 1.3) | smooth(40)fade = box(20, 20, 40, at=(50, 0, 0)) | vcolor(low=(0.1, 0.2, 0.8), high=(0.95, 0.8, 0.2), axis=z)

Scene and parts

StatementMeaning
name = ...Creates or replaces the part name.
_name = ...A helper that is not part of the model.
del("name")Removes a part. Alias remove. del(["a", "b"]) removes several; del("list") drops a list variable.
merge([a, b, ...])Combines solids into one part without a boolean (each keeps its material). Also a | merge(b).
group("path/name")Puts the part under a named group in GLB exports. Alias parent.
inst(proto, at=[...], rot=[...], scale=, name=)Lightweight copies of one shape (exported as instances).
Pipe
units("mm")_leg = cyl(2, 40, z0=0)top = box(60, 40, 4, z0=40) | group("table")legs = merge([_leg | move(-26, -16, 0), _leg | move(26, -16, 0), _leg | move(-26, 16, 0), _leg | move(26, 16, 0)]) | group("table")scratch = box(5, 5, 5, at=(100, 0, 0))del("scratch")

Every named part is exported together. To combine two parts into one solid on purpose, add them.

Queries

Queries measure the model without changing it.

QueryReports
clearance(a, b)The smallest distance between two parts, or that they intersect.
section(part, z)The cross-section at height z: number of loops, area, perimeter.
features(part)Planes, holes and bosses, symmetry and wall thickness.
Pipe
units("mm")shaft = cyl(4, 30, z0=0, segs=64)bearing = pipe(10, 4.2, 8, segs=64, z0=10)clearance(shaft, bearing)section(bearing, 14)

In Zolid, the agent's look tool with a part shows the same feature facts as features(). See Agent tools.

Units

units("mm") sets the unit of every number in the project. The default is metres, so set it first.

UnitAccepted namesSize
ummicron, micrometer, micrometre0.001 mm
mmmillimeter, millimetre1 mm
cmcentimeter, centimetre10 mm
mmeter, metre (default)1000 mm
ininch, inches25.4 mm
ftfoot, feet304.8 mm
Pipe · fails on purpose
units("parsec")# error: unknown unit 'parsec'

Expressions

Arithmetic and maths

+ - * /, parentheses and % (floored remainder, so -1 % 3 is 2).

FunctionMeaning
sqrt(x), abs(x), pow(base, exp)Roots, absolute value, powers.
sin cos tan asin acos atan atan2(y, x)Trigonometry, in radians.
deg(x), rad(x)Radians to degrees and back. pi is π.
floor(x), ceil(x), round(x)Rounding (round(2.5) is 3).
min(a, b, ...), max(...)Also min(list), max(list).
clamp(x, lo, hi), lerp(a, b, t), mod(a, b)Limit, interpolate, remainder.
rand(i, seed=0)A repeatable number in [0, 1) for whole numbers i and seed. Same result on every run.
len(list)Number of items.
Pipe
units("mm")r = 20n = 8angle = 2 * pi / nstuds = cyl(2, 6, z0=0, at=[(r * cos(i * angle), r * sin(i * angle), 0) for i in range(n)])scatter = sphere(1.5, at=[(60 + 30 * rand(i, 1), 30 * rand(i, 2), 1.5) for i in range(12)])

Note that rot() and rot= take degrees, but sin/cos take radians.

Lists and comprehensions

Pipe
units("mm")xs = [0, 15, 30]xs = xs + [45]last = xs[-1]count = len(xs)pins = cyl(2, 10, z0=0, at=[(xs[i], 0, 0) for i in range(count)])grid = box(4, 4, 2, z0=0, at=[((i % 4) * 6, 20 + floor(i / 4) * 6, 0) for i in range(12)])evens = box(3, 3, 3, z0=0, at=[(i * 5, 50, 0) for i in range(0, 20, 4)])

range(stop), range(start, stop) and range(start, stop, step) work as in Python. A comprehension loops over a range; for a grid, use one loop with % and floor as above, or index into a list with xs[i].

Logic

Comparisons < <= > >= == != (no chaining), and, or, not, and if(cond, a, b), which only evaluates the branch it picks.

Pipe
units("mm")size = 30thick = if(size > 20, 4, 2)plate = box(size, size, thick, z0=0)

Macros

def name(p1, p2=default) = expr defines a reusable function. A macro can be used as a pipeline step: part | name(args) passes the part as the first argument.

Pipe
units("mm")def rounded_box(w, d, h, r=3) = box(w, d, h, z0=0) | fillet(vertical, r)def lift(m, dz) = m | move(0, 0, dz)base = rounded_box(60, 40, 6)riser = rounded_box(30, 20, 10, r=5) | lift(5.9)

A recursive macro must stop through if.

History in code

checkpoint("tag"), rollback("tag") and undo() also exist as statements. In Zolid, use the studio's History panel or the agent's history tool instead, so every step stays in the project's history.

Errors

A step that fails changes nothing: the model rolls back to where it was, and the error names the line and the problem.

Pipe · fails on purpose
units("mm")plate = box(80, 50, 4) | drill(3)# error: unknown pipeline op 'drill'
Pipe · fails on purpose
units("mm")plate = box(80, 50, 4, colour=1)# error: unknown keyword argument 'colour'
Pipe · fails on purpose
units("mm")plate = box(10, 10, 10) | cut(box(20, 20, 20))# error: empty result, nothing is left: the tool covers the whole part

See Troubleshooting for more.