SoftForge OCCT add-on
The OpenCASCADE (OCCT) kernel for the SoftForge Electronic Workbench extension (SoftForge.softforge-electronic-workbench, 1.4.0 and newer).
It is a separate extension because the kernel — opencascade.js 1.1.1, OCCT 7.4 compiled to WebAssembly — is about
65 MB; the main extension stays small and works without it.
With the add-on installed the MCAD features of the main extension get:
| Feature |
Without the add-on |
With the add-on |
| Reference solids (enclosures) |
.glb only |
.step / .stp meshed to glb |
| Board → STEP |
— |
board (outline, holes, thickness) + component models as a named STEP assembly |
| Outline from MCAD |
DXF (pure TypeScript) |
DXF, or the largest ±z planar face of a STEP (section fallback) |
| 2D booleans |
clipper |
OCCT faces (union, subtract, intersect) |
| Mounting bosses |
from IDX / by hand |
vertical cylinders of an enclosure STEP |
| System assembly export |
— |
one STEP of all boards placed by their matrices |
Install
Build the VSIX from the repository root with npm run package:occt (about 14 MB; the wasm is compressed in it), then
install it next to the main extension:
code --install-extension softforge-occt-1.4.0.vsix
On start-up the add-on activates the main extension and registers itself with api.system.registerOcct(...). The
wasm is loaded lazily on the first OCCT call (about 0.6 s). The SoftForge OCCT output channel logs the load time,
each call and errors; SoftForge OCCT: Self test meshes a box and shows the kernel version.
The ewb CLI
ewb runs without VS Code, so it finds the add-on by itself: EWB_OCCT_ADDON (the add-on folder or its
out/service.js), else the newest installed softforge.softforge-occt-* under ~/.vscode/extensions,
~/.vscode-server/extensions, ~/.vscode-oss/extensions or ~/.vscode-insiders/extensions. It requires
out/service.js and calls createOcctService().
EWB_OCCT_ADDON=/path/to/packages/occt-addon ewb …
Frames
- STEP / MCAD frame: mm, z up, x = KiCad x, y = −KiCad y, z = 0 on the board's bottom face (KiCad's own STEP frame
without an origin offset). Every service call works in this frame.
- glb: metres, y up — glb (x, y, z) = MCAD (x, z, −y) / 1000, like kicad-cli.
Service (out/service.js, createOcctService())
stepToGlb(step, { meshQuality }) — one mesh per solid; linear deflection = bbox diagonal × lerp(0.01, 0.0005, q),
angular lerp(0.5, 0.15, q) rad; bounds in mm.
boardToStep({ outline, holes, thickness, components }) — board prism from z = 0 with the holes cut; components
read from their STEP, scaled, rotated about x, then y, then z (degrees) and moved to at. Written as an XCAF
assembly "Board" with the part "PCB" and one part per reference (a model used twice is stored once).
outlineFrom(file, { plane, tolerance }) — .dxf through the TypeScript reader; STEP: the largest planar face with a
±z normal (top-most for top, bottom-most for bottom), curved edges discretised to tolerance (mm); without such a
face a section at mid height is chained into loops.
booleans(a, b, op) — each input set is one region by the even–odd rule; the result is flattened as, for each face,
its outer ring (counter-clockwise) followed by its holes (clockwise).
bossesOf(step) — vertical cylindrical faces with 1 mm ≤ d ≤ 20 mm, merged within 0.1 mm: at = axis x, y and the
face's top z; height = the face's z extent.
assemblyStep(parts) — each part's STEP placed by its column-major 4×4 matrix (rigid), one named STEP assembly.
version(), available() (the wasm file is present; does not load it).
Limits
- opencascade.js 1.1.1 is single-threaded: large STEP files (100k+ faces) take seconds and block the extension host
while they mesh.
- Colours and names are not read from STEP files (shapes only); names are written on export.
- Non-uniform component scales are applied as a general transform (the geometry may become B-splines).
- If the XCAF writer fails, assemblies fall back to one unnamed compound (
lastAssemblyMode() reports compound).
License
The SoftForge code is MIT (LICENSE). opencascade.js and OCCT are LGPL-2.1; they ship unmodified as the separate file
out/opencascade.wasm.wasm that the add-on loads at run time and that you may replace. See THIRD_PARTY_NOTICES.md.
Development
cd packages/occt-addon
npm install # opencascade.js 1.1.1 (devDependencies come from the repository root)
npm run typecheck && npm run build
npm run make-enclosure # rewrites fixtures/mcad/enclosure.step
npm run package # ../../softforge-occt-1.4.0.vsix
cd ../.. && OCCT=1 npx tsx --test test/mcad.occt.test.ts
| |