Link Search Menu Expand Document

OCCTSwiftScripts documentation

A script harness for rapid iteration on OCCTSwift parametric geometry — the OCCTSwift answer to CadQuery / OpenSCAD. Edit a Swift script using the full OCCTSwift API, run it, and see the result live in the OCCTSwiftViewport demo app (the file watcher auto-reloads on each run). Bundled alongside is occtkit, a headless multi-call CLI of 29 reusable verbs (topology graph, ISO drawings, reconstruction, sheet metal, construction, introspection, mesh, render, I/O, XCAF) used by OCCTMCP and other downstream pipelines.

import OCCTSwift
import ScriptHarness

let ctx = ScriptContext()
let C = ScriptContext.Colors.self

let box = Shape.box(width: 60, height: 40, depth: 20)!
let drilled = box.drilled(at: SIMD3(30, 20, -1), direction: SIMD3(0, 0, 1),
                          radius: 6, depth: 22)!

try ctx.add(drilled, id: "plate", color: C.steel, name: "Drilled plate")
try ctx.emit(description: "60×40×20 plate with a Ø12 through-hole")
swift run Script                 # build + run Sources/Script/main.swift → live viewport reload

Cookbook

Task-oriented, example-rich recipes — short prose plus the actual Swift script (or occtkit invocation) and a rendered figure. The Cookbook index lists every area:

Script iteration · Authoring geometry · Sweeps, lofts & patterns · Gallery & 2D views · occtkit CLI basics · Construction · Introspection & measurement · Technical drawings · Reconstruction & sheet metal · Topology graph · Engineering analysis · Import, export & assemblies · Mesh & render

Reference

  • CLI & API Reference — per-family detail: the ScriptContext / ScriptHarness API, and every occtkit verb’s flags, JSON schema, what it returns, an example call + result, and the OCCTSwift call behind it.
  • README verb table — the one-line catalog.

Guides & concepts

  • Getting started — build, run your first script, wire up the live viewport, install occtkit.
  • Architecture — the targets (ScriptHarness / Script / DrawingComposer / occtkit), the output pipeline, the --serve envelope, and where this sits in the OCCTSwift ecosystem.

Project