Skip to main content

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:

EditorWhere you find itWhat you set
Retethe palette: occt > shapes > solid, or a right-click search for boxthe fields on the component, or wires into its inputs
Blocklythe toolbox: occt > shapes > solid, or the toolbox searchthe blocks plugged into its inputs
TypeScriptbitbybit.occt.shapes.solid.createBox(...), with IntelliSense as you type the pathan 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:

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.

NamespaceWhat it is forFunctionsTierExplained in
bitbybit.occtThe entry point to the Bitbybit OCCT Kernel: every OCCT feature is reached through one of its properties.632npm packagesCode · reference
bitbybit.babylonThe BabylonJS side of the library: everything that lives in the rendered scene rather than in a CAD kernel.428npm packagesCode · reference
bitbybit.manifoldThe entry point to the Manifold kernel, a fast mesh-based solid modeler.129npm packagesCode · reference
bitbybit.verbNURBS curves and surfaces.115npm packages- · reference
bitbybit.thingsThe entry point to the finished parametric models, grouped by what they are for.88platformCode · reference
bitbybit.jscadThe entry point to the JSCAD kernel, a mesh-based solid modeler with three kinds of geometry.66npm packagesCode · reference
bitbybit.advancedAdvanced tools that do in one call what would take many steps.62platformCode · reference
bitbybit.ifcIFC building models as reached from a script.58npm packagesCode · reference
bitbybit.mathArithmetic, rounding, ranges, random numbers and the trigonometric functions on plain numbers.46npm packagesCode · reference
bitbybit.drawDrawing anything into the scene.45npm packagesCode · reference
bitbybit.datesDates and times as JavaScript Date values: creating them, reading and setting their parts, and formatting them as text.42npm packagesCode · reference
bitbybit.listsReading, building and reshaping plain arrays of any kind of item.42npm packagesCode · reference
bitbybit.vectorVector maths on plain number arrays.38npm packagesCode · reference
bitbybit.frameFrames: 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.36npm packagesCode · reference
bitbybit.textWorking with text: splitting, joining, searching, trimming, padding, changing case, regular expressions and formatting with placeholders.36npm packagesCode · reference
bitbybit.pointPoints as plain number arrays.34npm packagesCode · reference
bitbybit.colorColors in the two forms the library uses.18npm packagesCode · reference
bitbybit.assetFiles 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.17npm packagesCode · reference
bitbybit.lineStraight lines between two points, held as plain objects of the form { start, end }, and the segment form [start, end] of the same thing.16npm packagesCode · reference
bitbybit.polylinePolylines: chains of straight segments through a list of points, held as plain objects of the form { points, isClosed }.15npm packagesCode · reference
bitbybit.jsonReading and changing values inside JSON data.12npm packagesCode · reference
bitbybit.csvReading and writing CSV, the plain-text table format with one row per line and a separator between cells.11npm packagesCode · reference
bitbybit.threeThe Three.js side of the library: what lives in the rendered scene rather than in a CAD kernel.11npm packages- · reference
bitbybit.logicBooleans 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.10npm packagesCode · reference
bitbybit.meshGeometry on plain triangle meshes: a mesh is a list of triangles, each three points.8npm packagesCode · reference
bitbybit.cloudOperations that exist only on CAD Cloud, each behind its own REST route.5CAD Cloud-
bitbybit.playcanvasThe PlayCanvas side of the library: what lives in the rendered scene rather than in a CAD kernel.5npm packages- · reference
bitbybit.occtProPro OCCT algorithms that run on CAD Cloud as pipeline steps.4CAD Cloud-
bitbybit.tagText labels pinned to 3D positions.3npm packagesCode · reference
bitbybit.timeHooks into the frame loop of the scene.1npm packagesCode · reference

Inside bitbybit.occt​

NamespaceWhat it is forFunctionsTierExplained in
shapesShape construction in OpenCascade, grouped by what you are building: vertices, edges, wires, faces, shells, solids and compounds.301npm packagesCode · reference
operationsThe modeling operations that turn OpenCascade wires and faces into surfaces and solids and measure shapes.48npm packagesCode · reference
transformsMoving, turning, scaling and mirroring OpenCascade shapes, and building the 4x4 matrices that describe such moves.41npm packagesCode · reference
selectChoosing 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.29npm packagesCode · reference
ioReading and writing CAD files with OCCT.27npm packagesCode · reference
assemblyAssemblies as OpenCascade documents.25npm packagesCode · reference
analysisQuestions asked of OpenCascade shapes, answered with points, numbers and index lists rather than new shapes.24npm packagesCode · reference
filletsRounding and beveling the edges of OpenCascade shapes.22npm packagesCode · reference
featuresLocal modelling features on solids.20npm packagesCode · reference
sketchDrawing flat outlines with a pen.18npm packagesCode · reference
brepGraphStructural queries over an OpenCascade shape seen as a graph.13npm packagesCode · reference
designBuilds parametric parts and assemblies kept as data.11npm packagesCode · reference
booleansCombining OpenCascade shapes with each other.10npm packagesCode · reference
shapeFixChecks and repairs for OpenCascade shapes that came out of a file or an operation with defects.10npm packagesCode · reference
geomThe geometric layer beneath the topology: the mathematical curves and surfaces themselves, separate from the edges and faces that carry them.8npm packagesCode · reference
cornersRounding and beveling single corners of an OpenCascade shell or solid, picked by a point near them rather than by edge index.4npm packagesCode · reference
dimensionsMeasurement annotations drawn as OpenCascade wires.3npm packagesCode · reference
draftDraft angles for OpenCascade shapes: the slight taper cast and molded parts need so they slide out of the mold.3npm packagesCode · reference
recipesBuilding 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.3npm packagesCode · reference
svgImporting SVG drawings as OpenCascade shapes.2npm packagesCode · reference
pathA 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.1npm packagesCode · 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.