Code in Bitbybit
Everything a Bitbybit script does, it does by calling the API: some two thousand functions under bitbybit, from bitbybit.point.spiral to bitbybit.occt.fillets.filletEdges. The three coding editors are three ways of calling the same functions, so what you learn here holds in all of them, and in the runners and npm packages as well.
One function, three editors
Take bitbybit.occt.shapes.solid.createBox. Its path says where it lives: in the OpenCascade kernel (occt), among its shapes, with the solids. Each editor finds it by that same path:
| Editor | Where you find it | What you set |
|---|---|---|
| Rete | the palette: occt > shapes > solid, or a right-click search for box | the fields on the component, or wires into its inputs |
| Blockly | the toolbox: occt > shapes > solid, or the toolbox search | the blocks plugged into its inputs |
| TypeScript | bitbybit.occt.shapes.solid.createBox(...), with IntelliSense as you type the path | an object of named inputs: { width: 4, length: 4, height: 4 } |
Every function takes one set of named inputs, most with a default, and returns one result. The API reference documents each one, and in Rete the path printed on a component links to its page there.
Start with the concepts
A handful of ideas explain most of what surprises people. Each page shows its idea in all three editors:
- Shapes live in a worker - why calls wait, why a shape is a handle, and why operations never change their inputs.
- Choosing a kernel - OpenCascade, Manifold or JSCAD, and moving a shape between them.
- Units, tolerance and precision - what a number means, and why a drawing's precision never changes the shape.
- Lists in every editor - a list as one value, and a function run once per item.
- Picking faces and edges - by index, by rule and by history.
- Checking a shape - volume, validity and repair, for the mistakes that do not fail.
- Getting a model out - STEP, STL, GLB and the other files, and a picture.
- Materials and the look of a model - colours, edges and physically based materials.
- Conventions - colours from 0 to 1, which way is up in each kernel, and the defaults that surprise people.
How Bitbybit works puts these ideas in the context of the whole platform.
What only one editor has
Most of the palette and the toolbox is the API. A few things belong to one editor, because they are about how that editor works rather than about geometry:
- Rete: modules that package part of a graph as a component, code components that hold a TypeScript function, groups and comments, sliders, and flow components that run on events such as a key press or a timer.
- Blockly: variables and functions, loops and Blockly's own maths, text and logic blocks.
- TypeScript: anything the language offers, a script of many files, and BabylonJS itself beside the API.
The map of the API
Every namespace, what it is for, how many functions it holds, which tier it belongs to, and where Code explains it. A namespace without a Code page is still documented in full in the reference.
| Namespace | What it is for | Functions | Tier | Explained in |
|---|---|---|---|---|
bitbybit.occt | The entry point to the Bitbybit OCCT Kernel: every OCCT feature is reached through one of its properties. | 632 | npm packages | Code · reference |
bitbybit.babylon | The BabylonJS side of the library: everything that lives in the rendered scene rather than in a CAD kernel. | 428 | npm packages | Code · reference |
bitbybit.manifold | The entry point to the Manifold kernel, a fast mesh-based solid modeler. | 129 | npm packages | Code · reference |
bitbybit.verb | NURBS curves and surfaces. | 115 | npm packages | - · reference |
bitbybit.things | The entry point to the finished parametric models, grouped by what they are for. | 88 | platform | Code · reference |
bitbybit.jscad | The entry point to the JSCAD kernel, a mesh-based solid modeler with three kinds of geometry. | 66 | npm packages | Code · reference |
bitbybit.advanced | Advanced tools that do in one call what would take many steps. | 62 | platform | Code · reference |
bitbybit.ifc | IFC building models as reached from a script. | 58 | npm packages | Code · reference |
bitbybit.math | Arithmetic, rounding, ranges, random numbers and the trigonometric functions on plain numbers. | 46 | npm packages | Code · reference |
bitbybit.draw | Drawing anything into the scene. | 45 | npm packages | Code · reference |
bitbybit.dates | Dates and times as JavaScript Date values: creating them, reading and setting their parts, and formatting them as text. | 42 | npm packages | Code · reference |
bitbybit.lists | Reading, building and reshaping plain arrays of any kind of item. | 42 | npm packages | Code · reference |
bitbybit.vector | Vector maths on plain number arrays. | 38 | npm packages | Code · reference |
bitbybit.frame | Frames: a frame is a point with three axes at right angles, written as its origin, its normal (the Z axis) and its direction (the X axis), the Y axis following from those two. | 36 | npm packages | Code · reference |
bitbybit.text | Working with text: splitting, joining, searching, trimming, padding, changing case, regular expressions and formatting with placeholders. | 36 | npm packages | Code · reference |
bitbybit.point | Points as plain number arrays. | 34 | npm packages | Code · reference |
bitbybit.color | Colors in the two forms the library uses. | 18 | npm packages | Code · reference |
bitbybit.asset | Files in and out of a script: assets the running application stores under a name, files fetched from a URL, downloads, and conversions between File, Blob, ArrayBuffer and Uint8Array. | 17 | npm packages | Code · reference |
bitbybit.line | Straight lines between two points, held as plain objects of the form { start, end }, and the segment form [start, end] of the same thing. | 16 | npm packages | Code · reference |
bitbybit.polyline | Polylines: chains of straight segments through a list of points, held as plain objects of the form { points, isClosed }. | 15 | npm packages | Code · reference |
bitbybit.json | Reading and changing values inside JSON data. | 12 | npm packages | Code · reference |
bitbybit.csv | Reading and writing CSV, the plain-text table format with one row per line and a separator between cells. | 11 | npm packages | Code · reference |
bitbybit.three | The Three.js side of the library: what lives in the rendered scene rather than in a CAD kernel. | 11 | npm packages | - · reference |
bitbybit.logic | Booleans and decisions: comparing values, flipping booleans, turning lists of numbers into lists of booleans by thresholds, drawing random booleans, and gating a value so it passes only when a condition holds. | 10 | npm packages | Code · reference |
bitbybit.mesh | Geometry on plain triangle meshes: a mesh is a list of triangles, each three points. | 8 | npm packages | Code · reference |
bitbybit.cloud | Operations that exist only on CAD Cloud, each behind its own REST route. | 5 | CAD Cloud | - |
bitbybit.playcanvas | The PlayCanvas side of the library: what lives in the rendered scene rather than in a CAD kernel. | 5 | npm packages | - · reference |
bitbybit.occtPro | Pro OCCT algorithms that run on CAD Cloud as pipeline steps. | 4 | CAD Cloud | - |
bitbybit.tag | Text labels pinned to 3D positions. | 3 | npm packages | Code · reference |
bitbybit.time | Hooks into the frame loop of the scene. | 1 | npm packages | Code · reference |
Inside bitbybit.occt
| Namespace | What it is for | Functions | Tier | Explained in |
|---|---|---|---|---|
shapes | Shape construction in OpenCascade, grouped by what you are building: vertices, edges, wires, faces, shells, solids and compounds. | 301 | npm packages | Code · reference |
operations | The modeling operations that turn OpenCascade wires and faces into surfaces and solids and measure shapes. | 48 | npm packages | Code · reference |
transforms | Moving, turning, scaling and mirroring OpenCascade shapes, and building the 4x4 matrices that describe such moves. | 41 | npm packages | Code · reference |
select | Choosing faces and edges of OpenCascade shapes by what they are, where they lie and how they meet, rather than by an index that shifts whenever the model changes. | 29 | npm packages | Code · reference |
io | Reading and writing CAD files with OCCT. | 27 | npm packages | Code · reference |
assembly | Assemblies as OpenCascade documents. | 25 | npm packages | Code · reference |
analysis | Questions asked of OpenCascade shapes, answered with points, numbers and index lists rather than new shapes. | 24 | npm packages | Code · reference |
fillets | Rounding and beveling the edges of OpenCascade shapes. | 22 | npm packages | Code · reference |
features | Local modelling features on solids. | 20 | npm packages | Code · reference |
sketch | Drawing flat outlines with a pen. | 18 | npm packages | Code · reference |
brepGraph | Structural queries over an OpenCascade shape seen as a graph. | 13 | npm packages | Code · reference |
design | Builds parametric parts and assemblies kept as data. | 11 | npm packages | Code · reference |
booleans | Combining OpenCascade shapes with each other. | 10 | npm packages | Code · reference |
shapeFix | Checks and repairs for OpenCascade shapes that came out of a file or an operation with defects. | 10 | npm packages | Code · reference |
geom | The geometric layer beneath the topology: the mathematical curves and surfaces themselves, separate from the edges and faces that carry them. | 8 | npm packages | Code · reference |
corners | Rounding and beveling single corners of an OpenCascade shell or solid, picked by a point near them rather than by edge index. | 4 | npm packages | Code · reference |
dimensions | Measurement annotations drawn as OpenCascade wires. | 3 | npm packages | Code · reference |
draft | Draft angles for OpenCascade shapes: the slight taper cast and molded parts need so they slide out of the mold. | 3 | npm packages | Code · reference |
recipes | Building recipes exactly: solids described as data - polygons, circles, extrusions, turns, lofts, cuts by solids and planes, openings, unions, intersections, transforms and triangle meshes - by a package that does not build geometry itself, such as one that reads building models. | 3 | npm packages | Code · reference |
svg | Importing SVG drawings as OpenCascade shapes. | 2 | npm packages | Code · reference |
path | A generic 2D path builder: describe an outline as subpaths of line, quadratic, cubic and arc segments, the vocabulary of SVG paths, and get an OpenCascade wire or face in one call. | 1 | npm packages | Code · reference |
Writing code with an agent
An AI agent writing Bitbybit code should read Geometry with the kernels, which the Bitbybit CAD MCP serves through get_guide: which kernel to use, the order to build a part in, how to choose edges, check a shape and export it, and the mistakes to avoid.