In this tutorial you will create a strictly watertight mounting bracket from scratch using the forma-3d WASM CLI, verify its manifold geometry, render a 4-view preview PNG and a 3-view SVG engineering blueprint, and export both a web-ready .glb and a millimeter-accurate .3mf file for 3D printing.
- Node.js
18.0.0or newer (node --version). - A terminal with an empty working directory. No Rust toolchain, GPU, or Blender installation is required.
Create a clean folder for this walkthrough:
mkdir forma-first-part && cd forma-first-partCheck that npx forma-3d runs cleanly:
npx -y forma-3d --versionYou should see forma 0.4.5.
Start with a minimal Forma-Pipe script that defines a single rectangular plate measuring 4 x 2 x 0.4 units centered at the origin:
cat > bracket.forma <<'EOF'
bracket = box(4, 2, 0.4)
EOFEvaluate the script with forma-3d eval:
npx forma-3d eval bracket.formaForma runs with strict manifold checking enabled by default and prints a compact observation:
OK [7.81ms] parts=1
- bracket: V=8 F=6 WT=ok NM=0 B=0 g=0 vol=3.200 bbox=[-2.00,-1.00,-0.20]..[2.00,1.00,0.20] size=[4.00,2.00,0.40]
tags: back(1) bottom(1) front(1) left(1) right(1) top(1)
diff: +bracket (vol=3.200)
Notice four fields in that line:
WT=ok: the mesh is watertight (closed solid with zero holes).NM=0: zero non-manifold edges.B=0: zero open boundary edges.tags: Forma automatically tagged each semantic face (top,bottom,front,back,left,right).
Now extend bracket.forma using pipeline stages (|) to drill a central bore (r = 0.5), drill four corner mounting holes (r = 0.2) using an at=[...] coordinate list, bevel the vertical edges, assign a brushed slate PBR material, and measure the z = 0 cross-section:
cat > bracket.forma <<'EOF'
bracket = box(4, 2, 0.4)
| cut(cyl(0.5, 1.0))
| cut(cyl(0.2, 1.0), at=[(-1.4, -0.5, 0), (-1.4, 0.5, 0), (1.4, -0.5, 0), (1.4, 0.5, 0)])
| bevel(vertical, 0.12)
| mat("anodized_slate", color=(0.35, 0.48, 0.62), metallic=0.85, roughness=0.3)
section(bracket, 0.0)
EOFRun eval and emit a .glb mesh, a 4-view shaded PNG preview, and a 3-view orthographic SVG drawing in a single command:
npx forma-3d eval bracket.forma \
--out bracket.glb \
--render bracket.png \
--draw bracket.svgForma validates the resulting solid and prints the updated invariants plus the cross-section query:
OK [189.23ms] parts=1
- bracket: V=336 F=520 WT=ok NM=0 B=0 g=5 vol=2.677 bbox=[-2.00,-1.00,-0.20]..[2.00,1.00,0.20] size=[4.00,2.00,0.40]
tags: bevel(520) bottom(176) hole(160) side(8) top(176)
diff: +bracket (vol=2.677)
query: section(part, z=0.000): loops=6 area=6.6914 perim=19.8738 xy=[-2.000,-1.000]..[2.000,1.000] size=[4.000,2.000]
Confirm what just happened:
- The genus increased from
g=0tog=5because the bracket now has five through-holes (one central bore plus four corner holes). section(bracket, 0.0)reportsloops=6(one outer perimeter plus five inner hole boundaries) and exact cross-sectional area6.6914.WT=ok NM=0 B=0proves the booleans and bevels produced a clean solid.
Verify that all three output files exist on disk:
ls -lh bracket.glb bracket.png bracket.svgOpen bracket.png to inspect the 4-view preview (isometric, front, right, top) and bracket.svg to inspect the dimensioned orthographic blueprint.
By default, Forma coordinates are in meters. When you author a physical part for a slicer, declare units("mm") at the top of the script and write dimensions directly in millimeters:
cat > bracket-mm.forma <<'EOF'
units("mm")
bracket = box(80, 40, 8)
| cut(cyl(10, 20))
| cut(cyl(3.2, 20), at=[(-30, -12, 0), (-30, 12, 0), (30, -12, 0), (30, 12, 0)])
| bevel(vertical, 2.5)
EOFEvaluate and export directly to .3mf:
npx forma-3d eval bracket-mm.forma --out bracket-mm.3mfForma confirms unit=mm in the header and embeds unit="millimeter" inside the .3mf package:
OK [65.88ms] parts=1 unit=mm
- bracket: V=336 F=520 WT=ok NM=0 B=0 g=5 vol=21980.009 bbox=[-40.00,-20.00,-4.00]..[40.00,20.00,4.00] size=[80.00,40.00,8.00]
tags: bevel(520) bottom(176) hole(160) side(8) top(176)
diff: +bracket (vol=21980.009)
You created a verified, strictly watertight 3D part with five through-holes and beveled edges, checked its cross-section mathematically, rendered both a 4-view PNG and an SVG blueprint, and exported .glb and millimeter .3mf deliverables using only npx forma-3d.
- Connect your coding agent to Forma over MCP: How to connect AI agents.
- Embed Forma inside Node.js, Cloudflare Workers, Edge, or browsers: How to embed forma-3d.
- Read how Forma's transactional rollback and invariants work: Explanation: Architecture.