Reference¶
Generated from the code each time the site is built, so it always matches the version the site was built from. For explanations, follow the links on the other pages.
b123d-print¶
The CLI; see CLI and Python.
usage: b123d-print [-h] [--root ROOT] [--version]
{init,new,build,check,metrics,orient,fit,trace,recipes,sketch,faces,edges,template,view,diagnose,bom,spec,params,set,measure,styles,printer,setup,compare,to-step,setup-ssh,ssh-serve,pull,push,save,versions,restore,config,list,examples,mcp}
...
build123d part workflow: scaffold, build, check
positional arguments:
{init,new,build,check,metrics,orient,fit,trace,recipes,sketch,faces,edges,template,view,diagnose,bom,spec,params,set,measure,styles,printer,setup,compare,to-step,setup-ssh,ssh-serve,pull,push,save,versions,restore,config,list,examples,mcp}
init create a workspace (b123d-print.toml, AGENTS.md, parts/)
new scaffold parts/<name>/<name>.py from the template
build export STEP/STL/3MF/PNG + section views
check run checks; exit 1 on failure
metrics design metrics and the style's suggestions (filament, time, edges, ...)
orient rank the ways to put each part on the bed (supports, contact, time, tip-
over, load)
fit fit between the pieces of assembly(d): overlaps, gaps under the clearance,
hole alignment
trace trace a flat object in a scan or photo into an outline in mm (JSON, py
snippet, overlay PNG)
recipes list the recipe library, or show one recipe's code, notes and sources
sketch sketch first: draw a sketch from sketches(d) on a mm grid with its
dimensions and checks (one region, neck, inside corners, small holes,
bed); exit 1 on a failure
faces list a part's flat faces with their ids (for a face template)
edges list a part's edges with their ids, convexity and faces (for a fillet or
chamfer)
template a fit-test template: a thin print cut from the part to check size, holes
and fits
view write a self-contained HTML 3D view of a part (rotate it in a browser,
offline)
diagnose a failed or broken build: each piece built on its own, with the likely
cause and fixes; exit 1 if a piece fails or has a problem
bom what to buy: the hardware the parts declare (hardware(d)) as one merged
table, or CSV
spec the replication spec of a part copied from a physical original: MEASURE.md
joined with the Dims, with flags (critical estimates, spread readings,
changes without a reason)
params list a part's Dims fields (type, value, source comment) and variant
overrides
set change Dims values in the script in place (FIELD=VALUE ...), then build
and show what changed
measure measure a built part in mm: a gap or interference, a wall, two faces, a
hole
styles list the design styles (yours and the built-in ones), or show one
printer optional printer/material profile (default: generic)
setup first-run setup: printer, material, export formats, default style, hole
compensation (asks, or takes flags); never replaces a value without
--overwrite or a yes
compare compare a part with a reference (STL/3MF/STEP); exit 1 if it fails the
thresholds
to-step convert an STL/3MF mesh to a STEP solid (coplanar triangles merged into
faces; curves stay faceted) and report what changed
setup-ssh on the server: the authorized_keys line that gives one client key the MCP
server in one workspace, and the client config to match
ssh-serve the forced command in authorized_keys (written by setup-ssh): runs the MCP
server, `pull` or `version` for $SSH_ORIGINAL_COMMAND, refuses anything
else
pull on the client: copy a part (script, out/, ref/) from an SSH server into
parts/<part>/ of the project folder
push on the client: copy a model to remix (STL/3MF/STEP) to an SSH server, into
parts/<part>/ref/
save save a version of the parts (script, ref/, MEASURE.md) and
b123d-print.toml in the project's version history (git)
versions list the saved versions, newest first, with what changed
restore bring a part back to a saved version, as a new version (nothing is lost)
config show the settings in effect
list list parts in the workspace
examples list the bundled example parts
mcp run the MCP server: the same as b123d-print-mcp, with all its options
(b123d-print mcp --help); lets `uvx b123d-print mcp` start it
options:
-h, --help show this help message and exit
--root ROOT workspace root (default: nearest b123d-print.toml, else the cwd)
--version show program's version number and exit
b123d-print init¶
usage: b123d-print init [-h] [--update-agents] [--git | --no-git] [dir]
positional arguments:
dir
options:
-h, --help show this help message and exit
--update-agents replace AGENTS.md with this version's text
--git also keep a version history: make the folder a git repo with a .gitignore
(asked when run in a terminal)
--no-git never ask about version history
b123d-print new¶
usage: b123d-print new [-h] [-d DESCRIPTION] [--from EXAMPLE] [--sketch] name
positional arguments:
name
options:
-h, --help show this help message and exit
-d DESCRIPTION, --description DESCRIPTION
--from EXAMPLE start from a bundled example (see `b123d-print examples`)
--sketch sketch first: a template with a sketches(d) outline that build(d) extrudes
(see `b123d-print sketch`)
b123d-print build¶
usage: b123d-print build [-h] [--variant VARIANT] [--formats FORMATS] [--only PIECES] [parts ...]
positional arguments:
parts part names or script paths (default: all)
options:
-h, --help show this help message and exit
--variant VARIANT
--formats FORMATS comma-separated, from step,stl,3mf,png,glb,print,hardware,bom,bom_csv,spec or
all (default: the formats setting)
--only PIECES comma-separated piece names from build(): build and export only those (lazy
pieces: the others are never built)
b123d-print check¶
usage: b123d-print check [-h] [--variant VARIANT] [--json] [-v] [parts ...]
positional arguments:
parts part names or script paths (default: all)
options:
-h, --help show this help message and exit
--variant VARIANT
--json
-v, --verbose also list passing checks
b123d-print metrics¶
usage: b123d-print metrics [-h] [--variant VARIANT] [--style STYLE] [--up UP] [--json] [parts ...]
positional arguments:
parts part names or script paths (default: all)
options:
-h, --help show this help message and exit
--variant VARIANT
--style STYLE override the part's STYLE: functional, modern, least_cost, rugged, soft,
structural, organic, decorative, toy
--up UP the side that points up in use, for water traps: +X, -Y, ... (default: UP,
else +Z)
--json
b123d-print orient¶
usage: b123d-print orient [-h] [--variant VARIANT] [--piece PIECE] [--load LOAD] [--image]
[--json]
[parts ...]
positional arguments:
parts part names or script paths (default: all)
options:
-h, --help show this help message and exit
--variant VARIANT
--piece PIECE only this printable part of a script that builds several
--load LOAD the bending or tension direction as build(d) returns the part: X, 'along Y',
XZ, 1,0,1
--image also render the top choice to out/images/<part>_orient.png
--json
b123d-print fit¶
usage: b123d-print fit [-h] [--variant VARIANT] [--hole-tol HOLE_TOL] [--json] [-v] [parts ...]
positional arguments:
parts part names or script paths (default: all with an assembly)
options:
-h, --help show this help message and exit
--variant VARIANT
--hole-tol HOLE_TOL largest axis offset of partner holes, mm (default 0.2)
--json
-v, --verbose also list the pairs that fit
b123d-print trace¶
usage: b123d-print trace [-h] [--dpi DPI] [--grid MM] [--reference card|L,S]
[--points X1,Y1,X2,Y2] [--distance MM] [--tolerance TOLERANCE] [--smooth]
[--pick X,Y] [--threshold THRESHOLD] [--invert] [-o OUT] [--json]
image
positional arguments:
image a PNG, JPEG, TIFF or BMP
options:
-h, --help show this help message and exit
--dpi DPI scan resolution (default: read from the file)
--grid MM grid cell size in mm (a cutting mat, graph paper)
--reference card|L,S a reference object beside it: card (85.60 x 53.98) or its sides in mm
--points X1,Y1,X2,Y2 two pixels (origin top left) a known --distance apart
--distance MM mm between --points
--tolerance TOLERANCE
mm the simplified outline may deviate (default 0.2)
--smooth spline through-points instead of a polyline
--pick X,Y a pixel inside the object to trace (default: the largest object)
--threshold THRESHOLD
gray level 0..1 (default: automatic)
--invert the object is lighter than the background
-o OUT, --out OUT folder for the outputs (default: next to the image)
--json
b123d-print recipes¶
usage: b123d-print recipes [-h] [name]
positional arguments:
name
options:
-h, --help show this help message and exit
b123d-print sketch¶
usage: b123d-print sketch [-h] [--variant VARIANT] [--no-dims] [--small] part [name]
positional arguments:
part part name or script path
name the sketch's name in sketches(d) (default: the first)
options:
-h, --help show this help message and exit
--variant VARIANT
--no-dims the shape and grid only, no dimensions
--small a smaller picture (~800 px wide)
b123d-print faces¶
usage: b123d-print faces [-h] [--variant VARIANT] [--part NAME] [--highlight ID] [--json] part
positional arguments:
part part name or script path
options:
-h, --help show this help message and exit
--variant VARIANT
--part NAME which printable part (default: the only one)
--highlight ID also draw the part with this face (id or side) in red
--json
b123d-print edges¶
usage: b123d-print edges [-h] [--variant VARIANT] [--part NAME] [--face ID] [--kind KIND]
[--convexity CONVEXITY] [--near X,Y,Z] [--radius RADIUS] [--limit LIMIT]
[--highlight IDS] [--json]
part
positional arguments:
part part name or script path
options:
-h, --help show this help message and exit
--variant VARIANT
--part NAME which printable part (default: the only one)
--face ID only the edges of this face: an id or side from `faces`, or x,y,z on it
--kind KIND only this type: line, circle, arc, ellipse, spline
--convexity CONVEXITY
only convex (outside), concave (inside corners), tangent or seam edges
--near X,Y,Z only edges within --radius mm of this point, nearest first
--radius RADIUS mm for --near (default 1)
--limit LIMIT list at most this many (default 200)
--highlight IDS draw these edges (3,4,7 or 3-6) in red and print a selector for them
--json
b123d-print template¶
usage: b123d-print template [-h] (--slice PLANE:AT | --face ID | --crop X,Y,Z:SX,SY,SZ)
[--thickness THICKNESS] [--no-label] [--no-base] [--name NAME]
[--variant VARIANT] [--part NAME] [--formats FORMATS]
part
positional arguments:
part part name or script path
options:
-h, --help show this help message and exit
--slice PLANE:AT the part between two planes around AT: XY:3 (Z=3), XZ:0 (Y), YZ:-5 (X)
--face ID one flat face as a plate: an id from `faces`, a side (bottom, top, ...) or
a point x,y,z on it
--crop X,Y,Z:SX,SY,SZ
the part inside a box: center and size in mm
--thickness THICKNESS
mm (default 1.2)
--no-label no engraved label
--no-base never add the thin base plate (slice, crop)
--name NAME the template id in file names (default: from the arguments, e.g. xy3)
--variant VARIANT default: the first variant
--part NAME which printable part (default: the only one)
--formats FORMATS comma-separated, from step,stl,3mf,png,glb,print,hardware,bom,bom_csv,spec
or all (default: the formats setting)
b123d-print view¶
usage: b123d-print view [-h] [--variant VARIANT] [--parts ONLY] [--assembly] [--open] part
positional arguments:
part part name or script path
options:
-h, --help show this help message and exit
--variant VARIANT one variant (default: the first)
--parts ONLY comma-separated printable parts to show (default: all)
--assembly show assembly(d), stand-ins included, instead of the printable parts on the
bed
--open also open it in the default browser
b123d-print diagnose¶
usage: b123d-print diagnose [-h] [--variant VARIANT] [--only PIECES] [--json] part
positional arguments:
part part name or script path
options:
-h, --help show this help message and exit
--variant VARIANT default: the first variant
--only PIECES comma-separated piece names: only those
--json
b123d-print bom¶
usage: b123d-print bom [-h] [--variant VARIANT] [--count COUNT] [--csv] [parts ...]
positional arguments:
parts part names or script paths (default: all, merged into one list)
options:
-h, --help show this help message and exit
--variant VARIANT
--count COUNT how many assemblies: multiplies every quantity (default 1)
--csv CSV instead of the Markdown table (for a spreadsheet or cart)
b123d-print spec¶
usage: b123d-print spec [-h] [--variant VARIANT] [--json] [--strict] part
positional arguments:
part part name or script path
options:
-h, --help show this help message and exit
--variant VARIANT default: the first variant
--json
--strict exit 1 if there is any warning
b123d-print params¶
usage: b123d-print params [-h] [--json] part
positional arguments:
part part name or script path
options:
-h, --help show this help message and exit
--json
b123d-print set¶
usage: b123d-print set [-h] [--variant VARIANT] [--no-build] part FIELD=VALUE [FIELD=VALUE ...]
positional arguments:
part part name or script path
FIELD=VALUE e.g. WIDTH=42 R=1.9 (Python literals)
options:
-h, --help show this help message and exit
--variant VARIANT change this variant's override in VARIANTS instead of the default
--no-build only edit the script
b123d-print measure¶
usage: b123d-print measure [-h] (--distance A,B | --wall X,Y,Z | --faces ID,ID | --hole [FACE])
[--of NAME] [--at X,Y,Z] [--dir DX,DY,DZ]
[--frame {auto,print,assembly}] [--variant VARIANT] [--image] [--json]
part
positional arguments:
part part name or script path
options:
-h, --help show this help message and exit
--distance A,B gap (or interference) between two pieces or assembly labels
--wall X,Y,Z wall thickness at a point (into the part, or along --dir)
--faces ID,ID distance or angle between two flat faces (ids or sides from `faces`)
--hole [FACE] holes in a flat face (id or side), or the hole nearest --at
--of NAME the piece (or assembly label) for --wall, --faces, --hole
--at X,Y,Z a point at the hole (--hole)
--dir DX,DY,DZ the direction for --wall
--frame {auto,print,assembly}
print (as build() returns it) or assembly (as assembly(d) places it);
default auto
--variant VARIANT default: the first variant
--image also draw the part with what was measured in red (out/images/)
--json
b123d-print styles¶
usage: b123d-print styles [-h] [name]
positional arguments:
name a style to show, with based_on applied
options:
-h, --help show this help message and exit
b123d-print printer¶
usage: b123d-print printer [-h] {list,show,use,hole-comp,calibrate} ...
positional arguments:
{list,show,use,hole-comp,calibrate}
list search the printer profiles (from OrcaSlicer's library + yours)
show show a printer (default: the active one)
use set the active printer in your user config; 'generic' clears it
hole-comp store a measured hole compensation for the active printer + material
calibrate store a value measured with a calibration coupon for the active printer +
material
options:
-h, --help show this help message and exit
b123d-print printer list¶
usage: b123d-print printer list [-h] [query ...]
positional arguments:
query
options:
-h, --help show this help message and exit
b123d-print printer show¶
usage: b123d-print printer show [-h] [name]
positional arguments:
name
options:
-h, --help show this help message and exit
b123d-print printer use¶
usage: b123d-print printer use [-h] [--material MATERIAL] [--nickname NICKNAME] name
positional arguments:
name a printer profile, or a nickname given before
options:
-h, --help show this help message and exit
--material MATERIAL pla, petg, asa, abs, tpu or your own
--nickname NICKNAME name this printer (e.g. p2s-garage): two of the same model each keep their
own calibration
b123d-print printer hole-comp¶
usage: b123d-print printer hole-comp [-h] value
positional arguments:
value
options:
-h, --help show this help message and exit
b123d-print printer calibrate¶
usage: b123d-print printer calibrate [-h] [--workspace]
{hole_comp,hole_comp_h,clearance,press_fit,free_fit,pip_clearance,max_overhang,max_bridge}
value
positional arguments:
{hole_comp,hole_comp_h,clearance,press_fit,free_fit,pip_clearance,max_overhang,max_bridge}
value
options:
-h, --help show this help message and exit
--workspace store it in this workspace's b123d-print.toml instead of calibration.toml
b123d-print setup¶
usage: b123d-print setup [-h] [--printer PRINTER] [--material MATERIAL] [--formats FORMATS]
[--style STYLE] [--hole-comp HOLE_COMP] [--hole-comp-h HOLE_COMP_H]
[--workspace] [--overwrite] [--no-input]
options:
-h, --help show this help message and exit
--printer PRINTER a printer profile name or search words ('generic' for none)
--material MATERIAL pla, petg, asa, abs, tpu or your own
--formats FORMATS comma-separated, from step,stl,3mf,png,glb,print,hardware,bom,bom_csv,spec
or all
--style STYLE functional, modern, least_cost, rugged, soft, structural, organic,
decorative, toy or your own
--hole-comp HOLE_COMP
measured hole compensation, mm (with a printer: stored for it and the
material)
--hole-comp-h HOLE_COMP_H
the same for horizontal holes
--workspace write to this workspace's b123d-print.toml (default: your user config)
--overwrite replace values already set there
--no-input never ask: write only the flags given (default when stdin is not a
terminal)
b123d-print compare¶
usage: b123d-print compare [-h] [--json] [--threshold NAME=VALUE] [--samples SAMPLES] [--no-icp]
[--seed SEED] [--image IMAGE]
reference candidate
positional arguments:
reference
candidate
options:
-h, --help show this help message and exit
--json
--threshold NAME=VALUE
override a pass/fail threshold, e.g. hausdorff_mm=2 (repeatable; see
b123d_print.compare.Criteria)
--samples SAMPLES surface points per part (default 20000)
--no-icp skip the ICP refinement after the axis search
--seed SEED
--image IMAGE also write a deviation view (PNG) here
b123d-print to-step¶
usage: b123d-print to-step [-h] [-o OUTPUT] [--scale SCALE] [--max-triangles MAX_TRIANGLES]
[--no-merge]
input
positional arguments:
input the .stl or .3mf (or .step, to check it)
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
the .step to write (default: next to the input)
--scale SCALE a factor or the unit the file is in: inch, cm, m, ... (default 1: mm)
--max-triangles MAX_TRIANGLES
refuse bigger meshes (default: the max_triangles setting)
--no-merge keep one face per triangle
b123d-print setup-ssh¶
usage: b123d-print setup-ssh [-h] --key KEY --workspace WORKSPACE [--host HOST] [--add]
[--authorized-keys AUTHORIZED_KEYS]
options:
-h, --help show this help message and exit
--key KEY the client's public key file (.pub), or - for stdin
--workspace WORKSPACE
a name (-> ~/parts/<name>) or a folder path
--host HOST the name clients reach this machine by (default: its FQDN)
--add also put the line into authorized_keys (replaces this key's earlier
b123d-print line)
--authorized-keys AUTHORIZED_KEYS
file to add it to (default: ~/.ssh/authorized_keys)
b123d-print ssh-serve¶
usage: b123d-print ssh-serve [-h] --workspace WORKSPACE [--dest DEST] [--timeout TIMEOUT]
[--check-timeout CHECK_TIMEOUT]
options:
-h, --help show this help message and exit
--workspace WORKSPACE
the workspace this key is pinned to
--dest DEST user@host as clients see it, for the pull command export suggests
--timeout TIMEOUT seconds per build (default 240)
--check-timeout CHECK_TIMEOUT
seconds per check run (default 300, or --timeout if longer)
b123d-print pull¶
usage: b123d-print pull [-h] --from USER@HOST [--formats FORMATS] [--variant VARIANT] [-o OUT]
[--ssh SSH]
part
positional arguments:
part
options:
-h, --help show this help message and exit
--from USER@HOST the server, as in your MCP config
--formats FORMATS only these out/ files, comma-separated, from
step,stl,3mf,png,glb,print,hardware,bom,bom_csv,spec (default: every file in
out/)
--variant VARIANT only this variant's out/ files ('standard' for the default one)
-o OUT, --out OUT the project folder; the part goes to <it>/parts/<part>/ (default: the current
folder)
--ssh SSH ssh command and options, e.g. 'ssh -i ~/.ssh/b123d_print -p 2222' (default:
ssh)
b123d-print push¶
usage: b123d-print push [-h] --part PART --to USER@HOST [--name NAME] [--overwrite] [--ssh SSH]
file
positional arguments:
file
options:
-h, --help show this help message and exit
--part PART the part it is for (the folder is created if needed)
--to USER@HOST the server, as in your MCP config
--name NAME file name on the server (default: the file's own name)
--overwrite replace a reference file of the same name
--ssh SSH ssh command and options (default: ssh)
b123d-print save¶
usage: b123d-print save [-h] [--part PART] [message]
positional arguments:
message what changed, in a few words (default: the changed values)
options:
-h, --help show this help message and exit
--part PART only this part (default: every part)
b123d-print versions¶
usage: b123d-print versions [-h] [--limit LIMIT] [part]
positional arguments:
part number this part's versions, for restore (default: every part)
options:
-h, --help show this help message and exit
--limit LIMIT show at most this many (default 20)
b123d-print restore¶
usage: b123d-print restore [-h] part version
positional arguments:
part
version a number from `b123d-print versions <part>`, or a commit id
options:
-h, --help show this help message and exit
b123d-print config¶
usage: b123d-print config [-h]
options:
-h, --help show this help message and exit
b123d-print list¶
usage: b123d-print list [-h]
options:
-h, --help show this help message and exit
b123d-print examples¶
usage: b123d-print examples [-h]
options:
-h, --help show this help message and exit
b123d-print mcp¶
usage: b123d-print mcp ...
positional arguments:
args
b123d-print-mcp¶
The MCP server; see Connect your MCP client.
usage: b123d-print-mcp [-h] [--workspace WORKSPACE] [--timeout TIMEOUT]
[--check-timeout CHECK_TIMEOUT] [--max-builds MAX_BUILDS]
[--max-memory MAX_MEMORY] [--quick-slots QUICK_SLOTS]
[--client-jobs CLIENT_JOBS] [--max-uploads MAX_UPLOADS]
[--client-uploads CLIENT_UPLOADS] [--transport {stdio,http}] [--host HOST]
[--port PORT] [--allowed-hosts ALLOWED_HOSTS]
[--shutdown-grace SHUTDOWN_GRACE] [--public-url PUBLIC_URL]
[--link-ttl LINK_TTL] [--retention-days RETENTION_DAYS]
[--tokens-file TOKENS_FILE] [--job-queue JOB_QUEUE] [--insecure-no-auth]
[--healthcheck]
{token,worker} ...
b123d-print MCP server: design, check and export 3D-printable build123d parts from any MCP client.
Part scripts are model-written code: every build runs in a sandboxed subprocess.
positional arguments:
{token,worker}
token manage the named tokens in --tokens-file
worker run builds handed over through --queue (pairs with the server's --job-
queue)
options:
-h, --help show this help message and exit
--workspace WORKSPACE
folder with b123d-print.toml / parts/ (default: $B123D_PRINT_WORKSPACE,
else the cwd)
--timeout TIMEOUT seconds per build, render, section or export (default 240;
$B123D_PRINT_TIMEOUT)
--check-timeout CHECK_TIMEOUT
seconds per check run, which builds the part and runs every check (on a
remix, on the original too); near the limit it stops and returns the
findings it has (default: 300, or --timeout if longer;
$B123D_PRINT_CHECK_TIMEOUT)
--max-builds MAX_BUILDS
build processes at once, across all clients and all server processes of
this user (one per SSH session); more calls wait (default: half the CPUs;
$B123D_PRINT_MAX_BUILDS)
--max-memory MAX_MEMORY
memory per build process, e.g. 2g or 1536m; a build over it fails with a
plain message (Linux and Windows; macOS has no per-process limit); 0 = no
limit (default 2g; $B123D_PRINT_MAX_MEMORY)
--quick-slots QUICK_SLOTS
build slots (out of --max-builds) kept for quick calls (measure, section,
faces, edges, hardware_list), so they never wait behind long builds; at
least one slot stays for long ones (default: 1 over HTTP with 2+ slots,
else 0; $B123D_PRINT_QUICK_SLOTS)
--client-jobs CLIENT_JOBS
http: jobs one client (token) may have running and waiting; more are
refused with a message until one finishes; 0 = no cap (default 4;
$B123D_PRINT_CLIENT_JOBS)
--max-uploads MAX_UPLOADS
http: signed-link uploads (upload_reference) at once, all clients
together; more are refused with a message (HTTP 503); 0 = no cap (default
8; $B123D_PRINT_MAX_UPLOADS)
--client-uploads CLIENT_UPLOADS
http: signed-link uploads one client (token) may have running at once;
more are refused with a message (HTTP 429); 0 = no cap (default 2;
$B123D_PRINT_CLIENT_UPLOADS)
--transport {stdio,http}
stdio (default) or http: Streamable HTTP at /mcp ($B123D_PRINT_TRANSPORT)
--host HOST http: address to bind (default 127.0.0.1; $B123D_PRINT_HOST)
--port PORT http: port (default 8000; $B123D_PRINT_PORT)
--allowed-hosts ALLOWED_HOSTS
http: comma-separated Host header values to accept (DNS-rebinding check;
$B123D_PRINT_ALLOWED_HOSTS)
--shutdown-grace SHUTDOWN_GRACE
http: on SIGTERM/Ctrl-C, seconds to let running calls finish before their
builds are killed (default 30)
--public-url PUBLIC_URL
http: base URL clients reach the server at, for download links, e.g.
https://cad.example.com (default: from the request;
$B123D_PRINT_PUBLIC_URL)
--link-ttl LINK_TTL http: seconds a download link stays valid (default 3600;
$B123D_PRINT_LINK_TTL)
--retention-days RETENTION_DAYS
http: remove a named workspace (workspaces/<name>) nobody has used for
this many days; checked at startup and hourly, never while it is in use; 0
= never (default 30; $B123D_PRINT_RETENTION_DAYS)
--tokens-file TOKENS_FILE
http: named tokens, each limited to workspaces (see `token add`); re-read
when it changes ($B123D_PRINT_TOKENS_FILE)
--job-queue JOB_QUEUE
http: hand builds to a separate `worker` process through this folder
instead of running them here (the Docker setup's network-less worker
container; $B123D_PRINT_JOB_QUEUE)
--insecure-no-auth http: run without any token (otherwise $B123D_PRINT_TOKENS_FILE,
$B123D_PRINT_TOKEN or $B123D_PRINT_TOKEN_FILE is required)
--healthcheck check the running HTTP server's /health and exit (for Docker)
MCP server¶
What the server registers, with the descriptions the model sees; see MCP tools and prompts.
Tools¶
read_guide¶
read_guide(essentials: bool = false)
The workflow and print rules (the b123d-print://guide resource). Call it once before the first part in a session: many clients never load that resource. essentials=True: only the short checklist of the rules most often skipped.
list_parts¶
list_parts()
List the part scripts in the workspace, with the settings in effect.
use_printer¶
use_printer(name: str = "", material: str = "", search: str = "", nickname: str = "")
Optional printer profile (default is generic mode). search: find printer names ("bambu a1", "prusa mk4"). name: make it active (saved in the user's config, or over HTTP and SSH in this workspace's b123d-print.toml; "generic" clears it); a nickname given before works too. nickname: only for two printers of the same model, e.g. name='bambu_lab_p2s_0_4_nozzle', nickname='p2s-garage': each nickname keeps its own calibration. material: pla, petg, asa, abs, tpu or the user's own. Only change the printer when the user asks for it.
save_setup¶
save_setup(printer: str = "", material: str = "", formats: str = "", style: str = "", hole_comp: float = None, hole_comp_h: float = None, calibration: object = None, overwrite: bool = false, move_flat: bool = false)
Save the user's first-run answers (the setup_workspace prompt): printer (a name from use_printer's search, or a nickname), material, formats ("3mf,png"), default style; hole_comp=0 records that the slicer corrects holes (the default way); a nonzero, MEASURED hole_comp / hole_comp_h is an opt-in that builds the correction into every file; calibration: other coupon results, e.g. {"clearance": 0.18, "max_bridge": 15}. With a printer, measured values are stored for it and the material. Written where use_printer writes. A value already set there is kept and listed as a conflict: ask the user, then call again with overwrite=True. Empty arguments change nothing. move_flat=True (after asking the user) moves measured values set for every printer of a workspace under the active printer.
new_part¶
new_part(name, description: str = "", example: str = None, show_code: bool = false, sketch_first: bool = false)
Create parts/<name>/<name>.py from the template (Dims dataclass, build(d), VARIANTS, views, checks). name: lower_snake_case. example: copy a bundled example instead (see list_parts), e.g. 'hole_coupon' to calibrate hole compensation. sketch_first: the template with a sketches(d) outline that build(d) extrudes, for a part that is mostly a 2D shape made solid (offer it per part, see the guide's Sketch first); check the outline with render_sketch. Returns a short confirmation; the template is the b123d-print://template resource (or read_part), show_code=True returns the new file's code here. Usually the next step is write_part with the whole script. If you haven't, call read_guide first; confirm the dimensions with the user before writing the script.
read_part¶
read_part(name)
Return the current code of a part script.
write_part¶
write_part(name, code)
Replace the whole part script with code (create the part with new_part first).
The script must define build(d) (+ Dims, VARIANTS). If you haven't, call read_guide first;
confirm the dimensions with the user before writing the script. Then call build_part.
params¶
params(name)
The part's named dimensions, read from the script without running it: each Dims field with its type, default as written, value (when the default is a literal), the comment saying where it came from, and its line; the derived values (@property) and the fields they use; and each variant's overrides in VARIANTS. Change one with set_params, not a whole rewrite.
set_params¶
set_params(name, values, variant: str = None, rebuild: bool = true, parts: str = None)
Change Dims values in the script in place, leaving every other character of the file as it was: values {"FIELD": new value, ...} replaces each field's default (only literal defaults: a default computed by an expression such as hole_comp(file) is refused with the reason; so are unknown fields, derived @property values and values of the wrong type). variant: change (or add) that variant's override in VARIANTS instead of the default. rebuild (default true): build before and after (the build cache makes "before" quick) and report what changed per piece: size and volume; parts: only those pieces. Saved like write_part (size limit, must compile). If the new build fails, the result has the diagnosis and the call to undo it.
build_part¶
build_part(name, variant: str = None, parts: str = None, fresh: bool = false)
Run the part script (sandboxed, with a timeout) and report, per variant and part: bounding box size and min/max (mm), volume (mm^3), solid count, is_valid, the Dims values, and any error with its traceback; and under "timing" each piece's face count and build time, with a hint for a piece that is slow or dense. variant: key from VARIANTS ('standard' = ''). parts: comma-separated piece names from build(): build only those (lazy pieces: the others are never built). Built pieces are cached in out/.cache/, so render_preview, section, check and export reuse them while the script, its Dims and the settings stay the same; fresh=True builds again and replaces the cached pieces. Writes no other files. Ends with "before_printing": the review steps this version still needs, each with its call.
diagnose_failure¶
diagnose_failure(name, variant: str = None, parts: str = None)
The deeper look after a failed or broken build (failed results already carry a short DIAGNOSIS): builds one variant piece by piece, each on its own and without the build cache, and for each piece reports the error with its likely cause and specific fixes (where in the script, the piece, the numbers: e.g. the largest fillet radius that works on those edges), or for a piece that built, what makes it unprintable (invalid solid, zero volume, a 2D shape, not on the bed) and, for an invalid one, which faces and edges are bad, tiny edges and sliver faces left by booleans, and whether part.fix() repairs it. Then the assembly. parts: only those pieces. Stops before the time limit and names the pieces it did not get to.
render_preview¶
render_preview(name, variant: str = None, parts: str = None, size: str = "normal", inline: bool = true, fresh: bool = false)
Render six views (iso, top, front, right, iso from below, bottom) as a PNG image. parts: comma-separated part names from build() (several are laid out side by side; only those are built), 'assembly' (assembled position with stand-ins), or omit: the assembly if the script has one, else every printable part side by side. One variant (default: the first). size: 'normal' or 'small' (~800 px wide, cheaper). inline=False returns only the file (over HTTP: its download link), not the image itself. Uses the pieces cached by an earlier build; fresh=True builds them again. Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted when unused; bring the part home with download_part (one zip in the parts/<name>/ layout). Never use ssh, scp or a shell on the server: there is none.
section¶
section(name, plane, at, variant: str = None, parts: str = None, size: str = "normal", inline: bool = true, fresh: bool = false)
Cross-section as a PNG image, each part in its own color. plane: 'XY' (at = Z height), 'XZ' (at = Y) or 'YZ' (at = X), in mm. parts: default the assembly if the script has one (shows fit and clearances), else all printable parts; or comma-separated names (only those are built). size: 'normal' or 'small' (~800 px wide). inline=False returns only the file (over HTTP: its download link), not the image itself. Uses the pieces cached by an earlier build; fresh=True builds them again. Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted when unused; bring the part home with download_part (one zip in the parts/<name>/ layout). Never use ssh, scp or a shell on the server: there is none.
render_sketch¶
render_sketch(name, sketch: str = None, variant: str = None, dims: bool = true, size: str = "normal", inline: bool = true)
Sketch first: one 2D shape from the script's sketches(d) hook, drawn flat on a mm grid as a PNG, with automatic dimensions (overall size, hole diameters, slot widths, inside corner radii, hole and slot centres from the lower-left corner) and the sketch checks: one closed region, the narrowest neck against min_wall, inside corners under R0.5 (BP-R1), holes under 1 mm, the outline against the bed. Show it to the user and get an OK before build(d) extrudes, revolves or sweeps it. sketch: its name in sketches(d) (default: the first). dims=False draws the shape and grid only. Nothing 3D is built. size: 'normal' or 'small'. Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted when unused; bring the part home with download_part (one zip in the parts/<name>/ layout). Never use ssh, scp or a shell on the server: there is none.
check¶
check(name, variant: str = None, fresh: bool = false)
Run the print checks: validity, overlap between assembly parts (incl. stand-ins), overhangs > 45 deg from vertical in print orientation (bed face ignored) and bridge spans, thin features (walls under one line width fail), round-topped horizontal holes, fillets on bed edges, gaps between parts printed in place, the script's Wall checks (thinnest material around deep cuts) and Probes. The fit between an assembly's pieces (hole alignment, gaps) is a separate tool, check_fit, unless the script lists Mates() in checks(d). Fix every FAIL; report every WARN. On a remote server (HTTP/SSH) the part is not on the user's machine until download_part brings it home. Uses the pieces cached by an earlier build, and each unchanged piece's findings of the per-piece checks; fresh=True builds and checks everything again. A passing result ends with the review steps this version still needs, each with its call.
design_metrics¶
design_metrics(name, variant: str = None, style: str = "", up: str = "", as_json: bool = false)
Design numbers for the design review, per printable part: size and proportions, filament (simple estimate, roughly +-20 %) and cost, print time (rough estimate), supports, shallow slopes that show layer steps, edge treatment (sharp / filleted / chamfered shares, distinct radii and chamfer sizes), mirror symmetry, screw sizes, seam corners, water traps, inside corners, hole edge distance, slenderness across the layers, vase-mode layers and lean (and the thinnest walls for a style that asks); then the suggestions the part's style triggers, each citing its DS-* rule. ALWAYS before export, after check passes; report its suggestions to the user. style: override the part's STYLE (functional, modern, least_cost, rugged, soft, structural, organic, decorative, toy, or a style file of the user's: list_parts shows them). up: the direction that points up in use for the water-trap check (+X, -Y, ...; default the script's UP, else +Z). as_json: the full numbers as JSON instead of the text report. Changes nothing.
suggest_orientation¶
suggest_orientation(name, variant: str = None, piece: str = None, load: str = "", image: bool = false, size: str = "normal", inline: bool = true)
Rank the ways to put the part on the bed, so it does not print upside down or on a thin edge: the six axis-aligned orientations and the large flat faces of its convex hull, each scored on supports (area and grams under overhangs past max_overhang, bridges apart), bed contact, height and print time (rough estimates), bridges, tip-over risk (as the check) and, with a load or the structural style, whether the load runs along the layers (DS-T1). Returns a ranked table with the Rot(x, y, z) to apply in build(d) and how. ALWAYS before export (a part already flat on the bed: it says so in a second). piece: one printable part (default: each). load: the bending or tension direction as build(d) returns the part ('X', 'along Y', 'XZ', '1,0,1'). image: also render the top choice (of the first part). Changes nothing. Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted when unused; bring the part home with download_part (one zip in the parts/<name>/ layout). Never use ssh, scp or a shell on the server: there is none.
export¶
export(name, variant: str = None, formats: str = None, parts: str = None, embed: bool = false, fresh: bool = false, view: str = "print", skip_review: str = "")
Export printable parts to parts/<name>/out/, sorted: print/ (3MF, STL, print sheet: for the
slicer), cad/ (STEP, GLB), images/, docs/ (BOM, view HTML), README.md. Default: every part, all variants. The
files must reach the user: on a remote server download_part brings them home.
parts: comma-separated part names from build() to build and export only those; variant: one
variant. Uses the pieces cached by an earlier build and leaves files already up to date as
they are (templates too); fresh=True builds and writes everything again.
formats: comma-separated from step (other CAD: Onshape, Fusion, FreeCAD), stl and 3mf
(slicers; 3MF keeps units), png (6-view preview + section views), glb (binary glTF, for web
and 3D apps), print (the print sheet, <name>[_<variant>]print.md: size, filament and time
estimates, supports, tip-over, walls and infill, fits and hole compensation, PRINT_NOTES, for
the slicer, including declared hardware), hardware (versioned whole-assembly BOM JSON,
<name>[<variant>]hardware.json), bom and bom_csv (the shopping list of that hardware as a
Markdown table, <name>[<variant>]bom.md, and as CSV, _bom.csv; hardware_list returns it in
the result), spec (the replication spec from MEASURE.md,<name>[_<variant>]_spec.md, for a
part copied from a physical original; replication_spec returns it), or 'all'. Omit to use the user's formats setting (default: step, stl, 3mf and
png). Ask the user which they want if unclear.
view: a 3D view the user can turn in a browser, per variant: 'print' (default: the printable
parts on the bed), 'assembly' (assembly(d) with its stand-ins) or 'none'. Over HTTP it is a
signed link (no token, expires like the downloads); locally a self-contained HTML file in
out/docs/ (works offline). Offer it to the user after an export.
Over HTTP (a remote server) each file comes with a download link (no token needed, expires)
and a b123d-print://files/ resource link; download_part gets the whole part (script, out/,
ref/) in one zip. embed=True also puts files up to 2 MB into the result itself, for clients
that can neither fetch URLs nor read resources.
Before export, ALWAYS: check passes, design_metrics(name, style=...), suggest_orientation(name)
(the "Before printing" block of build_part and check lists what is missing). With the review
setting "warn" (default) export says what was skipped, here and on the print sheet; with
"required" it refuses until the steps are done. skip_review: only when the user said to export
without them, their reason (recorded on the print sheet).
Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted
when unused; bring the part home with download_part (one zip in the parts/<name>/ layout).
Never use ssh, scp or a shell on the server: there is none.
list_faces¶
list_faces(name, variant: str = None, part: str = None, highlight: int | str = None, size: str = "normal", inline: bool = true)
The flat faces of a printable part, for picking one for a face fit-test template (make_template kind='face'): stable ids (1 = the largest; the same geometry always gets the same ids, changed geometry may renumber), outward normal and side (bottom, top, front, back, left, right), area, center, bounding box, round holes (diameter, center) and other openings; curved faces are only counted. part: which printable part (default: the only one). highlight: a face id or side; also returns a picture of the part with that face in red, to confirm the choice with the user before making the template. size: 'normal' or 'small'. Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted when unused; bring the part home with download_part (one zip in the parts/<name>/ layout). Never use ssh, scp or a shell on the server: there is none.
list_edges¶
list_edges(name, variant: str = None, part: str = None, highlight: array | int | str = None, face: int | str = None, kind: str = None, convexity: str = None, near: array | str = None, radius: float = 1.0, limit: int = 200, size: str = "normal", inline: bool = true)
The edges of a printable part, to pick the ones for a fillet or chamfer by id instead of
guessing a selector: stable ids (1 = the longest; changed geometry may renumber), type (line,
circle, arc, ellipse, spline), length, start and end (or center and radius), convexity (convex:
an outside edge; concave: an inside corner; tangent: a smooth joint such as a fillet's side;
seam), the turn between its faces and the two faces it joins (flat faces by their list_faces
id, curved ones by type). Filters: face (an id, side or 'x,y,z' as in list_faces: its edges),
kind, convexity, near ('x,y,z': edges within radius mm, nearest first); limit caps the list.
part: which printable part. highlight: edge ids ('3,4,7', '3-6' or a list): also returns a
picture with them in red and selector, a build123d expression (filter_by/group_by/sort_by
on part.edges(), one face's edges or convex_edges/concave_edges(part)) that selects exactly
those edges, verified on the part; put that in the script, never the ids (they change when the model changes).
size: 'normal' or 'small'.
Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted
when unused; bring the part home with download_part (one zip in the parts/<name>/ layout).
Never use ssh, scp or a shell on the server: there is none.
measure¶
measure(name, kind, a: str = None, b: str = None, at: array | str = None, direction: array | str = None, face: int | str = None, face2: int | str = None, frame: str = "auto", variant: str = None, image: bool = false, size: str = "normal", inline: bool = true)
Precise measurements on the built part, in mm, with the points where they were taken: check fits with numbers instead of guessing from pictures. kind: 'distance' (a, b: piece names from build() or assembly labels, stand-ins included): the smallest gap and its two points, or when they overlap the interference volume, its box and depth. Two assembly labels are measured where assembly(d) puts them (the fit). 'wall' (at: x,y,z on or in the material; direction: optional x,y,z): the thickness along a line through the point (default: into the part along the nearest face's normal), with the gaps and walls beyond it. 'faces' (face, face2: ids or sides from list_faces): the distance between two parallel flat faces (a wall, a slot), or the angle between them, and their closest points. 'hole' (face: a flat face id or side, and/or at: a point at the hole): each round hole's modeled diameter, what it prints at after hole_comp, center, axis, through or blind depth. a: the piece for wall, faces and hole (default: the only one). frame: 'auto' (default), 'print' (as build() returns it) or 'assembly' (as assembly(d) places it); points are in that frame. image: also a picture of the part with what was measured in red. Uses the build cache.
make_template¶
make_template(name, kind, plane: str = None, at: float = None, face: int | str = None, center: array | str = None, size: array | str = None, thickness: float = None, label: bool | str = true, base: bool = true, variant: str = None, part: str = None, formats: str = None, inline: bool = true)
A fit-test template: a quick thin print cut from the real part (same hole compensation and
clearances) to check size, hole pattern and mating fits before printing the whole part. kind:
'slice' (plane XY/XZ/YZ at = Z/Y/X: the part between two planes thickness apart, centered
on at), 'face' (face: an id from list_faces, a side such as 'bottom', or 'x,y,z' on it: that
flat face with its holes as a plate; a side means the largest face facing that way) or 'crop' (center, size: x,y,z in mm: the part inside
that box, with a thin base plate where it needs one; base=False: never). thickness: mm
(default 1.2). label: engrave '<part> <id>' (default), your own text, or false; skipped when
there is no room. The template is laid flat (template face down, Z=0) and checked like a
part. Writes <name>template<id>.* in formats (default: the formats setting): 3MF/STL in
parts/<name>/out/print/templates/, STEP in out/cad/; with png also out/images/<...>_where.png, the part with the template's source in red (returned
as the image; inline=False: only the file). Confirm the face or region with the user first
(list_faces with highlight).
Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted
when unused; bring the part home with download_part (one zip in the parts/<name>/ layout).
Never use ssh, scp or a shell on the server: there is none.
download_part¶
download_part(name, variant: str = None, formats: str = None, embed: bool = false)
Bring a whole part home from a remote server, in the same layout a local install writes:
parts/<name>/<name>.py, parts/<name>/out/ (exports, renders, sections) and parts/<name>/ref/
(reference models). Over HTTP: ONE signed link (no token needed, expires) to a zip of all of
it; run curl -fLo <name>.zip '<link>' and unzip it in the project folder, then check the
files are there. Over SSH: the b123d-print pull command that writes the same files. Locally
(stdio): says where the files already are. variant: only that variant's out/ files ('standard'
= ''); formats: only those out/ files (step, stl, 3mf, png, glb, print, hardware, bom, bom_csv, spec); the script and ref/ always come.
Over HTTP it also gives the 3D view links of the views export wrote (in a browser, no token).
embed=True also puts the zip (up to 8 MB) into the result (over HTTP and SSH), for clients
whose shell has no network (Antigravity/agy) or that can neither fetch URLs nor read
resources: unzip it from where the client saved it. Call it as the last step of remote work,
before reporting: a part is not done until its files are on the user's machine.
Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted
when unused; bring the part home with download_part (one zip in the parts/<name>/ layout).
Never use ssh, scp or a shell on the server: there is none.
compare¶
compare(reference, candidate, thresholds: str = "", image: bool = false, size: str = "normal", inline: bool = true)
Compare a part with a reference model: bounding box, volume and surface area differences, surface distances (mean, Hausdorff) after aligning orientation, an F-score, a 0-100 score and pass/fail. reference, candidate: STL, 3MF or STEP files inside the workspace, as paths relative to it (e.g. 'refs/bracket.stl', 'parts/bracket/out/print/bracket.3mf'). thresholds: optional overrides, comma-separated name=value (e.g. 'hausdorff_mm=2,volume_rel=0.05'). image: also return a view of the reference colored by deviation (green = matches, red = off); size: 'normal' or 'small' (~800 px wide); inline=False returns only its file (over HTTP: a link). Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted when unused; bring the part home with download_part (one zip in the parts/<name>/ layout). Never use ssh, scp or a shell on the server: there is none.
save_version¶
save_version(message, part: str = None, start: bool = false)
Save a version of the project in its version history (git, on the user's machine): each part's script, its ref/ folder, MEASURE.md and the .py files beside it, and b123d-print.toml; never out/. Only when the user said yes: after a change that built and passed its checks, OFFER "Save this version? (<part>: <what changed>)", never save on your own. message: what changed, in the user's words ("arm 115 -> 130 mm"); part: only that part (default: all). The result says what was saved and the changed Dims values. start=True first makes the project folder a git repository with a .gitignore: only after the user agreed to keep a version history. On a shared (HTTP/SSH) server it runs nothing and returns the commands for the user's own project folder.
list_versions¶
list_versions(part: str = None)
The saved versions, newest first: date, id, message and the Dims values that changed. With part: numbered versions of that part (for restore_version), and what is not saved yet. On a shared (HTTP/SSH) server: the command for the user's own project folder.
restore_version¶
restore_version(part, version)
Bring a part (script, ref/, MEASURE.md) back to a saved version: a number from list_versions(part), or a commit id. It is saved as a NEW version, so nothing is lost: no reset, no deleted history, files added later are kept. Refused while the part has changes not saved yet (offer save_version first). Ask the user before restoring; then build_part and check. On a shared (HTTP/SSH) server: the commands for the user's project folder (version = the commit id), then write_part to put the restored script back on the server.
upload_reference¶
upload_reference(part, filename, data_base64: str = "", overwrite: bool = false)
Get an original model (STL, 3MF or STEP) onto the server, into parts/<part>/ref/<filename>,
to remix it, or a scan or photo (PNG, JPEG, TIFF, BMP) to trace with trace_outline (the part
folder may not exist yet). With data_base64 (the whole file, base64) it
is stored now, up to 50 MB; that is only practical for small files, since the model has to
write out every byte. Without it, the result says how the USER copies the file: over HTTP a
signed upload link for curl -fT <file> '<link>' (no token needed, expires), over SSH the
b123d-print push command, locally the folder to copy it into. Then describe_model.
describe_model¶
describe_model(part, file, scale: str = "", image: bool = true, size: str = "normal", inline: bool = true)
Inspect an original model before remixing it: format, units (and whether they look wrong), size, volume, triangles and faces before/after merging coplanar triangles, how much is curved (faceted), round holes (diameter, axis, center), repairs needed, the designer/license metadata the file carries, and a suggestion: MODIFY it or REDRAW it. part: the part it is for. file: a name in parts/<part>/ref/ (or a workspace path such as 'refs/x.stl'). scale: '' (as the file says), a factor, or the unit the file was drawn in ('inch', 'cm'). image: also a 6-view render (saved as parts/<part>/out/images/<file>_original.png).
before_after¶
before_after(name, variant: str = None, size: str = "normal", inline: bool = true)
For a remix: the original and the remix side by side, and the original colored by how far the remix is from it (compare's deviation view: green = unchanged, red = changed), with compare's score and metrics. The original is what build() loads with import_model, or what the script's original(d) returns. export writes the same two images when it writes PNGs.
check_fit¶
check_fit(name, variant: str = None, hole_tol: float = None, verbose: bool = false, fresh: bool = false)
How the pieces of assembly(d) fit together, as placed (stand-ins count as obstacles): interference (pairs that overlap: the volume and where; pairs closer than the clearance without touching: the gap and where; faces resting on each other are contact) and hole alignment (round holes of two pieces on one axis are partners: offset beyond hole_tol mm, default 0.2, fails; their diameters read as screw holes, clearance + pilot / insert / nut, and a pair no single screw explains warns; a hole whose axis runs into solid material of the next piece has no partner). Male/female joint pairs from the script's joints(d) (or a Mates(joints=...) in checks(d)) are intentional fits measured against their own clearance. Stand-ins: labels saying stand-in or dummy, or matching no piece of build(). verbose: list the passing pairs too. One variant, or all. Uses the build cache (fresh=True rebuilds).
hardware_list¶
hardware_list(name: str = "", variant: str = None, count: int = 1, parts: str = None, format: str = "table")
What to buy: the bought hardware the script declares in hardware(d) (screws, inserts,
magnets, bearings), as one Markdown table to show the user: Qty | Item | Specification |
Used for | Source/link | Status ("check before ordering" where the specification is not
confirmed: ask the user, never guess it). Identical items are merged and summed. Offer it
when a part declares hardware. name: one part; parts: comma-separated part names to merge
into one list (each may be part:variant); neither: every part in the workspace. variant: the
variant (default: the standard one). count: how many assemblies ("for 4 brackets"), which
multiplies every quantity. format: 'table' (Markdown) or 'csv' (for a spreadsheet or cart).
Reads only hardware(d): builds nothing. The bom and bom_csv export formats write the
same list next to the exports. Changes nothing.
replication_spec¶
replication_spec(name, variant: str = None, as_json: bool = false)
The replication spec of a part copied from a physical original (the replicate_part
prompt): its MEASURE.md table (Feature | Value | Method | Accuracy | Status | Class | Source |
Field | Why changed) joined with the script's Dims values, as one Markdown table (Feature |
Field | Class | Source | Measured | Tol | Modeled | Δ | Why changed) plus flags: a critical
value still an estimate or not measured, readings spread wider than their accuracy (draft, an
oval hole, warp), a critical value modeled differently with no reason, a Field the script
lacks. Several readings in a Value cell ("4.21, 4.19, 4.22") are averaged. variant: whose Dims
(default: the standard one). Reads MEASURE.md and the Dims only: builds nothing, changes
nothing. The spec export format writes the same table to out/docs/.
trace_outline¶
trace_outline(part, file, dpi: float = None, grid: float = None, reference: str = "", points: str = "", distance: float = None, tolerance: float = 0.2, smooth: bool = false, pick: str = "", threshold: float = None, invert: bool = None, inline: bool = true)
Trace a flat object in a scan or photo (parts/<part>/ref/<file>, from upload_reference) into a
2D outline in mm for a part script: the largest object's outline and its holes, simplified to
tolerance mm (few points: dense polylines build slowly), or with smooth=True through-points
for a periodic spline. Scale, one of: dpi (a flatbed scan; omit everything to read it from the
file), grid (cell size in mm of a grid or cutting mat under the object), reference ('card' =
a credit card 85.60 x 53.98 mm beside the object, or 'L,S' mm of another rectangle), or points
('x1,y1,x2,y2' pixels, origin top left) with distance (mm between them). pick: 'x,y' pixel
inside the object to trace when it is not the largest. threshold (0..1) and invert (object
lighter than the background) override the automatic threshold. Writes out/docs/<file>_outline.json
(the points), out/docs/<file>_outline.py (a snippet with OUTLINE, OUTLINE_HOLES and a face function)
and out/images/<file>_trace.png (the outline on the image: show it to the user to confirm). A scan is
accurate to about a pixel; a photo only as far as it is square-on, flat and undistorted:
check a known dimension before trusting it.
Remote server (HTTP/SSH): the files stay on the server, as a temporary working copy deleted
when unused; bring the part home with download_part (one zip in the parts/<name>/ layout).
Never use ssh, scp or a shell on the server: there is none.
recipe¶
recipe(name: str = "")
Tested build123d recipes for common printable features, with printing notes and sources: teardrop holes, counterbores and countersinks, nut traps, magnet pockets, snap arms (with strain sizing), living hinges, print-in-place hinges, lids with a lip, text, bed-edge chamfers, zip-tie and cable slots, ribs and gussets. name: '' lists them; a recipe (or one of its function names) gives its code, an example and the notes. Use one before improvising the feature; part scripts import them: from b123d_print.recipes import snap_arm.
Prompts¶
design_part_from_photos¶
Arguments: description (optional).
Design a new part from photos and measurements: confirm dimensions first, then model, verify and report.
modify_part¶
Arguments: name, change.
Change an existing part, keeping its conventions, and re-verify.
remix_part¶
Arguments: name, source (optional), change (optional).
Remix someone else's model (STL, 3MF or STEP): inspect it, choose MODIFY or REDRAW, confirm the changes, then build, check (inherited vs new findings) and export.
replicate_part¶
Arguments: name, description (optional), scan (optional).
Copy a physical part (often injection-molded) as a printable one: a measurement plan, each dimension critical or free, molding features changed for FDM, a replication spec in MEASURE.md checked against the Dims, and a check of the copy against the original.
verify_part¶
Arguments: name.
Review an existing part against the rules and report findings.
design_review¶
Arguments: name, style (optional).
Review a part that passes the print checks for its purpose and design style: metrics, renders, 3-7 concrete suggestions with rule IDs. Changes nothing without the user's OK.
fit_test¶
Arguments: name, what (optional).
Make a fit-test template of a part: a quick thin print of a face, slice or region, to check size, hole pattern and mating fits before the full print.
setup_workspace¶
Arguments: none.
First-run setup: ask the user for the printer, material, export formats and default style, save them with save_setup, then offer the calibration coupons in order.
calibrate_hole_comp¶
Arguments: none.
Walk through measuring HOLE_COMP with the calibration coupon.
Resources¶
| URI | Type | What |
|---|---|---|
b123d-print://guide |
text/markdown |
The workflow and print rules (same text as AGENTS.md). |
b123d-print://template |
text/x-python |
The part-script template new_part starts from. |
b123d-print://recipes |
text/markdown |
The recipe library: tested build123d functions for common printable features. |
b123d-print://recipes/{name} |
text/markdown |
One recipe: its code, a tested example, printing notes and sources. |
b123d-print://files/{workspace}/{+path} |
application/octet-stream |
A file the server wrote (parts/<part>/out/..., e.g. out/print/<part>.3mf), in this session's own workspace ('_' = the root workspace). Tool results link to these; over HTTP the same files have download links. |
b123d-print://download/{workspace}/{part} |
application/zip |
A whole part as a zip in the local layout (parts/<part>/<part>.py, out/, ref/), in this session's own workspace; download_part links to it. |
Settings¶
The config.Settings fields; see Settings.
| Key | Default | Meaning |
|---|---|---|
hole_comp |
0.0 |
mm added to hole diameters when cutting (printed holes come out small) |
hole_comp_h |
null |
the same for horizontal holes (axis in XY); default: hole_comp |
clearance |
0.2 |
mm per side between mating parts that slide (the default fit) |
press_fit |
0.05 |
mm per side for parts pressed together |
free_fit |
0.3 |
mm per side for parts that turn or move freely |
pip_clearance |
0.3 |
mm between parts printed in place; the gap check fails below it |
min_wall |
0.8 |
mm; wall checks fail below this unless a check sets its own minimum |
max_overhang |
45.0 |
deg from vertical; steeper downward faces are flagged |
max_bridge |
10.0 |
mm; longer bridges (flat ceilings between two walls) warn |
max_triangles |
50000 |
import_model refuses meshes with more triangles (simplify them first) |
printer |
"" |
optional printer profile (b123d-print printer list); "" = generic |
material |
"" |
optional material profile: pla, petg, asa, abs, tpu or your own |
formats |
["step", "stl", "3mf", "png"] |
what export writes: step (other CAD), stl / 3mf (slicer), png (previews), glb (web/3D apps), print (the print sheet), hardware (declared BOM JSON), bom / bom_csv (the shopping list as Markdown / CSV), spec (the replication spec from MEASURE.md) |
style |
"" |
design style for parts without STYLE: functional (default), modern, least_cost, rugged, soft, structural, organic, decorative, toy or your own |
filament_price |
null |
price per kg; design_metrics shows a cost when set |
print_flow |
10.0 |
mm^3/s for the rough print-time estimate (standard hotend 8-12, high-flow 20+) |
tip_speed |
200.0 |
mm/s, the slicer's fastest print speed: the tip-over check scales with it; 0 = off |
supports |
"" |
your default support style for the print sheet: none, auto, build_plate_only, tree; "" = suggest from the geometry |
walls |
0 |
your default wall count (perimeters) for the print sheet and estimates; 0 = the slicer default (2) |
infill |
null |
your default infill percent for the print sheet and estimates; none = 15 |
review |
"warn" |
export's review mode (#146): warn (export, say what was skipped), required (refuse until the review steps are done, or skip_review="<reason>"), off |
parts_dir |
"parts" |
workspace-relative folder holding <name>/<name>.py |
nickname |
"" |
the printer's nickname when printer was set to one ([printers] table); printer is then its profile |