Docs · Node.js

Node.js API

The Node.js wrappers over the cadaclysm library: the reader reads, meshes and writes; the kernel builds exact solids. Every type and call, with the signature as the wrapper declares it — read from its source when this page is built.

Install

Install and load

node/cadaclysm.js (the reader, require('cadaclysm')), node/cadaclysm_blacksmith.js (the kernel, require('cadaclysm/blacksmith')) and node/cadaclysm_view.js (drawing, require('cadaclysm/view')), over koffi, with TypeScript declarations beside them. Node.js 18 or later.

Get the libraries with the SDK's fetch.py (or unpack a release archive's lib/ and include/); keep the wrapper files and the libraries from the same release. Details on the start page.

cd node && npm install          # koffi
npm install ./path/to/sdk/node   # from your own project

Where the library is found

CADACLYSM_LIBRARY (for the kernel, CADACLYSM_BLACKSMITH_LIBRARY), a file or a directory; else beside the module; else a lib/ directory in any parent. The view library: CADACLYSM_VIEW_LIBRARY (the GPU window's, cadaclysm_view) or CADACLYSM_TERMINAL_LIBRARY (the terminal's, cadaclysm_terminal), each a file or a directory; else beside the module; else a lib/, target/release or target/debug directory in any parent. CADACLYSM_VIEW (terminal, wgpu or a library's path) picks the library without code; the terminal is the default.

One library serves both modules, whichever flavour it is. The reader looks for cadaclysm (the full flavour), cadaclysm_kernel_reader, cadaclysm_reader and then the separate cadaclysm_capi of earlier releases; the kernel for cadaclysm, cadaclysm_kernel_reader, cadaclysm_kernel and then the separate cadaclysm_blacksmith, and reads CADACLYSM_LIBRARY when CADACLYSM_BLACKSMITH_LIBRARY is not set, passing over one that names the separate reader. cadaclysm.flavour() says which was loaded. A call the loaded flavour does not have throws CadaclysmError when it is made, naming the flavour and its features; loading a module from a flavour without its half (the kernel from cadaclysm_reader, the reader from cadaclysm_kernel) fails at once.

The licence

Unlicensed, everything works and a notice is printed on every open and export. A licence file removes it: set CADACLYSM_LICENSE, or put cadaclysm.lic beside the executable or in the working directory, or load it from code with either line below: one call covers the whole library (the two separate libraries of earlier releases need both).

require('cadaclysm').license('cadaclysm.lic');
require('cadaclysm/blacksmith').license('cadaclysm.lic');
Quick start

Build a part, then read it back

The kernel builds a plate with a boss, bores it and rounds its corners, then writes STEP — the Examples page's first part:

const { Axis, Profile, Selector, Workplane } = require('cadaclysm/blacksmith');

const plate = Workplane.xy().extrude(Profile.rect(120, 80), 14).solid();
const boss = Workplane.fromSolid(plate)
  .faces(Selector.max(Axis.Z)).workplane()
  .extrude(Profile.circle(22), 26).solid();
let part = plate.join(boss);

const bore = Workplane.xy().extrude(Profile.circle(11), 60).solid().translate(0, 0, -10);
part = part.cut(bore);

// The plate's four vertical corners: the lines along Z between two planes
// (the boss has vertical seams too, but those lie on its cylinder).
const corners = part.edges().filter((e) => e.isLine && Math.abs(e.direction[2]) > 0.99
  && e.faces.every((f) => part.faceKind(f) === 'plane'));
part = part.fillet(corners, 12);
part.step('plate.stp');

Or try it in the browser first: the JavaScript notebook runs this same wrapper over the WebAssembly build of the library, nothing installed, and opens on this very part, and takes TypeScript too.

The reader opens that file, walks its tree, meshes what it draws and writes glTF:

const cadaclysm = require('cadaclysm');

const scene = cadaclysm.open('plate.stp');
try {
  console.log(scene.schema, scene.metresPerUnit, 'm per unit');

  // The tree: assemblies, parts and bodies, parents before children.
  for (const node of scene.walk()) {
    console.log('  '.repeat(node.depth) + node.label, `[${node.kind}]`);
  }

  // What to draw: every placement of every shape, meshed on first ask.
  for (const placement of scene.placements()) {
    console.log(placement.geometry.label, placement.geometry.mesh().triangleCount, 'triangles');
  }

  scene.save('plate.glb');
} finally {
  scene.close();
}
Reader · cadaclysm_*

Reading, meshing, writing

Module functions

Loading the library, the licence, and opening a file — from disk or from bytes already in memory. Every other object on this page comes out of cadaclysm.open() or cadaclysm.openMemory().

cadaclysm.open()

function open(path: string, options?: OpenOptions): Scene

Open a CAD file and read its tree. The format comes from the extension (a .zip or .stpZ opens its first readable member — Scene.sourceName says which — and a .gz is read as the format named before it, part.step.gz as .step). The tree is read now and the geometry is built lazily, node by node, when it is first asked for.

convention is the space to read into — a Convention, optionally with the file-units and world-UV flags — and the library converts everything it hands back into it. schema names an extra EXPRESS schema (.exp, or a directory of them); every schema the SDK ships is already built in, so it is needed only for one the library does not carry. colours asks for per-vertex colours on bodies the file painted in more than one colour.

Never returns an empty handle: on failure it throws CadaclysmError carrying the library's reason.

options is { schema, convention, colors, sourceMetersPerUnit, lightmapResolution }; lightmapResolution is the lightmap atlas size in texels (0 or absent for none).

cadaclysm.openMemory()

function openMemory(bytes: Bytes, format: string, options?: OpenMemoryOptions): Scene

Open a file already in bytes — a download, a database blob, an archive member. With no file name to take the format from, it is named as an extension would name it: step, ifc, igs, 3dm, brep, scad, 3mf, ply (a leading dot is fine). The bytes are copied; the buffer can be reused as soon as this returns. Otherwise as cadaclysm.open().

cadaclysm.version()

function version(): string

The version of the library actually loaded — the one worth reporting in a bug.

cadaclysm.flavour()

function flavour(): string;

Which library is loaded: "full", "kernel-reader" or "reader" for a flavour of the single cadaclysm library ("kernel" has no reader to ask), and "reader" for the separate cadaclysm_capi of earlier releases. A call the loaded flavour does not have throws CadaclysmError naming the flavour and its features, and saying the full flavour has it.

cadaclysm.features()

function features(): string

The features the loaded library was built with, comma-separated — "nodes,kernel,write-breps,write-meshes,bim,parts" for the full flavour, "nodes,write-meshes" for the reader — and empty for the separate cadaclysm_capi.

cadaclysm.buildDate()

function buildDate(): string

When the loaded library was built, YYYY-MM-DD. A licence covers every build dated on or before its expiry.

cadaclysm.license()

function license(textOrPath: string): void

Load a licence: the certificate text, or the path of a file holding it. Without this call the library looks in the CADACLYSM_LICENSE environment variable, then for cadaclysm.lic beside the executable and in the working directory. On a licence that does not verify it throws CadaclysmError with the reason, and the previous licence (if any) stays in use.

cadaclysm.licenseInfo()

function licenseInfo(): string

One line about the licence in use — customer=… expiry=… scope=… — or unlicensed (unlicensed -- <reason> when a licence was found but did not verify). Never null.

cadaclysm.licenseNoticeCount()

function licenseNoticeCount(): number

How many unlicensed notices the library has printed to stderr in this process. An application with no console to watch (a GUI, a game) can poll this and show its own banner.

cadaclysm.meshFormats()

function meshFormats(): [name: string, extension: string, label: string][]

Every mesh format Node.saveMesh() writes, with its file extension and a label for a save menu: stl (STL (binary)), stl-ascii (writes .stl too), msh (Gmsh), glb, gltf, obj, usda, 3mf (3D Manufacturing Format), ply (PLY (binary)) and ply-ascii (writes .ply too) in this release. Build the menu from this list rather than hard-coding it, and a format added to the library appears without a code change.

cadaclysm.lodLevels()

function lodLevels(): number

How many coarser levels Node.meshLod() offers above the mesh itself (level 0): 3 in this release.

cadaclysm.formats()

function formats(): [name: string, extensions: string[]][]

Every format this build reads, each with the file extensions it takes — what an open dialog's filter is built from, the way cadaclysm.meshFormats() feeds a save menu.

datetimeOf

A schedule date (seconds since 1970-01-01T00:00, as WorkSchedule.at() and TaskTime give them) as a naive datetime.

Seconds since 1970-01-01T00:00, no zone: new Date(seconds * 1000), read with toISOString() or the getUTC* accessors.

secondsOf

A naive datetime as a schedule date: seconds since 1970-01-01T00:00, the inverse of datetimeOf.

Seconds since 1970-01-01T00:00, no zone: new Date(seconds * 1000), read with toISOString() or the getUTC* accessors.

cadaclysm.pickSave()

function pickSave(suggestedName?: string): string | null

Ask the user where to save, through the platform's own dialog, with suggested_name prefilled. null when they cancel or no dialog is available. Blocks until the user acts; on macOS call it from the main thread.

cadaclysm.pickFile()

function pickFile(): string | null

Ask the user for a file through the platform's own open dialog, filtered to what this build can read. null when they cancel or no dialog is available (on Linux, neither an XDG portal nor zenity). Blocks until the user acts; on macOS call it from the main thread.

cadaclysm.declaredSchema()

function declaredSchema(model: string): string

The schema a STEP or IFC file says it speaks (its FILE_SCHEMA line), read from the first few kilobytes — cheap even on a very large file. Empty when it names none.

cadaclysm.resolveSchema()

function resolveSchema(model: string, schema: string | null | undefined): { chosen: string | null; fallbacks: string[] };

Which .exp of a schema directory matches a model: the chosen file, or — when the file's declared name resembles none of them — the whole list as fallbacks to try in turn. cadaclysm.open() does this itself when given a directory; this is for a caller that wants to report the choice.

cadaclysm.libraryPath()

function libraryPath(): string;

Where the shared library was found: CADACLYSM_LIBRARY (a file or a directory) first, then beside the wrapper, then a lib/ directory in any parent (the SDK's layout).

cadaclysm.NONE

const NONE

The node index the C API uses for "no such node" (CADACLYSM_NONE, 0xFFFFFFFF). The wrappers turn it into null where a node may be missing (Node.parent, Node.instanceOf), so it matters only when reading raw indices.

Options and async Node.js only

interface OpenOptions
function openAsync(path: string, options?: OpenOptions): Promise<Scene>
function openMemoryAsync(bytes: Bytes, format: string, options?: OpenMemoryOptions): Promise<Scene>;

The keyword arguments are one options object. Each blocking call has an …Async twin (openAsync, realizeAllAsync, meshAsync, saveMeshAsync) that runs it on a worker thread and returns a promise, so a server stays responsive while a large file loads.

Scene

class Scene

An open document. Close it when done — Scene.close(), or let the language's scope do it (with, using, defer, try-with-resources). Everything it hands back borrows from it: node handles, meshes, polylines. See Lifetimes for what survives a close.

Scene.close()

close(): void

Give the document back. Idempotent. Every mesh and polyline view still held reads freed memory afterwards (the wrappers that can tell refuse to read them). Node and Godot hand back copies, so nothing of theirs goes stale here.

Scene.closed

readonly closed: boolean

Whether Scene.close() has run.

Scene.path

path: string

The file it was read from, or the name given to cadaclysm.openMemory().

Scene.schemaPath

schemaPath: string | null

The .exp actually used, or null — worth reporting when a directory was passed.

Scene.convention

convention: number

The convention it was opened with. Nothing the library hands back says what space it is in, and every array out of this scene is in this one.

Scene.version

readonly version: string

The version of the library that read it.

Scene.schema

readonly schema: string

The schema the file named, or empty for a format that names none.

Scene.schemaRead

readonly schemaRead: string

The schema that actually read it. A file declaring a release candidate reads under the finished schema of the same version where that is what is built in; a file whose schema is unknown reads under the one that defines its entity types.

Scene.substituted

readonly substituted: boolean

Whether something other than the file's own schema read it — Scene.schema and Scene.schemaRead differ.

Scene.metresPerUnit

readonly metresPerUnit: number

What one length unit in the file is worth in metres; 1 where the file did not say.

Scene.tolerances

readonly tolerances: Tolerances

What the file declares about its own precision, as Tolerances: the absolute tolerance in the file's own unit (beside Scene.metresPerUnit, whatever convention the scene was opened into) and the angular one in radians, each none where the file did not say — a 3dm's units and tolerances, STEP's uncertainty, SAT's resabs, IGES's resolution; other formats declare nothing. Each body read from the file carries a copy, which the kernel's verbs given no tolerance work from.

Scene.bounds

readonly bounds: Bounds

Everything the model covers, in world coordinates — the one figure not in a node's own frame. This meshes the whole model, being the only way to know how far it reaches; to frame a view quickly, use the bounds of the nodes already built.

Scene.bounds64

readonly bounds64: Bounds64

Scene.bounds in double precision, in world coordinates: the model's extent unnarrowed, exact far from the origin. This meshes the whole model, as Scene.bounds does.

Scene.diagnostics()

diagnostics(): string[]

What the file held that the reader could not build, one line each.

Scene.joints()

joints(): Joint[]

The connections between those links, in the file's order; each names, through Joint.pair, how it moves.

Scene.states()

states(): State[]

The file's named mechanism poses, in file order, each a State. Empty for a file that records none.

Scene.sequences()

sequences(): Sequence[]

The file's motion sequences — INTERPOLATED_CONFIGURATION_SEQUENCE, a mechanism moving through its states — in file order, each a Sequence. Empty for a file that records none.

Scene.schedules()

schedules(): WorkSchedule[]

The file's work schedules (IFC 4D: IfcWorkSchedule and the tasks it controls), in file order, each a WorkSchedule. Empty for a file that records none.

Scene.calendars()

calendars(): WorkCalendar[]

The file's work calendars (IFC 4D: IfcWorkCalendar), in file order, each a WorkCalendar. A task's Task.calendarIndex indexes this list. Empty for a file that records none.

Scene.base

readonly base: Link | null

The link the file declares as the mechanism's base, or null when it declares none.

Scene.pose()

pose(values?: Iterable<StateValue | [Joint, ArrayLike<number>]>, ground?: Link | null): Pose

The mechanism posed by values — rows of a joint and one number per freedom of its pair, in the pair's freedom order, exactly State.values's row type — with ground (a Link, or null for the default ground: the declared Scene.base, else the link on the most joints) held fixed. Values outside a freedom's range are used as given and reported in the answer's Pose.outOfRange. throws CadaclysmError on a bad row or a file with no mechanism, carrying the library's own message.

Scene.poseState()

poseState(state: State, ground?: Link | null): Pose

The mechanism posed by a named State's values, ground held fixed as Scene.pose() does. throws CadaclysmError as Scene.pose() does.

Scene.geometryDiagnostics()

geometryDiagnostics(): string[]

What the reader built but the geometry stage could not finish — a face that would not trim, a surface that would not mesh — one line each. Scene.diagnostics() is what the *file* held that could not be read; this is what the geometry did.

Scene.sourceName

readonly sourceName: string | null

The archive member this was read from, or null for a plain file.

Scene.nodes()

nodes(): Node[]

Every node, in index order: assemblies, shapes, layers, storeys — structure as well as geometry. To draw, iterate Scene.placements() instead.

Scene.roots()

roots(): Node[]

The nodes nothing else contains: where a tree view starts.

Scene.walk()

walk(): IterableIterator<Node>

Every node reachable from the roots, parents before children.

Scene.query()

query(filter: string): number[]

The indices of the nodes a filter matches, in document order. The filter is one boolean expression in the query language — class == ON_Brep and within(name == Walls). A filter that does not parse throws CadaclysmError with the parser's message and position; one that matches nothing is an empty result, not an error.

Scene.placements()

placements(): Placement[]

What the document draws, and where. Not the nodes: a block or an instanced part is one node of geometry drawn at several places, and a node walk draws it once at its definition's frame. Iterate this to draw, and the nodes to build a tree. See Placement.

Scene.realizeAll()

realizeAll(): number

Build every mesh now, across all cores, and return how many were built. Reading is lazy so a tree can be on screen while the shapes are still coming; asking node by node meshes on one core, this uses them all. Watch it from another thread with Scene.realized and Scene.realizeTotal; stop it with Scene.cancel().

Scene.realizeMeshes()

realizeMeshes(skipSurfaced?: boolean): number

Scene.realizeAll(), leaving alone every node that carries surfaces when skip_surfaced is true (the default): a renderer drawing those parts from their surfaces never pays for their triangles, and takes their bounds from Node.bounds, which falls back to the surfaces.

Scene.realized

readonly realized: number

How many nodes Scene.realizeAll() has finished. Safe to read from another thread.

Scene.realizeTotal

readonly realizeTotal: number

How many it will build in all; zero until it starts.

Scene.cancel()

cancel(): void

Ask a running Scene.realizeAll() to stop. One-way for the life of the scene: later calls return at once, and meshes are still built one node at a time on request.

Scene.forgetMeshes()

forgetMeshes(): void

Drop every mesh the scene has built and give the memory back; the next ask rebuilds. For a viewer that has uploaded what it needs. What it frees is the document's own mesh, which Node.mesh64() lends: a view from before it points at freed memory afterwards, so the scene counts its forgets and a Mesh64 read after one is refused as a stale view rather than read. Mesh, Polylines and the Béziers are the library's own caches, which a forget does not touch and which stay good until Scene.close(); Node and Godot hand back copies, unaffected by either.

Scene.save()

save(path: string, format?: string): void

Write the whole scene: glb (binary glTF), gltf (text glTF, one file), obj (every placement baked to its own named object, with a .mtl beside it when anything has a colour), usda (an OpenUSD text layer: each shape's triangles once, every placement a prim referencing them, and a node's MaterialX or MDL material — its ExternalStyle.* or MaterialReference.* properties — bound in its own format over a preview of its colour), 3mf (a 3MF package: each shape an object once, every placement a build item with its world matrix, a colour per object), ply (binary little-endian) or ply-ascii (PLY has no tree: every placement baked through its world matrix into one body, a colour a vertex where anything has one), or 3dm (a Rhino file, version 8: each body as its exact brep where the file kept one and as its mesh otherwise, a shape drawn in several places once as a block with a reference at each, layers, names and colours kept; written in the file's own units and axes, so it needs a scene opened in the native convention). Every placement of every shape, named and placed as the tree is, one material per colour; in the scene's convention (use Y-up metres for the space glTF specifies; a USD layer states its up axis and metres per unit). A mechanism moves: in glTF each moving link hangs under a pivot node on its joint, in USD each link is a UsdPhysics rigid body — its mass and inertia summed from its parts at their declared density (water's where the file declares none), its parts colliding in convex pieces — and each pair a joint prim (for a simulator such as Isaac Sim); glb-skinned, gltf-skinned and usda-skinned write it as a skin instead, one bone per link (a UsdSkel skeleton in USD), for engines that move skeletal meshes only. A format outside these, or a failed write, throws CadaclysmError.

Scene.surfaceMatrix

readonly surfaceMatrix: Float32Array

The 4×4 that puts Node.surfaces() into the space everything else is already in. Meshes and polylines arrive in the scene's convention; surfaces arrive in the file's own frame, because converting a surface means converting its parameter space too. Identity for a document opened in its native convention and units.

Scene.show()

show(options?: ShowOptions): void

Draw every visible placement — each block instance where the file puts it — with the viewer in use. Keywords: view= (front, back, left, right, top, bottom, iso), az=, el=, zoom=, up= (default from the convention the scene was opened with), edges= (the B-rep edges over the shapes; on the terminal library, edges=False also hides free curves — the two share one layer there), width=, height=, hint=. No tolerance=: a document is drawn at the tolerance it was read with. With the GPU library (import cadaclysm.view.wgpu) the drawing replaces what one shared window shows and stays live — at the REPL, in IPython and in Jupyter by themselves, in a script until it exits; cadaclysm.view.View draws several items or several windows.

Takes an options object: view, azimuth, elevation, zoom, up, edges, width, height, title. A tolerance is refused: a document is drawn at the tolerance it was read with. On the wgpu library (require('cadaclysm/view').useWgpu()) it replaces what one shared window shows and returns; a 16 ms timer keeps the window live and holds the process until it is closed. On the terminal it prints a still.

Scene.view()

view(options?: ShowOptions): Camera

Orbit the model with the viewer in use; returns the camera where it was left — a dict of eye, target, up, orthographic, azimuth and elevation — and pick, what was last clicked (item, node, face) or None. A fresh window, run until closed, with the GPU library.

Takes the options show does; returns a Camera object with these fields.

Scene.svg()

svg(path: string, options?: SvgOptions): void

Every visible placement's wireframe as SVG, from a camera the keywords describe rather than a viewer window: view= (front, back, left, right, top, bottom, iso — Scene.show()'s own table), az=/el= over it, up= (default from the convention this scene was opened with), fov= (0, the default, is orthographic), size= (width, height), margin= (fraction of the content's extent left each side), tolerance= (how far a written curve may stray, in page units), stroke= and background= ("#rgb", "#rrggbb" or a CSS colour name in every language, beside that language's own numeric form; background= null for transparent), width= (the stroke's, in page units), edges=, curves=, isocurves=, polylines= (which line sets are drawn; edges by default), and silhouettes= (also draw where each solid's surfaces turn away from the eye — the outline a sphere has no edge for, on by default: a sphere's and a torus's only curves are the seams where their one face meets itself, which are not edges of the body and are never drawn, so without it those two draw a blank page. A line set in its own right, so silhouettes= with edges= off draws the outline alone).

The SVG *is* the drawing, not a picture of one: with path, this writes it to the file and returns null; without, it returns the SVG text instead of writing anything. throws CadaclysmError on a refused option (naming the field) or a failed write.

Node

class Node

One node of the document — an assembly, a part, a body, a layer, a placement. A handle, not a snapshot: each property asks the scene when read, so nothing goes stale and nothing is built that is never looked at. Names and attributes are cheap; Node.bounds and Node.mesh() build the geometry.

Node.scene

scene: Scene

The scene it belongs to.

Node.index

index: number

Its index in the scene, stable while the scene is open: a key for a map of what has been uploaded.

Node.name

readonly name: string

The name the file gave it, or empty.

Node.id

readonly id: string

What the file calls it: a STEP #N, an IFC GlobalId, a Rhino object id.

Node.kind

readonly kind: string

Its type in the file: an IFC class, an openNURBS class, a STEP shape kind.

Node.label

readonly label: string

Something to put in a tree row: the name, else the kind, else #index.

Node.depth

readonly depth: number

How far down the tree it sits; a root is zero.

Node.generator

readonly generator: string

What its geometry was before it was triangles — brep, mesh, csg — or empty for a node that draws nothing.

Node.visible

readonly visible: boolean

Whether the file says to show it when opened. The node's own switch, not inherited; true where the format has no such switch.

Node.visibleNow

readonly visibleNow: boolean

Node.visible with every ancestor consulted: a layer switched off hides what hangs under it.

Node.locked

readonly locked: boolean

Whether the file says it cannot be selected or edited (Rhino's lock, own or by layer). A locked node is still drawn.

Node.parent

readonly parent: Node | null

The node containing this one, or null for a root.

Node.children()

children(): Node[]

The nodes directly under this one.

Node.instanceOf

readonly instanceOf: Node | null

The node whose geometry this one places, or null. A part placed seventy times is one mesh and seventy transforms; this is how a caller knows to upload it once.

Node.selectAs

readonly selectAs: Node

What a click on this node's geometry should select — usually itself. Formats that hang geometry under the object it belongs to (an IFC representation under its product) point back at the object.

Node.attributes()

attributes(): Attribute[]

Everything the file said about the node, as Attribute values.

Three keys are this library's own, put there by the STEP reader where the file states a body's geometric validation properties: Validation.StatedArea and Validation.StatedVolume, each one number, and Validation.StatedCentroid, a list of three. They are in the document's own length unit — mm and mm² and mm³ on a millimetre part — not SI. They are the sender's claim about the geometry, not a measurement of it: a receiver measures the body itself (Solid.mass() on Solid.fromNode()) and compares, and a difference is evidence about the transfer. blacksmith.setOption()'s step.validation_properties writes them on the way out. Every other key is whatever the file itself carried, and is not documented here.

Node.canMesh

readonly canMesh: boolean

Whether the node has geometry of its own to draw. Builds nothing; most nodes are structure and answer false.

Node.color

readonly color: number[] | null

The colour the file gave it as RGBA in 0–1, or null — most STEP files carry none, and the caller's default is the right answer.

Node.transform

readonly transform: number[][]

Where the node's geometry sits: a 4×4 in double precision, composed through every frame above it. Meshes stay single precision in their own frame under a double transform, so a model at survey coordinates keeps its millimetres.

Node.rawTransform

readonly rawTransform: Float64Array

The same matrix as 16 numbers in the C API's column-major order, ready for a GPU uniform.

Node.bounds

readonly bounds: Bounds

The extent of the node's geometry in that geometry's own frame. Builds the geometry if needed; carry it through Node.transform for world coordinates.

Node.bounds64

readonly bounds64: Bounds64

Node.bounds in double precision: the node's extent in that geometry's own frame, unnarrowed — exact far from the origin, where Node.bounds's float32 corners are not. Builds the geometry if needed.

Node.mesh()

mesh(): Mesh

Its triangles in their own frame, built now if they have not been. A node that instances another hands back the instanced node's arrays — the same memory for every placement. The arrays are views into the scene — copies in Node and Godot; see Lifetimes.

Node.mesh64()

mesh64(): Mesh64 | null

Node.mesh() in double precision: the document's own mesh, lent rather than narrowed — the same indices, Node.mesh()'s positions being exactly these rounded. For a mesh used as geometry (an exporter, a measurement, a solver) far from the origin, where float32 cannot hold the file's coordinates. Where the wrapper hands out views over the scene's memory, forgetting the scene's meshes invalidates them — these lend the document's own mesh, where the float mesh is a copy the library keeps and a forget leaves alone; asked again it is built again. Each one is stamped with the scene's forget count, so reading its arrays after a forget raises a stale view rather than reading freed memory — an array already taken out of it before the forget is not caught.

Copied at call time, exactly as mesh()'s float arrays are — this wrapper hands out no views at all, koffi.decode allocating a typed array of its own for every ask (measured: two asks give two buffers, and a write into one is invisible to the other). So both survive a forgetMeshes() or a close(), and the paragraph above does not apply here.

Node.femMesh()

femMesh(tolerance?: number, maxSize?: number, placement?: ArrayLike<number> | null): FemMesh

Its body meshed for a solver, as a FemMesh: nodes welded by bits — two mesh points are one node only where their coordinates are the same doubles, so no tolerance ever merges two distinct points and a crack stays a crack — triangles wound outward, and every node tagged with the lowest-dimension B-rep entity it lies on. Meshed in the part's own frame, following the hop from an instance to the shape it draws that Node.mesh() follows, so a node instanced six times meshes once.

tolerance is the chordal tolerance in model units, and it alone governs how closely the mesh follows the geometry. max_size is a size ceiling, 0 for none (curvature alone): it splits boundary segments to at most that length and lays interior stations max_size / √2 apart as a target, and it adds nodes without refining the boundary geometry — a caller that wants the rim nearer its curve lowers the tolerance, where max_size only makes the elements smaller. FemMesh.longestEdge is what the mesh actually came to, and the figure to check.

placement is sixteen numbers, in Placement.rawTransform's own column-major order — which Node.boundsPlaced() takes too, in the wrappers that have it — applied in double precision throughout. The kernel's Solid.femMesh() takes twelve instead — an origin and three axes — so a caller moving between the two reformats the placement.

The space is the body's own for a B-rep and the scene's for a mesh, which FemMesh.fromMesh is the flag for: under a convention other than the native one those are two different spaces, and mixing these nodes with Node.transform without reading it gives a rotated part.

A cracked body is not a failure: it comes back with FemMesh.watertight false and its cracks in FemMesh.openEdges() and FemMesh.foldedEdges(), and nothing is welded shut to make it look sound. It throws CadaclysmError for a tolerance or size the mesher refuses, a placement that is not sixteen finite and invertible numbers, a node with neither a B-rep nor a mesh (an assembly, a storey, a layer, a curve), and a body that meshes to no triangles at all.

The unlicensed notice is printed here, once, and on neither of the two .msh calls — where the kernel library is the other way round. Read FemMesh.mshText() before porting either convention onto the other side.

Node.meshLod()

meshLod(level: number): Mesh

Its triangles at a coarser level of detail: 0 is Node.mesh() itself, 1 up to cadaclysm.lodLevels() each about a quarter of the triangles of the one before, and past that empty. Every level shares the level-0 vertices — the same positions, only the indices differ — so upload the vertices once and switch level by drawing a different index range. Simplifying costs about what meshing did, once per node.

Node.lodError()

lodError(level: number): number

How far Node.meshLod() at this level moved the surface, in the scene's units — what to pick a level by against the pixel size on screen. Zero at level 0.

Node.lightmapUvs

readonly lightmapUvs: Float32Array | null

A second set of texture coordinates for Node.mesh(), one (u, v) per vertex in the same order, packed into the unit square with no two triangles overlapping — what a baked lightmap needs, where the material coordinates repeat. Asked for when the scene is opened, with a lightmap resolution in texels: each face is one chart, two texels apart and one texel in from the edges at that size. null when it was not asked for, for a mesh with no B-rep behind it, and for a body whose charts did not fit at that resolution — the scene's diagnostics say which; open it again larger.

Node.surfaces()

surfaces(): Surfaces

Its faces as exact surfaces plus the trim loops that cut them, each in the surface's own (u, v). Nothing is meshed to produce it, and reading it costs Node.mesh() nothing. Empty where the reader has no parametric description (a tessellated body, a mesh format). In the file's frame — see Scene.surfaceMatrix.

Node.edges()

edges(): Polylines

Its feature edges as polylines, for an outline overlay. Builds the geometry if needed.

Node.brep

readonly brep: Brep | null

Its exact B-rep, as a Brep, for the kernel's Solid.fromNode() to operate on — or null where it has none (a mesh, a curve, a CSG body, an OpenSCAD part read without the kernel). Shared with the scene, not copied.

Node.curves()

curves(): Polylines

Its free curves as polylines; a 2D drawing is all of these.

Node.isocurves()

isocurves(): Polylines

Lines ruled across its surfaces, so a curved face reads as curved in a wireframe. A flat face yields its outline, so these can overlap Node.edges().

Node.edgeBeziers()

edgeBeziers(): Beziers

Its feature edges as cubic Bézier curves, a Beziers — exact where the file's curves were, where Node.edges() are their chords. Builds the geometry if needed.

Node.edgeBeziers64()

edgeBeziers64(): Beziers64

Node.edgeBeziers() in double precision, kept beside the float Béziers: a forget leaves it valid, unlike Node.mesh64() — in a wrapper that lends views. Node and Godot copy both, so a forget leaves both valid.

Node.curveBeziers()

curveBeziers(): Beziers

Its free curves as cubic Béziers; see Node.edgeBeziers().

Node.curveBeziers64()

curveBeziers64(): Beziers64

Node.curveBeziers() in double precision; see Node.edgeBeziers64().

Node.isocurveBeziers()

isocurveBeziers(): Beziers

Its isocurves as cubic Béziers; see Node.edgeBeziers().

Node.isocurveBeziers64()

isocurveBeziers64(): Beziers64

Node.isocurveBeziers() in double precision; see Node.edgeBeziers64().

Node.silhouetteBeziers()

silhouetteBeziers(options?: SvgOptions): Beziers64

Where this node's surfaces turn away from the eye, which no edge of it lies on, as rational cubic Béziers in double precision, from the camera the options describe: Node.svg()'s own words, so the words that draw a picture ask about the same eye. tolerance is read as a fraction of the page's width, and nothing else in the options changes the curves; the line-set flags are not read.

A copy, unlike Node.edgeBeziers64(). The library keeps one silhouette slot per scene, and the next silhouette call on that scene — for any node — overwrites it, so a view into it would change under a caller who asked twice. The curves are copied out of the slot before the call returns: asking for several nodes' silhouettes in a loop keeps every answer, and a Scene.close() leaves them valid. Calls sharing one scene across threads must be serialised by the caller, as the library documents.

A node with no silhouette — no exact B-rep, or every face planar, a cuboid's — is an empty answer (count 0), not an error. The library clears its error slot as the call starts, so an empty answer leaves no message and a refusal leaves one; that is how the two are told apart, and why a failure from an earlier call cannot be mistaken for this call's empty answer. throws CadaclysmError on a refusal: a refused option, a body with no measurable geometry, or a node that holds no shape of its own (a container above the parts).

Takes the options object (width with tolerance). Returns a Beziers64 whose arrays are the call's own; the empty answer has count 0 and empty arrays.

Node.collision()

collision(hullBudget?: number): Collision | null

The collision body for what this node draws, as a Collision: a box, sphere, capsule or cylinder where one fits, else a convex hull. hull_budget is the most triangles a hull may have; 0 (the default) asks for the Unity limit of 255 and is not clamped to it. null for a node that draws nothing. Builds the mesh if it is not built; cached per node and budget.

Node.collisionHull()

collisionHull(hullBudget?: number): CollisionHull

The convex hull Node.collision() counted, as triangles — a CollisionHull, a view into the scene (a copy in Node and Godot). Empty for a node that draws nothing. Asking the same node for a different hull_budget refits it and frees the hull the earlier call returned: hold one budget.

The surface path

Node.isMeshed

readonly isMeshed: boolean

Whether its mesh has been built and is held — by Scene.realizeAll(), by an ask for it, or by anything else that needed it. A renderer drawing the part from its surfaces checks it never paid for the triangles.

Node.triangleEstimate

readonly triangleEstimate: number

About how many triangles Node.mesh() would give, without building it — for sizing a budget before meshing. Exact for a stored mesh, within a few tens of percent for a B-rep; -1 where the reader cannot say without doing the work, and for a node that draws nothing. Treat -1 as unknown, never as zero.

Node.boundsPlaced()

boundsPlaced(placement?: ArrayLike<number> | null): Bounds

The box of what this node draws under a placement (16 numbers, column-major, as Placement.rawTransform; null for the identity), for a part drawn from its surfaces: every sample is carried through the convention and the placement before it is boxed, so it is tighter than placing the corners of Node.bounds. All zeros for a part with no surfaces.

Node.boundsPlaced64()

boundsPlaced64(placement?: ArrayLike<number> | null): Bounds64

Node.boundsPlaced() in double precision, from the unnarrowed surface samples; see Node.bounds64.

Node.surfaceEdges()

surfaceEdges(): Polylines

Its face boundaries taken from its trimmed surfaces — the outline that costs no tessellation, where Node.edges() meshes the part. In the surfaces' own frame (Scene.surfaceMatrix); empty without surfaces. A shared edge appears once from each face.

Node.surfaceEdgeBeziers()

surfaceEdgeBeziers(): Beziers

Its edges as the exact curves, a Beziers, where the part has them without meshing — a Rhino extrusion's rims are its profile — and empty everywhere else. A caller drawing from surfaces tries it before Node.surfaceEdges(), whose trims are thinned to the mesh tolerance and so cut chords across a curve the surface rounds. The same segments as Node.edgeBeziers(), in the scene's space: not the surfaces' frame, so no Scene.surfaceMatrix.

Node.edgeColours()

edgeColours(): (number[] | null)[]

One RGBA per polyline of Node.edges(), and none for an edge the file does not style; empty when nothing is styled. STEP files carry them as CURVE_STYLE styling.

Node.surfaceEdgeColours()

surfaceEdgeColours(): (number[] | null)[]

Node.edgeColours() for Node.surfaceEdges().

Node.surfaceIsocurves()

surfaceIsocurves(): Polylines

Its isocurves taken from its trimmed surfaces and clipped to the trims, without meshing: lines at a surface's bend lines and an even spread where it has none; a flat face gets none. In the surfaces' frame; empty without surfaces.

Node.surfacePick()

surfacePick(from: ArrayLike<number>, to: ArrayLike<number>): number[] | null

Where a segment first meets this part's surfaces, or null. Exact — it answers from the surface and tests the trims at the hit's own (u, v) — and in the surfaces' own frame: carry a ray from the scene's space through the inverse of Scene.surfaceMatrix first.

Node.surfaceProxyMesh()

surfaceProxyMesh(cells: number): Mesh

A coarse mesh over its surfaces for the things that need triangles and not a picture — ray tracing, distance fields: each face gridded cells by cells over its trim window, two triangles a cell whose centre lies inside the trims, never welded. Built once per part at the first cells asked for. In the scene's space, like Node.mesh(). Empty without surfaces or for zero cells.

Node.saveMesh()

saveMesh(path: string, format?: string): void

Write this node's own mesh — where it is defined, without its placement — in one of cadaclysm.meshFormats(). A node that draws nothing, or an unknown format, throws CadaclysmError; ask Node.canMesh first to grey out a menu entry. To write the whole model, see Scene.save().

Node.walk()

walk(): IterableIterator<Node>

This node and every node under it, parents before children.

Node.show()

show(options?: ShowOptions): void

Draw what this node and everything under it places with the viewer in use — shown by handle on its scene, hiding the siblings along the path from the scene's root to this node (each ancestor's own geometry stays visible) and framing this node. Keywords as Scene.show(). With the GPU library (import cadaclysm.view.wgpu) the drawing replaces what one shared window shows and stays live — at the REPL, in IPython and in Jupyter by themselves, in a script until it exits; cadaclysm.view.View draws several items or several windows.

Takes an options object: view, azimuth, elevation, zoom, up, edges, width, height, title. A tolerance is refused: a document is drawn at the tolerance it was read with. On the wgpu library (require('cadaclysm/view').useWgpu()) it replaces what one shared window shows and returns; a 16 ms timer keeps the window live and holds the process until it is closed. On the terminal it prints a still.

Node.view()

view(options?: ShowOptions): Camera

Orbit this node and everything under it; returns the camera where it was left — a dict of eye, target, up, orthographic, azimuth and elevation — and pick, what was last clicked (item, node, face) or None. A fresh window, run until closed, with the GPU library.

Takes the options show does; returns a Camera object with these fields.

Node.svg()

svg(path: string, options?: SvgOptions): void

This node's own wireframe as SVG, in its own frame — Scene.svg()'s keywords, read from just this node rather than every placement. With path, writes the file and returns null; without, returns the SVG text. throws CadaclysmError on a refused option (naming the field) or a failed write.

Brep

class Brep

A body's exact B-rep — the trimmed surfaces its mesh is cut from — shared with the scene rather than copied, and held by this object until it is released. It is what Node.brep hands the kernel's Solid.fromNode(), which operates on it without a copy, and it can say whether it is a Manifold. It outlives the scene it came from for as long as anything holds it. In the node's own frame and the file's own units and axes; the kernel library must come from the same release as the reader.

Brep.pointer

readonly pointer: unknown

The brep's C pointer, which the kernel's wrapper hands across. throws CadaclysmError once released.

Brep.layoutId()

static layoutId(): string

How this library lays a brep out in memory: its compiler, target and source. The kernel shares a brep only with a reader whose id equals its own.

Brep.manifold

readonly manifold: Manifold

Whether its faces make a manifold — every edge bordered by one face or two, the faces round every vertex one fan — and whether it is closed, as a Manifold. Read off the topology the file wrote, not a mesh. throws CadaclysmError once released.

Brep.sew()

sew(options?: { tolerance?: number; vertex?: number }): { brep: Brep; report: SewReport }

This brep with its free edges sewn, and what was sewn, as a new Brep and a SewReport; this one is left as it was. Two free edges become one shared edge where both their ends coincide within vertex — by default the rounding Brep.manifold merges vertices at — and their curves lie within tolerance of each other, by default vertex too, so only edges that are one curve written twice are joined. A larger tolerance also joins two curves between the same two vertices that part by up to it; vertex is what decides which edges are candidates at all, and raising it is what could close a slot. Nothing moves. throws CadaclysmError once released.

Brep.health()

health(options?: HealthOptions): HealthReport

What is wrong with this brep, as a HealthReport: the free edges and the wires they chain into, each with its nearest partner and the gap to it; the features below tolerance; the loose edges; and what sewing would join and leave. Nothing moves. tolerance is an absolute length, as Rhino's model tolerance is, by default 1e-4 times the diagonal; a NaN, infinite, zero or negative one takes the default, and the report shows what was used. A partner is the nearest free edge other than a neighbour on the wire, so a rim reads as a gap the size of the part; shared_ends 2 is what Brep.sew() joins. mesh=True also meshes the brep and reports where the mesh cracks; an open body's crack census is empty by design (not asked), and cracks are only counted on a closed body. Loose edges are compared against the larger of the tolerance recorded and the one given. throws CadaclysmError once released.

Brep.heal()

heal(options?: HealOptions): { brep: Brep; report: HealReport }

This brep with its small features removed, beside a HealReport of what was done and left, as a new Brep; this one is left as it was. It heals what Brep.health() lists as small at the same tolerance, so health first tells what it will do.

Each kind's fix: a short edge's two ends are merged into one vertex and the edge dropped; a collapsed edge (a trim collapsed to a point where its surface is not singular) is dropped; a sliver face's short ends are merged, then the face is dropped and its two long sides sewn into one edge; a tiny face's corners are merged into one vertex and the face is dropped with its edges; a small hole (an inner loop whose edges are all free: a pinhole in an open sheet) is dropped from its face. A hole with walls (a bore) is not a small hole, and a tiny body is listed but never removed.

Everything is a vertex merge no wider than tolerance: a cluster of vertices that spans more, measured by every trim end at them, is refused (chain), so a run of short edges cannot swallow a long one, nor a loosely written corner move an end further. No edit moves a trim further than tolerance: a trim end on a surface pole keeps its uv, an end sent further is left, and a curve edit that would move further is discarded and only the vertex moves. A stack of slivers whose outer faces part by more than tolerance is not sewn across (neighbours_part). Each edge that moved records how far as its Brep.edgeTolerance(), as sewing records a gap; an end that could not move records how far it was left from the merged vertex.

A guard compares the result's health with this brep's. If it is worse — less closed, more free or non-manifold edges, or no faces left — healing retries with the face pass off; if that is still worse, this brep comes back as it was. guarded is set whenever the guard refused a fix. So a lone sliver sheet comes back as a face of two trims: its short ends merged, the sliver refused.

edges, faces and holes switch each kind of fix; a kind switched off is refused as toggled. tolerance null, NaN, infinite, zero or negative takes the default, 1e-4 times the diagonal; the report shows what was used. In the browser the reader module's Scene.healed returns the report only: heal the body through the blacksmith module's Solid.heal. throws CadaclysmError once released.

Brep.edgeTolerance()

edgeTolerance(edge: number): number | null

How far edge edge (a brep edge id, as a HealFix or FreeEdge names one) may lie off its curve: 0 for an exact edge, the distance healing or sewing moved it where that is recorded, null when no trim names the id (an edge healing removed). throws CadaclysmError once released.

Brep.recognize()

recognize(options?: RecognizeOptions): { brep: Brep; report: RecognizeReport }

This brep with its free-form surfaces and edge curves given their analytic kind, beside a RecognizeReport of what was taken and left, as a new Brep; this one is left as it was. A NURBS, revolved, extruded or swept surface that is a plane, cylinder, cone, sphere or torus within tolerance of every sample of its faces and every point of their edges becomes exactly that; an edge curve that is a line, circle or ellipse within it likewise, over the same stretch run the same way. So a file that stored its analytic faces as NURBS — a .3dm above all, and many STEP and SAT exports — comes back as it was made, and verbs that read a face's kind (a hole's axis, a fillet's radius) work on it.

Faces and edges keep their numbers, so a face or edge picked before is the same one after. The faces of one surface are taken together or not at all. A face given only by trims in its old surface's parameters (.3dm, IGES) is lifted to space edges first. Volume and area move by no more than the tolerance allows.

tolerance null, NaN, infinite, zero or negative takes the default, 1e-6 of the body's extent; the report shows what was used. Not the file's declared tolerance: at a STEP file's usual 0.01, a fillet's blend reads as a torus and the body's area moves by parts in a thousand. In the browser the reader module's Scene.recognized returns the report only: recognise the body through the blacksmith module's Solid.recognize. throws CadaclysmError once released.

Brep.release()

release(): void

Give the reference back now. Leaving a with block, or the garbage collector, does it otherwise.

Placement

class Placement

One drawing of one node's geometry at one place: what Scene.placements() lists. Two drawings of the same shape name the same geometry node, and so the same arrays — upload once, draw twice.

Placement.scene

scene: Scene

The scene it belongs to.

Placement.index

index: number

Its index in Scene.placements().

Placement.geometry

readonly geometry: Node

The node whose mesh, edges and curves this draws.

Placement.select

readonly select: Node

What a click on this drawing selects: the placement's own node rather than the shared shape, which would light up every copy.

Placement.transform

readonly transform: number[][]

Where to draw it: a 4×4, already composed through every frame from the root.

Placement.rawTransform

readonly rawTransform: Float64Array

The same matrix as 16 numbers, column-major.

Joint

class Joint

A connection between two links. Its two ends keep the file's order, not a parent and a child, since a mechanism may be a network with loops.

Joint.scene

scene: Scene

The scene this joint belongs to.

Joint.index

index: number

Its position in the scene's joints.

Joint.name

readonly name: string

Its name, as the file gives it.

Joint.start

readonly start: Link

The link it starts at.

Joint.end

readonly end: Link

The link it ends at.

Joint.pair

readonly pair: Pair | null

How this joint moves: the kinematic pair naming it, a Pair, or null when the file gives it none.

Pair

class Pair

A kinematic pair: the kind of relative motion a joint allows between its two links — what Joint.pair returns.

Pair.kind

kind: PairKind

One of thirteen kinds: revolute, prismatic, cylindrical, spherical, spherical_with_pin, planar, universal, homokinetic, screw, fully_constrained, unconstrained, low_order, other.

Pair.typeName

typeName: string | null

For other: the pair's entity type name (GEAR_PAIR). null otherwise.

Pair.pitch

pitch: number | null

For screw: its pitch, a length per revolution in the scene's units. null otherwise.

Pair.kindName

kindName: string

The kind by name, finer than kind: the same thirteen names, and gear and rack_and_pinion for the two coupled pairs kind reads as other.

Pair.parameters

parameters: number[]

The pair's own numbers, in the order Assembly.pairWith() takes them: screw its pitch, rack_and_pinion its pinion radius, gear its first radius, second radius, ratio (the second link's rotation over the first's, signed), bevel and helical angle — always five. Empty for every other kind.

Pair.frameStart

frameStart: number[][]

The pair's contact frame fixed in its joint's start link, in world coordinates at the file's rest pose: a 4x4, already composed like Node.transform.

Pair.frameEnd

frameEnd: number[][]

The pair's contact frame fixed in its joint's end link.

Pair.rawFrameStart

rawFrameStart: Float64Array

frame_start as 16 numbers, column-major — like Node.rawTransform.

Pair.rawFrameEnd

rawFrameEnd: Float64Array

frame_end as 16 numbers, column-major.

Pair.freedoms()

freedoms(): Freedom[]

Its degrees of freedom, in the reader's per-kind order, each a Freedom. A State's values compose in this order.

Freedom

class Freedom

One degree of freedom of a Pair: which motion, about or along which contact-frame axis, and its optional range. From Pair.freedoms().

Freedom.motion

motion: Motion

rotation or translation.

Freedom.axis

axis: FreedomAxis

x, y or z: the contact frames' axis the motion is about or along.

Freedom.lower

lower: number | null

The lower limit — radians for a rotation, a length for a translation — or null for unbounded.

Freedom.upper

upper: number | null

The upper limit, or null for unbounded.

State

class State

A named pose of the file's mechanism: a MECHANISM_STATE_REPRESENTATION. From Scene.states().

State.index

index: number

Its position in the scene's states.

State.name

name: string

Its name, as the file gives it.

State.values

values: StateValue[]

One row per joint this state sets, in file order: the joint, then one value per freedom of its pair, in the pair's freedom order.

Sequence

class Sequence

A motion the file records: an INTERPOLATED_CONFIGURATION_SEQUENCE, its states at increasing parameter values. From Scene.sequences().

Sequence.index

index: number

Its position in the scene's sequences.

Sequence.name

name: string

Its name: its representation's, name #2 and on for further sequences in one representation.

Sequence.closed

closed: boolean

Whether the motion returns to its first segment (its last segment is not discontinuous).

Sequence.secondsPerUnit

secondsPerUnit: number | null

Seconds per unit of the parameter where the file states a time unit, or null where it states none (the parameter is then read as seconds).

The seconds rule, to play a sequence on a clock: with a duration, stretch start to end (plus the closing span of a closed sequence, (end - start) divided by one less than the number of segments) over it; with none, seconds are (t - start) times Sequence.secondsPerUnit, or times 1 where it is null.

Sequence.segments

segments: Segment[]

The segments, in file order (at least two), each a Segment.

Sequence.start

start: number

The first segment's parameter.

Sequence.end

end: number

The last segment's parameter (the closing span of a closed sequence not included).

Sequence.pose()

pose(t: number, ground?: Link | null): Pose

The mechanism posed by this sequence at parameter t, in the file's own parameter: a segment is a keyframe of its state, a discontinuous segment holds until the next and every other kind moves linearly, an open sequence holds its ends and a closed one wraps (its closing span, last back to first, is the mean of its spans, and each joint loops on its own keys, so one that only some segments name still comes back round smoothly). ground is held fixed as Scene.pose() does. throws CadaclysmError for a t that is not finite.

Segment

class Segment

One step of a Sequence: the state it reaches, its parameter, and how the motion leaves it for the next. From Sequence.segments.

Segment.state

state: State

The State this segment reaches.

Segment.t

t: number

Its parameter.

Segment.interpolation

interpolation: Interpolation

How the motion leaves it: "undefined", "discontinuous", "synchronous" or "linear".

WorkSchedule

class WorkSchedule

A building's programme: an IfcWorkSchedule and the tasks it controls. From Scene.schedules(). Dates are seconds since 1970-01-01T00:00 (no time zone); durations and lags are seconds.

WorkSchedule.index

index: number

Its position in the scene's schedules.

WorkSchedule.name

readonly name: string

Its name, else its identification, else schedule #k (k from 1, in file order).

WorkSchedule.identification

readonly identification: string

Its identification, empty where the file gives none.

WorkSchedule.kind

readonly kind: ScheduleKind

"planned", "actual", "baseline", "notdefined" or "other".

WorkSchedule.kindName

readonly kindName: string

The text of a user-defined kind (kind is "other"); empty otherwise.

WorkSchedule.start

readonly start: number | null

The schedule's start date, or null where the file gives none.

WorkSchedule.finish

readonly finish: number | null

The schedule's finish date, or null where the file gives none.

WorkSchedule.tasks

readonly tasks: Task[]

Its tasks, in file order, each a Task.

WorkSchedule.at()

at(date: number, dates?: 'scheduled' | 'actual'): ElementState[]

What each element this schedule names is doing on date, as ElementState rows in node order; an element no task names is not listed. dates says which of a task's dates to play: "scheduled" (the default) or "actual", where each actual date overrides its scheduled one. A task builds its nodes over its window, or removes them (demolition, dismantling, removal, disposal); summary tasks span their children. A task that works on a WorkCalendar builds over working time only, pausing at nights and weekends. throws CadaclysmError for a date that is not finite, and a dates other than those two words is refused. Each call expands the calendars again: call it when the date changes, not per frame.

Task

class Task

One task of a WorkSchedule. From WorkSchedule.tasks.

Task.schedule

schedule: WorkSchedule

The WorkSchedule it belongs to.

Task.scheduleIndex

readonly scheduleIndex: number

The index of the work schedule this task belongs to (scene.schedules[i]).

Task.index

index: number

Its position in its schedule's tasks.

Task.name

readonly name: string

Its name.

Task.identification

readonly identification: string

Its identification, empty where the file gives none.

Task.kind

readonly kind: TaskKind

"attendance", "construction", "demolition", "dismantle", "disposal", "installation", "logistic", "maintenance", "move", "operation", "removal", "renovation", "notdefined" or "other".

Task.kindName

readonly kindName: string

The text of a user-defined kind (kind is "other"); empty otherwise.

Task.status

readonly status: string

Its status as the file writes it, empty where none.

Task.milestone

readonly milestone: boolean

Whether it is a milestone: an instant, not a span.

Task.parent

readonly parent: Task | null

The summary task nesting it, or null for a top-level task.

Task.time

readonly time: TaskTime

Its dates, a TaskTime.

Task.nodes

readonly nodes: Node[]

The nodes it builds or removes, each a Node.

Task.calendarIndex

readonly calendarIndex: number | null

The index of the work calendar this task works on (scene.calendars[i]), or null where it has none.

Task.calendar

readonly calendar: WorkCalendar | null

The WorkCalendar this task works on, or null where it has none.

TaskTime

class TaskTime

Every date pair a task gives, in seconds since 1970-01-01T00:00; each is null where the file gives none. From Task.time.

TaskTime.scheduleStart

scheduleStart: number | null

The scheduled start.

TaskTime.scheduleFinish

scheduleFinish: number | null

The scheduled finish.

TaskTime.earlyStart

earlyStart: number | null

The early start.

TaskTime.earlyFinish

earlyFinish: number | null

The early finish.

TaskTime.lateStart

lateStart: number | null

The late start.

TaskTime.lateFinish

lateFinish: number | null

The late finish.

TaskTime.actualStart

actualStart: number | null

The actual start.

TaskTime.actualFinish

actualFinish: number | null

The actual finish.

TaskTime.duration

duration: number | null

The scheduled duration, in elapsed seconds.

TaskTime.durationKind

durationKind: DurationKind | null

How the file means the duration: "ELAPSEDTIME", "WORKTIME" or "NOTDEFINED"; null where the file gives none. A task with a Task.calendar counts working time unless this is "ELAPSEDTIME"; a task with no calendar always counts elapsed time.

TaskTime.workDuration

workDuration: { days: number; seconds: number } | null

The duration as working time: that many working days, then that many seconds of working time, as a (days, seconds) pair. null for an IFC2X3 task or one with no duration. A year is read as 260 working days, a month as 20, a week as 5 and a day as 1; hours, minutes and seconds are working seconds. So P2DT4H is 2 days and 14400 seconds.

WorkCalendar

class WorkCalendar

When work happens: an IfcWorkCalendar. From Scene.calendars() or Task.calendar. A calendar's working time is the union of its working times' occurrences minus the union of its exceptions' (exceptions only ever remove time). A calendar with no working times works every day, all day, less its exceptions. Dates are seconds since 1970-01-01T00:00 (no time zone). The queries refuse, with these messages, a from or to that is not finite (from and to must be finite), a from after to (from must not be after to), a WorkCalendar.workingPeriods() or WorkCalendar.workingSeconds() range longer than 100 years (from and to must lie within 100 years of each other) and a calendar with no working time within 100 years of the date searched (no working time within 100 years).

WorkCalendar.index

index: number

Its position in the scene's calendars.

WorkCalendar.name

readonly name: string

Its name, else its identification, else calendar #k (k from 1, in file order).

WorkCalendar.identification

readonly identification: string

Its identification, empty where the file gives none.

WorkCalendar.kind

readonly kind: CalendarKind

"FIRSTSHIFT", "SECONDSHIFT", "THIRDSHIFT", "NOTDEFINED" or "USERDEFINED".

WorkCalendar.kindName

readonly kindName: string

The text of a user-defined kind (kind is "USERDEFINED"); empty otherwise.

WorkCalendar.working

readonly working: WorkTime[]

Its working times, in file order, each a WorkTime.

WorkCalendar.exceptions

readonly exceptions: WorkTime[]

Its exception (non-working) times, in file order, each a WorkTime.

WorkCalendar.workingPeriods()

workingPeriods(from: number, to: number): [number, number][]

The working periods overlapping from..to, clipped to it, sorted and merged so no two touch or overlap: (start, end) pairs of dates, in seconds. throws CadaclysmError for a from or to that is not finite, a from after to, or a range longer than 100 years. Playback uses this to pause a task across nights and weekends; the web build's workingPeriods returns the same pairs as one flat Float64Array.

WorkCalendar.workingSeconds()

workingSeconds(from: number, to: number): number

The working seconds in from..to. throws CadaclysmError as WorkCalendar.workingPeriods() does.

WorkCalendar.addWork()

addWork(from: number, days: number, seconds?: number): number

The date days working days, then seconds of working time, after from (before it, when negative). A forward result that lands at the start of a working day is reported as the end of the previous one, so a ten-day task starting Monday 08:00 on a weekday 08:00-17:00 calendar finishes on the second Friday at 17:00. throws CadaclysmError for a non-finite argument, and for a calendar with no working day within 100 years.

WorkTime

class WorkTime

A repeating set of working periods, or among a calendar's exceptions of non-working ones, valid between two dates: an IfcWorkTime. From WorkCalendar.working or WorkCalendar.exceptions.

WorkTime.name

name: string

Its name, empty where the file gives none.

WorkTime.start

start: number | null

The first day it applies, as that day's midnight (seconds since 1970-01-01T00:00), or null for an open start.

WorkTime.finish

finish: number | null

The last day it applies, as that day's midnight (the day itself is included), or null for an open end.

WorkTime.pattern

pattern: Recurrence | null

Its Recurrence, or null for every day of the range, all day.

Recurrence

class Recurrence

Which days a WorkTime occurs on and when within each: an IfcRecurrencePattern. From WorkTime.pattern.

Recurrence.kind

kind: RecurrenceKind

The IFC word: "DAILY", "WEEKLY", "MONTHLY_BY_DAY_OF_MONTH", "MONTHLY_BY_POSITION", "BY_DAY_COUNT", "BY_WEEKDAY_COUNT", "YEARLY_BY_DAY_OF_MONTH" or "YEARLY_BY_POSITION".

Recurrence.days

days: number[]

The days of the month, 1 to 31, sorted.

Recurrence.weekdays

weekdays: number[]

The weekdays, 1 (Monday) to 7 (Sunday), sorted.

Recurrence.months

months: number[]

The months, 1 to 12, sorted.

Recurrence.position

position: number | null

The position among the month's listed weekdays: 1 to 5 from the month's start, -1 from its end; null where the file gives none.

Recurrence.interval

interval: number | null

Every how many days, weeks, months or years; null where the file gives none (every one).

Recurrence.occurrences

occurrences: number | null

How many occurring days, counted from the work time's start, before it stops; null for no limit.

Recurrence.periods

periods: [number, number][]

The working periods within an occurring day, as (start, end) pairs of seconds after midnight, in file order; empty for the whole day.

ElementState

class ElementState

What one element is doing on a date: WorkSchedule.at()'s rows.

ElementState.node

node: Node

The Node.

ElementState.phase

phase: 'unbuilt' | 'building' | 'built' | 'demolishing' | 'demolished'

"unbuilt", "building", "built", "demolishing" or "demolished".

ElementState.progress

progress: number

How far through the window that governs the phase, 0 to 1: 0 unbuilt, 1 built or demolished.

ElementState.variance

variance: number | null

Seconds late (positive) or early (negative) against the schedule, or null where there is none to give.

Pose

class Pose

A posed mechanism: Scene.pose(), Scene.poseState() or Sequence.pose()'s answer. The document itself is unchanged. Copied eagerly out of the C handle when it is made, so it borrows nothing and outlives a Scene.close().

Pose.ground

readonly ground: Link

The link held fixed.

Pose.unsolved

readonly unsolved: Joint[]

Joints that close a loop and were not honoured, in file order, each a Joint.

Pose.outOfRange

readonly outOfRange: [Joint, number, number][]

One entry per given value that fell outside its freedom's range: the Joint, the freedom's index in its pair, and the value used.

Pose.diagnostics

readonly diagnostics: string[]

What the couplings — a gear, a rack and pinion, a screw closing a loop — could not solve, or found disagreeing, in file order, as text in the kernel's words: coupling 'mesh': both 'drive' and 'driven' are given and disagree by 0.1, or coupling 'mesh' cannot be solved: .... Empty when the pose is what was asked: a coupling neither of whose sides is given rests, and one side given drives the other.

Pose.transform()

transform(node: Node): number[][]

A node's posed transform, in the same form Node.transform returns.

Pose.rawTransform()

rawTransform(node: Node): Float64Array

The same matrix in the ABI's own column-major order, as 16 numbers.

Pose.show()

show(options?: ShowOptions): void

Draw this pose's scene with the viewer in use, as Scene.show() does, but with each placement moved by its select node's pose — each node a joint turned draws at its posed transform rather than its rest one. Same keywords as Scene.show().

Takes the options Scene.show takes; draws the scene by handle with each node's posed transform (nodeTransforms). On the wgpu library (require('cadaclysm/view').useWgpu()) it replaces what one shared window shows and returns; a 16 ms timer keeps the window live and holds the process until it is closed. On the terminal it prints a still.

Pose.view()

view(options?: ShowOptions): Camera

Pose.show()'s orbiting twin; returns what Scene.view() returns — the camera where it was left, and the last pick.

Takes the options Scene.view does; returns a Camera object with these fields.

Mesh

class Mesh

A node's triangles, in the node's own frame: what Node.mesh() returns. In every wrapper that can lend a view the arrays are read-only views into the scene's memory, not copies — a large assembly is tens of millions of triangles, and most of them go straight to a GPU — and Mesh.copy makes arrays of your own. Node and Godot copy instead, having no borrowed-view machinery at all: their arrays are theirs already, outlive Scene.close(), and need no copy. The same split as a FemMesh's arrays, and for the same reason.

Mesh.positions

positions: Float32Array

Three floats a vertex.

Mesh.normals

normals: Float32Array | null

Three floats a vertex, or null for a mesh that carries none.

Mesh.uvs

uvs: Float32Array | null

Two floats a vertex, or null: only readers asked for world-scale UVs fill them. One unit of u or v is one world unit, so faces overlap in UV space — a tiling material, not a lightmap.

Mesh.colors

colors: Float32Array | null

Four floats (RGBA) a vertex, or null — the common case. Only a body painted in several colours, opened with colours on, carries them.

Mesh.indices

indices: Uint32Array

Three vertex indices a triangle, unsigned 32-bit.

Mesh.vertexCount

vertexCount: number

How many vertices.

Mesh.indexCount

indexCount: number

How many indices: three a triangle.

Mesh.triangleCount

readonly triangleCount: number

How many triangles.

Mesh.copy

The same arrays in memory of your own, safe to keep after Scene.close(). Deliberately visible: on a large model this is where the gigabytes go.

There is nothing to copy: mesh() already hands back fresh typed arrays rather than views, so what you hold outlives Scene.close() as it is.

Polylines

class Polylines

Edges or curves already flattened to points, in the node's own frame: what Node.edges(), Node.curves() and Node.isocurves() return. Views into the scene, like Mesh — copies in Node and Godot, as there.

Polylines.positions

positions: Float32Array

Three floats a point, the runs end to end.

Polylines.counts

counts: Uint32Array

How many points each run has, in order.

Polylines.polylineCount

polylineCount: number

How many runs.

Polylines.vertexCount

vertexCount: number

How many points in all.

Polylines.segmentIndices()

segmentIndices(): Uint32Array

Index pairs into the positions, two per line segment — what GL_LINES and every pair-taking API want. Indices rather than points, so a caller can transform the points once and expand afterwards.

Polylines.segments()

segments(): Float32Array

The segment endpoints themselves, two points per segment.

Beziers

class Beziers

Edges, curves or isocurves as cubic Bézier curves, exact where the file's curves were: what Node.edgeBeziers(), Node.curveBeziers() and Node.isocurveBeziers() return. Views into the scene, like Polylines — copies in Node and Godot, as there.

Beziers.points

points: Float32Array

Four control points a curve, three floats each.

Beziers.weights

weights: Float32Array

A weight per control point: all ones for a polynomial curve, and the weights that make a circular arc exact for a rational one.

Beziers.count

count: number

How many curves.

Beziers.copy

The same arrays in memory of your own, safe to keep after Scene.close().

The arrays are typed-array copies already.

Mesh64

class Mesh64

Mesh in double precision, unnarrowed: what Node.mesh64() returns. Positions, normals and uvs keep the file's own precision; colours stay float32, as Mesh.colors do. Views into the scene's memory, like Mesh — copies in Node and Godot, as there.

Copied at call time, as this wrapper's Mesh is too: Float64Arrays of their own that survive a forgetMeshes() or a close(). It is the other wrappers that hand out a view — there is no borrowed view anywhere in the Node binding.

Mesh64.positions

positions: Float64Array

Three doubles a vertex.

Mesh64.normals

normals: Float64Array | null

Three doubles a vertex, or null for a mesh that carries none.

Mesh64.uvs

uvs: Float64Array | null

Two doubles a vertex, or null; see Mesh.uvs.

Mesh64.colors

colors: Float32Array | null

Four floats (RGBA) a vertex, or null — always float32, as Mesh.colors are.

Mesh64.indices

indices: Uint32Array

Three vertex indices a triangle, unsigned 32-bit — the same triangles as Mesh.indices.

Mesh64.vertexCount

vertexCount: number

How many vertices.

Mesh64.indexCount

indexCount: number

How many indices: three a triangle.

Mesh64.triangleCount

readonly triangleCount: number

How many triangles.

Mesh64.copy

The same arrays in memory of your own, safe to keep after a forget or Scene.close().

The arrays are Float64Array copies already, made when this is called; keep the object itself.

Beziers64

class Beziers64

Beziers in double precision, unnarrowed: what Node.edgeBeziers64(), Node.curveBeziers64() and Node.isocurveBeziers64() return. Views into the scene, like Beziers — copies in Node and Godot, as there.

Beziers64.points

points: Float64Array

Four control points a curve, three doubles each.

Beziers64.weights

weights: Float64Array

A weight per control point, as doubles.

Beziers64.count

count: number

How many curves.

Beziers64.copy

The same arrays in memory of your own, safe to keep after Scene.close().

The arrays are typed-array copies already.

Bounds64

class Bounds64

Bounds in double precision, unnarrowed: what Node.bounds64, Node.boundsPlaced64() and Scene.bounds64 return.

Bounds64.min

min: Float64Array

The low corner.

Bounds64.max

max: Float64Array

The high corner.

Bounds64.isEmpty

readonly isEmpty: boolean

Whether this is the all-zero box that stands for nothing.

Bounds64.size

readonly size: number[]

The extent along each axis.

Bounds64.centre

readonly centre: number[]

The midpoint.

Collision and CollisionHull

class Collision

What Node.collision() found: shape (0 none, 1 box, 2 sphere, 3 capsule, 4 cylinder, 5 hull, named by shape_name), confidence, the axis a capsule or cylinder runs along, frame (16 numbers, column-major) and half_extent — always the true oriented box — radius, height, the fit's error, and the hull's vertex and index counts. Plain data, copied out of the scene. Node.collisionHull() is the hull itself: positions (three floats a vertex) and indices (three a triangle), views into the scene — copies in Node and Godot.

Collision.shapeName

readonly shapeName: string

none, box, sphere, capsule, cylinder or hull.

Collision.error

error: number

How far the fitted shape strays from the mesh, in the scene's units; zero for an exact fit.

Collision.frame

frame: Float64Array

The oriented box's frame, 16 numbers column-major.

Collision.halfExtent

halfExtent: Float64Array

Half the oriented box's size along its own three axes.

Collision

class Collision
shape: number
confidence: number
axis: number
radius: number
height: number
hullVertexCount: number
hullIndexCount: number

shape, confidence, axis, radius, height, hull_vertex_count and hull_index_count, alongside frame, half_extent, error and shape_name.

CollisionHull

class CollisionHull
positions: Float32Array
indices: Uint32Array
vertexCount: number
indexCount: number

The hull's positions, indices, vertex_count and index_count.

Meshlets

class Meshlets

A mesh split into meshlets, optionally with coarser levels above them, for a mesh-shader or meshlet-based renderer. Built from any mesh — a Node.mesh() or arrays of your own — and owned by you: free it, or let the language's scope do it (see Lifetimes).

Meshlets.build()

static build(positions: ArrayLike<number>, normals: ArrayLike<number> | null, indices: ArrayLike<number>, limits: { maxTriangles: number; maxVertices: number; levels?: number }): Meshlets

Split positions (three floats a vertex), normals (the same, or none) and indices (three a triangle) into meshlets of at most max_triangles and max_vertices each. The limits are the consumer's own, with no default: Nanite takes 128 and 256, a mesh-shader pipeline 124 and 64, and the vertex cap is the one that bites. levels above 0 groups and simplifies each level into the next until one meshlet is left; Meshlets.level() and a meshlet's children say which is which. A budget of zero, or arrays whose lengths do not agree, throws CadaclysmError before the library is called.

Meshlets.count

readonly count: number

How many meshlets, every level counted.

Meshlets.triangleCount()

triangleCount(i: number): number

How many triangles meshlet i has.

Meshlets.vertexCount()

vertexCount(i: number): number

How many vertices meshlet i has.

Meshlets.level()

level(i: number): number

0 for a leaf over the mesh itself, higher for a simplified level above it.

Meshlets.group()

group(i: number): number

Which group of a levelled build meshlet i belongs to.

Meshlets.error()

error(i: number): number

How far meshlet i's level moved the surface; zero at level 0.

Meshlets.childCount()

childCount(i: number): number

How many finer meshlets sit below meshlet i.

Meshlet

interface Meshlet
index: number
level: number
group: number
error: number
vertexCount: number
triangleCount: number
positions: Float32Array
normals: Float32Array
indices: Uint32Array
children: Uint32Array
meshlet(i: number): Meshlet

One meshlet's arrays and numbers, copied out: index, level, group, error, vertex_count, triangle_count, positions, normals (zeros where the mesh had none), indices (into the meshlet's own vertices) and children. The arrays are yours.

Meshlets.free()

free(): void

Give the meshlets back. Idempotent; the collector or scope does it otherwise.

Meshlets.freed

Whether Meshlets.free() has run.

Ask by catching the throw.

FemMesh

class FemMesh

One body meshed for a solver: nodes welded by bits, triangles wound outward, every node tagged with the lowest-dimension B-rep entity it lies on, and every crack reported rather than closed. What Node.femMesh() returns, and owned by you: free it, or let the language's scope do it (see Lifetimes).

A handle rather than a snapshot. In every wrapper that can lend a view, the big arrays are read-only views into the library's own memory, as Node.mesh()'s are and for the same reason — a solver mesh is megabytes, and copying it to hand it over would cost that twice. Node and Godot copy instead, having no borrowed-view machinery at all, so for those two the array is theirs and everything below about a stale view falls away. Either way the owner of the memory is this object rather than the scene: Scene.close() neither frees a FEM mesh nor stales one, and meshing the body again does not either. Only FemMesh.free() does, or the language's own scope or collector reclaiming the handle.

So keep the FEM mesh itself reachable for as long as you read a view of it, and copy anything that must outlive it. What refuses a stale read is a different mechanism in each language, so all ten are named here rather than a rule with an "otherwise" in it. Swift's view type carries its owner and asks it before every element, so the read itself is refused — it traps inside the subscript getter, measured in a release build. Rust settles it before the program runs: its free takes the mesh by value, so a slice can neither be asked for after it nor held across it. Godot and Node hand back copies, so there is nothing of the library's left to go stale. Python, C#, Java and C++ check the handle in the accessor, so a view asked for after the free is refused and one already in hand is a bare array, span or buffer that reads freed memory — measured in C#, where a span taken before the free read the body's own coordinates out of the freed block. Python's numpy array does hold the mesh, which keeps it reachable (below), but nothing asks the mesh when the array is read, so one kept past an explicit free() dangles as C#'s span does. Go's and LuaJIT's arrays are fields filled when the mesh was built rather than accessors, so neither moment is refused there; their methods are, and for those two this is documented rather than enforced, as their own module headers already do for the scene.

Staying reachable is a second question, and a narrower one. In C#, Java, Go and LuaJIT the view is the platform's own array type with nowhere to hold a reference back to the handle, so a program that keeps a view and lets go of the mesh can have the collector free the handle under it with nothing ever calling FemMesh.free() — measured in C#, Java and Go. C++ has no collector but the same shape at scope end: the mesh's destructor frees the handle when it goes out of scope, and a Span kept past that reads freed memory. A view type that carries its owner is safe from that (Python's, Swift's), and so is a language that rules the case out — Rust borrows the mesh for the view's lifetime, Godot and Node copy. The same rule as Solid.mesh()'s own views.

FemMesh.nodes()

nodes(): Float64Array

Every node's position, three doubles each, placed by Node.femMesh()'s placement and in the space FemMesh.fromMesh names. Every node is used by at least one triangle.

The five arrays are methods here, and each one copies. nodes() decodes a fresh Float64Array out of the handle every time it is asked, and the four Uint32Arrays the same — this wrapper has no borrowed-view machinery at all, koffi.decode allocating a typed array of its own (measured: two asks give two buffers, and a write into one is invisible to the other). So the paragraph above does not apply to Node: an array in hand survives free(), the collector and the owner, with nothing of the library's left in it to go stale, which is also why there is no copy() to call. The price runs the other way — every ask copies again — so hold the array rather than calling nodes() inside a loop. FemEdge's nodes and runs are copies too, and chains() gives subarray views into them, not into the library.

FemMesh.triangles()

triangles(): Uint32Array

Three node indices a triangle, wound outward — a mirroring placement is wound back.

FemMesh.triangleFace()

triangleFace(): Uint32Array

Which B-rep face each triangle lies on, one per triangle, into the body's FemMesh.faceCount faces.

FemMesh.nodeKind()

nodeKind(): Uint32Array

What each node lies on — 0 a B-rep vertex, 1 an edge, 2 a face — one per node: the lowest-dimension entity it lies on, which is the .msh format's own classification rule. FemMesh.nodeEntity() says which entity of that kind.

FemMesh.nodeEntity()

nodeEntity(): Uint32Array

Which vertex, edge or face each node lies on, read by the matching FemMesh.nodeKind(): an index into FemMesh.vertices(), into FemMesh.edges(), or into the body's faces.

FemMesh.faceCount

readonly faceCount: number

The body's faces; FemMesh.triangleFace() and a FemMesh.nodeKind() of 2 index them.

FemMesh.edges()

edges(): FemEdge[]

One FemEdge per B-rep edge, in the order a FemMesh.nodeKind() of 1 indexes them. Empty for a FemMesh.fromMesh body, which has no B-rep edges at all.

FemEdge

class FemEdge
id: number
nodes: Uint32Array
runs: Uint32Array
faces: [number, number]
ends: [number, number]
closed: boolean
seam: boolean
chains(): Uint32Array[]

One B-rep edge's chain of nodes, and where that chain breaks. nodes are this mesh's node indices in order along the edge, its end vertices included. runs says where the chain breaks: each entry is a start offset into nodes, and the nodes from one offset up to the next — the last offset running to the end — are a polyline of their own, with nothing joining across a boundary. The two ends either side of a boundary are two points of the edge with no mesh edge between them, a crack along the edge or a stretch of it sampled on one face only. (0,) is the ordinary answer, and a caller reading nodes as one polyline without looking here jumps the gap silently.

faces is (face_a, face_b) and ends is (end_a, end_b), the second of each a sentinel where there is none — an open body's rim, or both ends at one vertex. 0 is a real face and a real vertex, not a sentinel. Which end comes first is the first trim's direction and means nothing else: the pair bounds the edge, it does not orient it. closed where the nodes make one loop, never with more than one run; seam where one face bounds the edge twice, and both faces are then that same face.

id is the body's own edge id, not this mesh's edge index: FemMesh.edges() is a densely renumbered subset of the body's edges, ascending by id, with every edge collapsed to a point left out, so edge 0 of a STEP body's mesh routinely has an id in the hundreds. Everything else that names an edge means the index — a FemMesh.nodeKind() of 1 read through FemMesh.nodeEntity(), the third number of a FemMesh.openEdges() or FemMesh.foldedEdges() row, and the edge_<i> physical group of FemMesh.mshText() — and this is the one way back from any of them to the topology the file wrote.

FemMesh.vertices()

vertices(): FemVertex[]

One FemVertex per B-rep vertex, in the order a FemMesh.nodeKind() of 0 indexes them. Empty for a FemMesh.fromMesh body.

FemVertex

class FemVertex
node: number
point: Float64Array
hasPosition: boolean

One B-rep vertex: node is the mesh node there, a sentinel where the mesh has none, which is ordinary rather than a fault — the analysis rebuilds a vertex wherever two trims meet, so a sphere has 48 of them where the mesh has two points, and a caller walking these skips the sentinel instead of reading it as a gap.

point is where the topology says the vertex is, in the same space and under the same placement as FemMesh.nodes() — the file's own vertex rather than a mesh node, so the two can differ by the reader's rounding. Meaningless unless has_position: it is all zeros then, a point no geometry has and one a solver would read as a node at the origin.

FemMesh.openEdges()

openEdges(): [number, number, number][]

Every crack, as (a, b, brep_edge): a directed mesh edge (a, b) with no (b, a), and the B-rep edge both nodes lie on where they share one.

Empty unless the body's topology is closed — for a B-rep body, whose mesh is otherwise not asked about at all. The census asks whether a body that ought to enclose a solid does, and an open one — a sheet, a bag of surfaces, a shell the file itself wrote open — makes no such claim to check: its rim is not a crack. So such a body reports FemMesh.watertight false with this and FemMesh.foldedEdges() both empty, and that trio of answers together is what says "not asked", not "nothing found".

A FemMesh.fromMesh body is the exception, and the opposite case. A bare mesh carries no topology to say whether it ought to close, so its census always runs over the welded triangles: an open one lists its cracks here with FemMesh.watertight false, a closed one reports FemMesh.watertight true with no topology consulted at all, and an empty census there really does mean "nothing found".

FemMesh.foldedEdges()

foldedEdges(): [number, number, number][]

Every fold, as FemMesh.openEdges() reports a crack: a directed mesh edge used by more than one triangle, once.

A body can be folded without being open — a solid no thicker than a line leaves no hole for an open edge to find — and the closure census's own known-bad bodies are folds rather than open cracks. A caller that checks FemMesh.openEdges() alone calls such a body sound. Empty under the same rule as FemMesh.openEdges().

FemMesh.crossings()

crossings(): [number, number][]

Every pair of triangles that pass through each other, as (a, b) with a < b, sorted: an edge of one through the other's interior. Their B-rep faces are FemMesh.triangleFace() at a and b.

Computed for every body, open or closed. FemMesh.watertight, FemMesh.openEdges() and FemMesh.foldedEdges() are topological and cannot see a surface passing through itself; a mesh is ready for a volume mesher when it is FemMesh.watertight and this is empty — Gmsh refuses one that crosses. A copy.

FemMesh.watertight

readonly watertight: boolean

The welded mesh closes — every directed mesh edge paired with its reverse and none used twice — and, for a B-rep body, so does the topology behind it. false for every B-rep body whose topology is not closed, whose mesh is then not asked about; read FemMesh.openEdges() for what an empty census beside a false here does and does not mean.

A FemMesh.fromMesh body has no topology to ask of, so this says only that its triangles close: a closed render mesh reports true with nothing exact behind it at all.

Ready for a volume mesher means this and an empty FemMesh.crossings(): this census is topological and cannot see a surface passing through itself.

FemMesh.fromMesh

readonly fromMesh: boolean

This came from the scene's own mesh rather than from a B-rep: one face, every node on face 0, no edges and no vertices.

It is also which space the mesh is in. A B-rep body's FEM mesh is in the file's own units and axes, whatever Convention the scene was opened with, because it is taken off the B-rep — and a B-rep is in the file's own space for the reason Brep gives. A node with no B-rep falls back to the scene's mesh, which is converted, so that one comes back in the scene's convention, wound counter-clockwise about the outward normal even where the convention winds the other way.

And it is which contract the census is reporting under: read FemMesh.openEdges().

FemMesh.minAngle

readonly minAngle: number

The smallest interior angle of any triangle, in degrees. There is always one: a body that meshed to no triangles is a refusal, not a mesh.

FemMesh.worstTriangle

readonly worstTriangle: number

The triangle with that angle, as an index into FemMesh.triangles().

FemMesh.longestEdge

readonly longestEdge: number

The longest triangle edge, placed. The figure to check against Node.femMesh()'s max_size, and the only one that says what the mesh actually is. max_size bounds the boundary segments and merely targets the interior: measured at 1.03 x max_size on a face whose parameters run unevenly, where a full-size boundary piece met a much shorter one left by halving. One small enough beside the body to reach the mesher's own piece and station ceilings is not honoured at all.

FemMesh.mshText()

mshText(): string

The mesh as Gmsh 4.1 ASCII .msh text: an entity per B-rep vertex, edge and face, a volume where the body closes, and a physical group naming each.

Gmsh reads the file as written — measured with Gmsh 4.15: node and triangle counts equal to this mesh's, and a physical group per entity. To fill a closed body with tetrahedra, give Gmsh a volume of its own over the file's surfaces. In its Python API: gmsh.open(path), then faces = [t for _, t in gmsh.model.getBoundary([(3, 1)], oriented=False)], gmsh.model.geo.addVolume([gmsh.model.geo.addSurfaceLoop(faces)]), gmsh.model.geo.synchronize() and gmsh.model.mesh.generate(3). A plain generate(3) leaves a volume read from any .msh file empty — Gmsh's own saved meshes too — and gmsh.model.mesh.createGeometry() re-meshes the surfaces rather than keeping these triangles.

Prefer Gmsh's HXT algorithm: gmsh.option.setNumber("Mesh.Algorithm3D", 10) before generate(3). On these surfaces the default left tetrahedra of exactly zero volume (four in a 100 mm bar), which no solver can use, and HXT's worst element came out far better on curved bodies (a minimum SICN of 0.1 to 0.3 where the default's was 0.001). Then name the tetrahedra before saving: HXT fills the new volume rather than the file's own, and gmsh.write keeps only elements in a physical group, so without this step every tetrahedron is dropped from the file without a word — filled = [t for _, t in gmsh.model.getEntities(3) if len(gmsh.model.mesh.getElementsByType(4, t)[0])], gmsh.model.removePhysicalGroups(gmsh.model.getPhysicalGroups(3)) and gmsh.model.addPhysicalGroup(3, filled, name="body"). The saved file also lists a few interior nodes no element uses — points Gmsh's refinement tried and gave up on — so a solver reading it should keep only the tetrahedra's own nodes: each unused one is an unconstrained unknown.

On this side of the ABI the library's text is borrowed — a slot on this handle, replaced by the next call on it and gone when the mesh is freed. The wrapper copies it out on the way, so what a caller holds is a string of its own. The kernel library's own msh_text is the other way round: an owned string, released by the wrapper (cadaclysm_blacksmith_string_free at the ABI), two asks giving two independent texts. A reader porting one side's reasoning onto the other leaks or double-frees.

No unlicensed notice is printed here. Node.femMesh() gave it once when the mesh was built, and this ABI deliberately does not repeat it on either .msh call — where the kernel library notices on both of its writers and not on its builder. Each matches its own siblings, so moving the call to look like the other side breaks a convention.

It throws CadaclysmError for a mesh the writer refuses, naming the field it cannot honour, and for a freed handle.

FemMesh.saveMsh()

saveMsh(path: string): void

FemMesh.mshText() written to a path by the library itself: the same bytes from the same writer, straight to the file rather than through the borrowed slot, so a text asked of this handle on another thread cannot be freed under the write. It throws CadaclysmError for a mesh the writer refuses or a file it cannot write, naming the path. No notice here either; see FemMesh.mshText().

FemMesh.free()

free(): void

Give the mesh back, and with it every view taken from it. Idempotent; the collector or the scope does it otherwise.

There are no views to give back with it: every array this wrapper hands out is a copy (see nodes() above), so what free() ends is the handle and the calls that read through it — each of which throws fem mesh: freed afterwards. A second free() is a no-op, and the collector does it for a mesh you drop.

FemMesh.freed

readonly freed: boolean

Whether FemMesh.free() has run.

Surfaces and Face

class Surfaces implements Iterable<Face>

A node's faces as exact surfaces and trims: what Node.surfaces() returns. Iterate it for Face values. In the file's own frame; Scene.surfaceMatrix brings it into the scene's.

Surfaces.faces

faces: Face[]

The faces, one per trimmed face of the body.

Face

class Face
kind: number
origin: Float32Array
domain: Float32Array
scalars: Float32Array
loops: Float32Array[]
nurbs: Float32Array

One trimmed face. kind is the surface: 0 plane, 1 cylinder, 2 cone, 3 sphere, 4 torus, 5 revolution, 6 extrusion, 7 NURBS, 8 sum. origin, ax, ay, az are its frame, scalars its kind-dependent sizes (radius, angle…) and domain its (u min, v min, u max, v max). loops holds the trim loops as (u, v) points, each closing implicitly; profile, profile2 and nurbs carry what a swept or NURBS surface needs. reversed flips the normal; transposed swaps u and v. The C header's CadaclysmFace is the full description.

Tolerances

interface Tolerances

What a file declares about its own precision, as a named tuple: absolute, a length in the file's own unit, and angular, in radians — each none where the file said nothing. What Scene.tolerances returns.

Bounds

class Bounds

An axis-aligned box: what Node.bounds and Scene.bounds return. All zeros means "nothing here".

Bounds.min

min: Float32Array

The low corner.

Bounds.max

max: Float32Array

The high corner.

Bounds.isEmpty

readonly isEmpty: boolean

Whether this is the all-zero box that stands for nothing.

Bounds.size

readonly size: number[]

The extent along each axis.

Bounds.centre

readonly centre: number[]

The midpoint.

Attribute

class Attribute

One thing the file said about a node: what Node.attributes() lists.

Attribute.name

name: string

What the file called it.

Attribute.kind

kind: ValueKind

Which kind of value it holds — a ValueKind. Lets a caller tell a reference from prose, or total the numbers.

Attribute.value

value: string | number | boolean | null

The value, in the language's own type where it has one for the kind.

Attribute.text

readonly text: string

The value rendered for display, identically in every wrapper: true/false, reals in their shortest exact form, lists as [a, b, c].

Convention

const Convention

The coordinate space to open a file into. The library converts on the way out, so a caller names the space it draws in and reads geometry already in it — nothing to rotate or scale afterwards.

Convention

const Convention
readonly NATIVE: 0
readonly UNREAL: 1
readonly UNITY: 2
readonly Y_UP: 3
readonly BLENDER: 4

The presets: NATIVE keeps the file's own axes and units; UNREAL is Z up, left-handed, centimetres; UNITY Y up, left-handed, metres; Y_UP Y up, right-handed, metres (glTF, three.js, most real-time engines); BLENDER Z up, right-handed, metres.

Convention.FILE_UNITS

readonly FILE_UNITS: 0x100

Combine with a preset to keep its axes but the file's own units.

Convention.UV_WORLD

readonly UV_WORLD: 0x200

Combine with a preset to ask for world-scale texture coordinates in Mesh.uvs. Off by default: eight bytes a vertex nobody asked for.

Convention.parse()

parse(text: string): number

A convention from a name a user typed: unreal, or unreal+file-units. An unknown name throws CadaclysmError listing the accepted ones, rather than silently reading as native.

ValueKind

const ValueKind

Which kind of value an Attribute holds.

ValueKind

const ValueKind
readonly NONE: 0
readonly TEXT: 1
readonly INTEGER: 2
readonly REAL: 3
readonly BOOLEAN: 4
readonly LIST: 5
readonly REFERENCE: 6

TEXT, INTEGER, REAL, BOOLEAN; LIST (the elements rendered as [a, b, c]); REFERENCE (another entity, by the id the file gave it, so it can be followed rather than shown as prose); NONE for an attribute that had no value.

Manifold

interface Manifold

Whether a body's faces make a manifold — every edge bordered by one face or two, the faces round every vertex one fan — told from its topology rather than a mesh: what a brep's manifold and the kernel's Solid.manifold return. Orientation is not asked. The topology is the file's: faces that name no shared edge (IGES, each surface its own sheet; an IFC face written as one polygon) read as open however well they meet in space.

Manifold.faces

faces: number

How many faces.

Manifold.edges

edges: number

How many distinct edges: one shared by two faces counts once.

Manifold.vertices

vertices: number

How many distinct vertices.

Manifold.boundaryEdges

boundaryEdges: number

Edges only one face borders: a sheet's rim, a hole in a shell.

Manifold.nonManifoldEdges

nonManifoldEdges: number

Edges three or more faces border: a fin, or two solids meeting along a line.

Manifold.nonManifoldVertices

nonManifoldVertices: number

Vertices whose faces make more than one fan: two solids touching at a corner.

Manifold.isManifold

isManifold: boolean

No non-manifold edge or vertex: a manifold, possibly with a boundary.

Manifold.isClosed

isClosed: boolean

A manifold with no boundary edge either: it encloses a solid.

SewReport

interface SewReport

What Brep.sew() did, as plain data: the edges it joined, the free edges before and after, how many groups of free edges it left free, the widest gap it sewed, and the two tolerances it used.

SewReport.pairs

pairs: number

How many pairs of free edges it joined into one shared edge.

SewReport.freeBefore

freeBefore: number

Free edges (those only one face borders) before sewing.

SewReport.freeAfter

freeAfter: number

Free edges after sewing.

SewReport.refused

refused: number

How many groups of free edges between the same two vertices it left free: too far apart for the tolerance, or more than two.

SewReport.worstGap

worstGap: number

The widest gap between two curves it sewed.

SewReport.tolerance

tolerance: number

How close two curves had to lie, as used: by default vertex.

SewReport.vertex

vertex: number

How close two edges' ends had to coincide, as used: by default the rounding Brep.manifold merges vertices at.

HealthReport

class HealthReport

What is wrong with a body, as plain data: what Brep.health() returns. Nothing in it moves the body. It lists the free edges (the sides only one face bounds) and the wires they chain into, the features below the tolerance, the loose edges, what sewing would join and leave, and, if asked for, where the body's mesh cracks. The tolerance is an absolute length, as Rhino's model tolerance is; it is reported back as used.

HealthReport.tolerance

tolerance: number

The length below which a feature is small and a gap closes, as used: by default 1e-4 times the body's diagonal. A value that is not finite and positive (NaN, infinite, zero or negative) takes the default.

HealthReport.rounding

rounding: number

The rounding the body's vertices are merged at, as used.

HealthReport.extent

extent: number

The body's diagonal, the length the default tolerance is a fraction of.

HealthReport.freeEdges

freeEdges: FreeEdge[]

The free edges, as FreeEdge rows, each wire's edges together and in order.

HealthReport.wires

wires: FreeWire[]

The chains the free edges make end to end, as FreeWire rows.

HealthReport.small

small: SmallFeature[]

The features below the tolerance, as SmallFeature rows.

HealthReport.looseEdges

looseEdges: number

How many shared edges are loose: the two faces' sides along the edge lie further apart than the larger of the tolerance the body recorded for the edge and the one given.

HealthReport.worstLoose

worstLoose: number

The widest such gap; 0 when no edge is loose.

HealthReport.sewPairs

sewPairs: number

How many pairs of free edges Brep.sew() (or Solid.joinSheets()) would join: those with shared_ends 2.

HealthReport.sewRefused

sewRefused: number

How many groups of free edges it would leave free.

HealthReport.sewWorstGap

sewWorstGap: number

The widest gap it would sew.

HealthReport.cracks

cracks: Cracks | null

Where the body's mesh cracks, as a Cracks; null unless the call asked for the mesh. Cracks are only counted on a closed body: for an open one the census is empty by design, so watertight false beside no edges means "not asked", not "nothing found".

HealthReport.worstGap

worstGap: number

The widest gap between a free edge and its partner. A rim has no true partner, so it reads as a gap the size of the part.

HealthReport.wireEdges()

wireEdges(wire: number): FreeEdge[]

The free edges of one wire, by its number in wires, in order.

FreeEdge

class FreeEdge

One free edge: a side only one face bounds, with its nearest partner. The partner is the nearest free edge other than a neighbour on its own wire, so the rim of a sheet reads as a gap the size of the part rather than as a crack, and a real seam reads as a small gap. The partner is a row index into free_edges.

FreeEdge.trim

trim: number

The face's side this is.

FreeEdge.edge

edge: number | null

The edge it lies on; null for a side that has no edge.

FreeEdge.face

face: number

The face it bounds.

FreeEdge.wire

wire: number

The free wire it is on: a row of wires.

FreeEdge.partner

partner: number | null

The nearest free edge across the gap, as an index into free_edges; null if there is none.

FreeEdge.sharedEnds

sharedEnds: number

How many of its two ends it shares with the partner: 2 is what Brep.sew() joins.

FreeEdge.length

length: number

Its length.

FreeEdge.gap

gap: number

The distance to the partner; infinite without one.

FreeWire

class FreeWire

A chain of free edges end to end.

FreeWire.first

first: number

The row of free_edges it starts at: its edges are the rows first to first + count.

FreeWire.count

count: number

How many free edges it holds.

FreeWire.closed

closed: boolean

Whether it closes on itself.

FreeWire.length

length: number

Its total length.

FreeWire.widestGap

widestGap: number

The widest gap from any of its edges to a partner.

SmallFeature

class SmallFeature

Something below the tolerance.

SmallFeature.kind

kind: SmallFeatureKind

What it is: short_edge, collapsed_edge, sliver_face, tiny_face, tiny_body or small_hole (an inner loop whose edges are all free, below the tolerance in area or width: a pinhole in an open sheet; a hole with walls is not one).

SmallFeature.index

index: number

Its edge, face or body number; a small hole's is its loop number.

SmallFeature.size

size: number

How small it is.

Cracks

class Cracks

What a mesh of the body shows, asked for with mesh=True: the call meshes the body. Only a closed body is counted: an open one's census is empty by design, as its rim is not a crack.

Cracks.watertight

watertight: boolean

Whether the mesh has no open or folded edge.

Cracks.open

open: number

How many mesh edges only one triangle uses.

Cracks.folded

folded: number

How many mesh edges more than two triangles use.

Cracks.crossings

crossings: number

How many pairs of triangles pass through each other.

Cracks.edges

edges: number[]

The body's edges the cracks lie along.

HealReport

class HealReport

What Brep.heal() did, as plain data: the fixes it made, the small features it left and why, and the body's health before and after at the tolerance it healed at. Indices are the input body's.

HealReport.tolerance

tolerance: number

The tolerance it healed at, as used: by default 1e-4 times the body's diagonal.

HealReport.moved

moved: number

The furthest any trim the result keeps moved, measured: the edited trims against the originals. Not the same measure as a HealFix's moved, which is how far that fix's merged vertices moved: a curve can move further than its ends, and the trims of a dropped edge are not measured at all, so either can be the larger.

HealReport.guarded

guarded: boolean

Whether the guard refused a fix: the full result was worse (less closed, more free or non-manifold edges, or no faces left), so the face pass's fixes were refused and the rest kept, or, if that was still worse, every fix was refused and the body came back as it was. Refused fixes are listed as body_guard.

HealReport.fixes

fixes: HealFix[]

What was done, as HealFix rows, in the order it was done. A short edge removed as part of a face is that face's fix and is not listed again.

HealReport.refused

refused: HealRefusal[]

What health listed as small and was left, as HealRefusal rows.

HealReport.smallBefore

smallBefore: number

How many small features health listed on the input.

HealReport.smallAfter

smallAfter: number

How many it lists on the result.

HealReport.freeBefore

freeBefore: number

The input's free edges (sides only one face bounds).

HealReport.freeAfter

freeAfter: number

The result's free edges.

HealReport.closedBefore

closedBefore: boolean

Whether the input was closed.

HealReport.closedAfter

closedAfter: boolean

Whether the result is closed.

HealReport.nonmanifoldBefore

nonmanifoldBefore: number

The input's edges three or more faces share.

HealReport.nonmanifoldAfter

nonmanifoldAfter: number

The result's.

HealFix

class HealFix

One small feature removed.

HealFix.kind

kind: SmallFeatureKind

What it was, as SmallFeature's kind.

HealFix.index

index: number

Its edge, face or loop number in the input, as health gave it.

HealFix.size

size: number

How small it was.

HealFix.moved

moved: number

How far the vertices this fix merged moved. The report's own moved is a second measure, how far any surviving trim moved, measured; either can be the larger.

HealRefusal

class HealRefusal

One small feature left, and why.

HealRefusal.kind

kind: SmallFeatureKind

What it is, as SmallFeature's kind.

HealRefusal.index

index: number

Its edge, face or loop number in the input.

HealRefusal.why

why: HealWhy

would_empty_loop (removing the edge would leave a loop with no trims: the face pass's case), closed (both ends already one vertex: a tiny closed curve), seam (one face uses the edge twice), chain (the vertices to merge span more than the tolerance), neighbours_part (a sliver's two long sides part by more than the tolerance), uneven (a sliver's long edges are not two, one per side), non_manifold (a sliver side three or more trims share), has_holes (the sliver or tiny face has inner loops), body_guard (the guard refused the fix), toggled (its kind switched off) or unsupported (a tiny body, which healing never removes).

HealRefusal.figure

figure: number

The width of a chain, the gap of neighbours_part; 0 otherwise.

RecognizeReport

class RecognizeReport

What Brep.recognize() did, as plain data: the faces and edges given an analytic kind, the faces left free-form and why, and the tolerance it fitted to. Faces and edges are numbered as in the body, before and after alike.

RecognizeReport.tolerance

tolerance: number

The tolerance it fitted to, as used: by default 1e-6 of the body's extent.

RecognizeReport.faces

faces: RecognizedFace[]

The faces given an analytic kind, as RecognizedFace rows.

RecognizeReport.refused

refused: RecognizeRefusal[]

The free-form faces left, as RecognizeRefusal rows.

RecognizeReport.edges

edges: RecognizedEdge[]

The edges whose curve was given an analytic kind, as RecognizedEdge rows, in edge order.

RecognizeReport.edgesLeft

edgesLeft: number

How many edges were left on a free-form curve.

RecognizeReport.worstFace

worstFace: number

The furthest any face taken lies from its analytic surface; 0 when none was taken.

RecognizeReport.worstEdge

worstEdge: number

The furthest any edge taken lies from its analytic curve; 0 when none was taken.

RecognizedFace

class RecognizedFace

One face given an analytic kind.

RecognizedFace.face

face: number

Its face number, the same before and after.

RecognizedFace.kind

kind: RecognizedFaceKind

plane, cylinder, cone, sphere or torus.

RecognizedFace.deviation

deviation: number

The furthest any sample of the face or point of its edges lies from the analytic surface.

RecognizeRefusal

class RecognizeRefusal

One face left free-form, and why.

RecognizeRefusal.face

face: number

Its face number.

RecognizeRefusal.why

why: RecognizeWhy

no_kind (no kind fits within the tolerance), mixed_normals (its normals point both ways), parameter_trims (a trim in its surface's parameters could not be lifted to space) or too_few_samples.

RecognizeRefusal.closest

closest: number | null

For no_kind, the deviation of the kind that came closest; null otherwise.

RecognizedEdge

class RecognizedEdge

One edge whose curve was given an analytic kind.

RecognizedEdge.edge

edge: number

Its brep edge id, as edge_tolerance takes one.

RecognizedEdge.kind

kind: RecognizedEdgeKind

line, circle or ellipse.

RecognizedEdge.deviation

deviation: number

The furthest any point of the curve or the edge lies from the analytic curve.

Errors

class CadaclysmError extends Error

A call into the library failed; the message is the library's own reason. One type for every reader failure.

Kernel · cadaclysm_blacksmith_*

Building solids

Frames and axes

A frame is twelve numbers: an origin, then the x, y and z axes, each three numbers (0,0,0, 1,0,0, 0,1,0, 0,0,1 is the world). A profile is drawn in its frame's x/y and extruded along its z. An axis is six numbers: a point and a direction, which need not be unit. Workplane.xy() and friends start on the three world planes; Solid.faceFrame() gives the frame on a face. A Frame builds one for you — Frame.xy() at any origin, Frame.at() from a point and a normal — and checks that its axes are square and right-handed, which a bare twelve numbers are not.

Pass a Frame, twelve numbers or four triples; an axis is six numbers or two triples.

Module functions

The kernel's own module: its version, licence, STEP and .brep writers. The kernel and the reader are one library, so its licence call and the reader's set the same licence.

blacksmith.writeStep()

function writeStep(path: string, solids: Iterable<Solid>, schema?: string | null, unit?: Unit): void;

Write several solids as one STEP file, each its own body. unit is mm, m or in. schema is left out for AP203 (built in — no file needed; AP242 when any solid, face or edge is coloured, since AP203 has no colour entities), the name of another built-in schema such as AP242's AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF (AP214's AUTOMOTIVE_DESIGN cannot carry the writer's mechanical_context), or a custom EXPRESS schema: a path to its .exp or its text. Colours from coloured and edges_coloured are written as STEP styling wherever the schema has it, a solid's read back as the node's colour; a named schema without it writes the solids bare.

blacksmith.writeStepText()

function writeStepText(solids: Iterable<Solid>, schema?: string | null, unit?: Unit): string

The same STEP file as text, for a caller that stores or sends it rather than writing a file.

writeStepAssembly

Write an assembly as one STEP file: parts names each solid, in its own coordinates, and each is written once as its own product; placements lists (name, frame) pairs, each an occurrence of that part at that frame (right-handed and orthonormal), all under one root product. A reader tessellates a part once however many times it is placed, and shows each placement under its part's name. schema and unit as blacksmith.writeStep().

Not in this wrapper: build an Assembly and write it with step or step_text.

writeStepAssemblyText

The same assembly as STEP text.

Not in this wrapper: build an Assembly and write it with step or step_text.

blacksmith.writeBrep()

function writeBrep(path: string, solids: Iterable<Solid>): void;

Write several solids as one OCCT .brep file, each its own solid under one compound (a single solid is the file's root): the exact surfaces and curves, with a curve in each face's own parameters for every edge, so Open CASCADE's BRepTools::Read gives a shape its BRepCheck_Analyzer finds valid. No unit is declared — a .brep carries none — so the numbers written are the numbers held. The library writes the file itself.

blacksmith.writeBrepText()

function writeBrepText(solids: Iterable<Solid>): string

The same .brep file as text.

blacksmith.writeSat()

function writeSat(path: string, solids: Iterable<Solid>, unit?: Unit): void;

Write several solids as one ACIS SAT file, each its own body: planes, cylinders, cones, spheres and tori as their own records, splines and swept surfaces as exact NURBS, in the layout Rhino's own exporter writes. unit is mm, m or in and goes into the header as millimetres per unit. The library writes the file itself, so a refusal names it.

blacksmith.writeSatText()

function writeSatText(solids: Iterable<Solid>, unit?: Unit): string

The same SAT file as text.

blacksmith.write3dm()

function write3dm(path: string, solids: Iterable<Solid>, unit?: Unit): void;

Write several solids as one Rhino .3dm (version 8, which Rhino 8 and 9 open), one object each: its exact brep — the surfaces and trims as they are — or, where a body has no exact form there, its mesh, with a warning saying so. Each object is named as its solid is and coloured with the solid's own colour, each painted face with its own (Rhino keeps it on the face; a body written as its mesh carries them as vertex colours; an edge's own colour has no place in a .3dm and is left out, with a warning saying so), and carries the solid's attributes as user text. unit is mm, m or in and is the file's unit: the numbers written are the numbers held. The library writes the file itself, so a refusal names it.

blacksmith.rhino3dmBytes()

function rhino3dmBytes(solids: Iterable<Solid>, unit?: Unit): Buffer;

The same .3dm file as bytes.

blacksmith.meshFile()

function meshFile(solids: Iterable<Solid>, format?: 'stl' | 'stl-ascii' | 'obj' | 'glb' | 'gltf' | '3mf' | 'ply' | 'ply-ascii', names?: Iterable<string> | null, looks?: Iterable<ArrayLike<number>> | null, tolerance?: number | null): Buffer

Several solids meshed at tolerance — each the mesh Solid.mesh() hands out — as one file's bytes in format: "stl" (binary, every solid in one body), "stl-ascii" (one body named as the first solid), "obj" (one named object a solid, no material library), "glb" or "gltf" (one named node a solid in a material of its own; the .gltf with its buffer embedded), "3mf" (a 3MF package, one named object a solid, in millimetres), "ply" (binary little-endian) or "ply-ascii" (PLY, every solid's triangles in one body). 3MF and PLY carry the solids' colours — each face its own where it was painted, else the solid's; 3MF a colour a triangle, PLY a colour a vertex — and none when no solid is coloured. names one a solid (left out: each solid's own name, else Solid 1, Solid 2, ...); looks one a solid, six numbers each — linear r, g, b, a, metallic, roughness in 0..1 — the glTF's materials (left out: each solid's own colour); the other formats ignore them. No solids, an unknown format, or names or looks not one a solid throws BuildError.

blacksmith.writeSvg()

function writeSvg(path: string, things: Iterable<Drawable>, options?: SvgOptions): void;

Several solids and profiles' wireframe as one SVG, any mix and any order: a <g id="solid-<i>"> per solid then a <g id="profile-<i>"> per profile, each stroked in its own colour where it carries one — a solid's edge colour first, then its body colour (a face colour says nothing about a wireframe) — and the keywords' stroke= otherwise. The keywords are Scene.svg()'s own: view= (front, back, left, right, top, bottom, iso), az=/el= over it, up= (default z: neither a solid nor a profile carries a convention of its own to default it from), fov= (0, the default, is orthographic), size=, margin=, tolerance=, stroke= and background= ("#rgb", "#rrggbb" or a CSS colour name in every language, beside that language's own numeric form; background= null for transparent), width= (the stroke's, in page units), edges=, curves=, isocurves=, polylines= (which line sets are drawn; edges by default), and silhouettes= (also draw where each solid's surfaces turn away from the eye — the outline a sphere has no edge for, on by default: a sphere's and a torus's only curves are the seams where their one face meets itself, which are not edges of the body and are never drawn, so without it those two draw a blank page. A line set in its own right, so silhouettes= with edges= off draws the outline alone).

hidden= draws the solids through hidden-line removal, the solids on the page hiding one another, seen from the eye the other words describe: null (the default) draws every line, "removed" only what is seen — edges in solid-<i>, outlines in solid-<i>-silhouettes — and "dashed" adds the hidden lines, dashed, in a solid-<i>-hidden group. Profiles neither hide nor are hidden.

A list of solids alone draws exactly as it always did. The SVG is the drawing itself: with path, writes it to the file and returns null; without, returns the SVG text. Both lists empty throws BuildError; so does anything in them that is neither a solid nor a profile, a refused option, or a failed write.

blacksmith.hlr()

function hlr(solids: Iterable<Solid>, options?: HlrOptions): Hlr;

Hidden-line removal of several solids, each where it stands, every solid hiding the others: what a drawing of them shows, and what it shows only dashed, as an Hlr. A parallel view along direction (from the eye toward the model; default (0, 1, 0), the front) with up the page's up (default (0, 0, 1)), or, with eye, a perspective from eye toward target — not both direction and eye. Each line is a span of an edge's own curve or of a silhouette, exact as rational cubic Béziers; iso above 0 adds that many isocurves each way on every face; smooth_angle (radians, default one degree) is how near tangent two faces are for the edge between them to be "smooth". tolerance null or 0 is the solids' effective tolerance. View coordinates are the camera's, x right and y up, the origin on the sight line through the solids' box centre. No solids, a zero direction or up, up along the sight line, eye on target, or an angle or tolerance out of range throws BuildError.

blacksmith.hlrMesh()

function hlrMesh(meshes: Iterable<TriangleMesh>, options?: HlrOptions): Hlr;

blacksmith.hlr() of triangle meshes (TriangleMesh), each a solid of flat triangles: its lines are the edges whose two triangles turn by more than feature_angle (radians, default thirty degrees), the edges with one triangle, and the edges between a triangle facing the eye and one facing away (the outlines); the triangles hide exactly. Each line's source is a mesh edge, its two vertices. The same view words as blacksmith.hlr(), bar iso and smooth_angle.

blacksmith.projectedOutline()

function projectedOutline(solids: Iterable<Solid>, options?: HlrOptions): Profile[];

The boundary of the union of the solids' projections, as closed Profiles in blacksmith.hlr()'s view coordinates: each outer loop counter-clockwise with its holes clockwise inside it, so a through hole seen along its axis is a hole. The silhouette a part casts — what a laser cuts or a pocket clears — ready to extrude. blacksmith.hlr()'s view words, bar iso and smooth_angle.

blacksmith.dxfProfiles()

function dxfProfiles(text: string, tolerance?: number | null): Profile[];

A DXF file's closed loops as Profiles, the way back from a drawing: its lines, arcs, circles, ellipses, polylines and splines (blocks inserted) chained end to end within tolerance (null or 0: the effective tolerance over the drawing's extents) into closed loops, each hole nested in the loop around it. Text that is not DXF throws BuildError, naming the line it stopped at.

blacksmith.HLR_KINDS

const HLR_KINDS

The kinds of a hidden-line view's lines, in the C API's numbering from 0: "sharp" (an edge between faces that meet at an angle), "smooth" (an edge between faces near tangent), "outline" (a silhouette, where a surface turns away from the eye), "iso" (an isocurve) and "boundary" (an edge with one face, a sheet's rim).

SQUISH_DEFORMATIONS

The deformations Solid.squish() takes, by name, and their C API codes: free 0, stretch_mostly 1, stretch_only 2, compress_mostly 3 and compress_only 4.

squish takes the deformation's name: "free", "stretch_mostly", "stretch_only", "compress_mostly" or "compress_only".

blacksmith.PAGE_UNITS

const PAGE_UNITS

The units a Page can be drawn in, by name, and the DXF $INSUNITS code each is written as: unitless 0, in 1, ft 2, mm 4, cm 5 and m 6.

blacksmith.defaultSchema()

function defaultSchema(): string

Where an ap203.exp file is found (CADACLYSM_SCHEMAS, else schemas/ in a parent). No longer needed to write STEP: the kernel's AP203 is built in.

blacksmith.version()

function version(): string

The version of the kernel library actually loaded.

blacksmith.flavour()

function flavour(): string;

Which library the kernel loaded: "full", "kernel-reader" or "kernel" for a flavour of the single cadaclysm library, and "kernel" for the separate cadaclysm_blacksmith of earlier releases. Loading the kernel from the reader flavour throws BuildError at once, naming the flavours that have a kernel; a call the loaded flavour does not have (a writer or a part on "kernel") throws BuildError when it is made.

blacksmith.features()

function features(): string;

The features the kernel's library was built with, comma-separated, as the reader's query answers them; empty for the separate cadaclysm_blacksmith.

blacksmith.buildDate()

function buildDate(): string;

When the loaded kernel was built, YYYY-MM-DD.

blacksmith.build()

function build(): { branch: string; commit: string; date: string; time: string; version: string }

The loaded kernel's build: its version, the commit and branch it was built from ("unknown" built from no checkout), when (a release's pinned date), and its build date — {"branch": "master", "commit": "7e4b5058e", "date": "2026-11-14", "time": "2026-11-14T10:22:31Z", "version": "0.14.2"}. What an app shows as the cadaclysm it runs on. Python returns it as a dict and JavaScript as an object; the other languages return the JSON text.

blacksmith.pairFreedomCount()

function pairFreedomCount(kind: string): number;

How many freedoms a pair kind has, so a caller can size Assembly.pair()'s ranges. 0 for an unknown name, and for fully_constrained, which has none.

blacksmith.license()

function license(textOrPath: string): void

Load a licence into the kernel — the text, or a file's path. The reader has its own call; the same file works for both.

blacksmith.licenseInfo()

function licenseInfo(): string

One line about the kernel's licence, or unlicensed. Never null.

blacksmith.licenseNoticeCount()

function licenseNoticeCount(): number;

How many unlicensed notices the kernel has printed to stderr in this process.

blacksmith.setOption()

function setOption(name: string, value: number): void;

Set a kernel option, by its name, for the whole process from the next call on — every thread, every solid. The options are numbers under stable names, one call for all of them, so an option added later needs no new function:

boolean.mesh_budget (default 500000): the most triangles a boolean (join, cut, common, split) builds its trees from, its two solids' meshes together. Past it the boolean refuses with a tolerance error rather than running for minutes or hours. A whole number, at least 1, or infinity for no limit.

boolean.finest_tolerance (default 1e-8): the finest tolerance a boolean takes, as a share of how far its two solids reach; under it the boolean refuses before meshing anything. From 0 (no floor) to below 1.

profile_boolean.point_budget (default 8000000): the most points a profile boolean follows its two profiles' arcs and splines with. Past it the boolean refuses with a tolerance error; 8 million is about 128 MB. A whole number, at least 1, or infinity for no limit.

measure.default_accuracy (default 1e-7): the relative accuracy Solid.mass(), Solid.edgeLength(), Profile.length() and the arc-length samples (Solid.edgePointAtLength(), Profile.pointAtLength() and their divides) refine to when they are asked for 0, the default. Above 0 and below 1. Solid.orientedBox() has its own default, 1e-5, and does not read it.

step.validation_properties (default 0): whether a STEP part file (Solid.step(), blacksmith.writeStep()) carries each body's geometric validation properties — the surface area, the volume and the centroid this kernel measures for it, stated in the file so the kernel that reads it can check the transfer against its own measurement of the same geometry. 1 to write them, 0 not to. Off by default because it measures every body in the file at step.validation_accuracy. With no schema named the file moves to AP242, as a colour moves it, since AP203's first edition has no entity to state a property with; a named schema that cannot state them throws BuildError rather than writing the file without the figures. A body whose measurement is refused is written without properties, and the file is still written. An assembly file (writeStepAssembly) never carries them. A reader finds them again on the node, under Node.attributes().

step.validation_accuracy (default 1e-5): the relative accuracy each body is measured to for those figures — 1e-5, as Solid.orientedBox()'s own default, not measure.default_accuracy's 1e-7, because 1e-7 costs tens of seconds on a free-form body and a file is a whole model of them. Above 0 and below 1. STEP has no field for an error bound, so the figures written are as good as this and no better: a receiver who wants to compare against a finer figure asks for a finer one here.

tolerance.relative (default 1e-4): the share of a solid's size a verb given no tolerance (0, or none where the language has it) works at, unless the solids declare a looser absolute tolerance — see blacksmith.effectiveTolerance(). Above 0 and below 1.

tolerance.angular (default one degree, in radians): the angle that stands in where nothing declares one. Above 0 and below a right angle.

A name that is not an option, or a value the option does not take, throws BuildError and changes nothing, saying which and what it takes.

blacksmith.option()

function option(name: string): number;

A kernel option's value, by its name: what blacksmith.setOption() last set, else its default (see blacksmith.setOption() for the names). A name that is not an option throws BuildError, listing the ones there are.

blacksmith.brepLayoutId()

function brepLayoutId(): string;

How the loaded kernel lays a brep out in memory: its compiler, target and source. Solid.fromNode() works only where this equals the reader's Brep.layoutId() — both modules on the same release of the library.

blacksmith.libraryPath()

function libraryPath(): string;

Where the kernel library was found: CADACLYSM_BLACKSMITH_LIBRARY first, then as the reader's.

blacksmith.threadSizes()

function threadSizes(): ThreadSize[];

The whole thread size table as ThreadSizes: ISO metric coarse M1 .. M64, ISO metric fine M8x1 .. M64x4, UNC #1 .. 1-1/2", UNF #0 .. 1-1/2", in that order, each by ascending major.

blacksmith.threadSize()

function threadSize(designation: string): ThreadSize;

The ThreadSize designation names: the exact designation first, then forgiven — case and spaces ignored, "M10" the coarse row, "M10x1.25" the fine one, "1/4-20" the UNC or UNF row of that TPI. A designation no row matches throws BuildError.

blacksmith.gearCentreDistanceInvolute()

function gearCentreDistanceInvolute(module: number, teethFirst: number, teethSecond: number, options?: GearCentreDistanceOptions): number;

The centre distance of two involute gears of module, teeth_first and teeth_second teeth, in mesh without backlash: module (z1 + z2) / 2 cos(alpha) / cos(alpha_w), the working angle alpha_w solved from the shifts. null is the default: shifts 0, pressure_angle 20 degrees (radians). A module not positive, fewer than 4 teeth, a pressure angle outside (0, pi/4) or shifts that leave no working angle throws BuildError.

blacksmith.angle()

function angle(a: Point3, vertex: Point3, b: Point3): number;

The angle at vertex between the arms to a and to b, in radians 0 to pi. A point not finite, or an arm of no length, throws BuildError.

blacksmith.effectiveTolerance()

function effectiveTolerance(...solids: Solid[]): number;

The tolerance a verb given none — 0, or none where the language has it — works at over solids: the larger of the loosest absolute tolerance they declare (Solid.tolerances) and tolerance.relative (see blacksmith.setOption()) times the largest of their sizes, never finer than their coordinates can represent. Every verb that takes a distance tolerance (booleans, fillets, shells, splits, sections, hits, meshes, curve fits, profile verbs) reads it so; the wrappers' own defaults (0.05 for a boolean) stay what they are. 0 for no solids, or solids with nothing to size by, which a verb refuses.

blacksmith.boxesApart()

function boxesApart(a: Box, frameA: FrameLike, b: Box, frameB: FrameLike): boolean;

True only if box a at frame_a and box b at frame_b cannot touch — a separating axis among the boxes' face normals and edge-direction crosses; touching is not apart. Sharper than moving each box (Box.move()) and asking Box.overlaps(), which boxes the *result* on the world axes again and so can call two oriented boxes overlapping when they are not (two unit boxes, the second turned 45 degrees about z and moved 2.3 along x: their world boxes overlap, but the boxes themselves do not touch). frame_a or frame_b not twelve finite numbers or not rigid throws BuildError.

blacksmith.clash()

function clash(parts: Iterable<Solid>, others?: Iterable<Solid> | null, clearance?: number, tolerance?: number | null, allowed?: ArrayLike<number>): Clash[];

Every pair of parts — or, with others, every part of parts against every part of others — that penetrates, touches or lies within clearance of the other, as Clash rows, the solids as they stand. It is the question Solid.closest() and Collider.check() leave open: not how far apart two parts are, nor only whether they overlap, but which pairs are in trouble and how. A row's kind is decided in this order: "penetrating" where the volumes overlap; "touching" where the boundaries are within tolerance of each other; "too_close" where they are apart by more than tolerance but less than clearance; "refused" where the pair could not be decided. A pair further apart than clearance gives no row, and with clearance 0 there are no "too_close" rows. tolerance is the meshing tolerance, absolute, in model units (0.05 by default); a distance is exact to within it. In a row a indexes parts and b indexes others (or parts again, when there are no others; then a < b). Rows come in pair order. allowed is pairs of part indices never tested — designed contacts — each exactly two integers; with others a pair is (index in parts, index in others). A negative or non-finite clearance, a tolerance not positive and finite, an allowed pair that is not two indices or one out of range, an empty others, or a part that is not a closed solid throws BuildError; the kernel's own words are prefixed clash:. For the same parts moved pose after pose, build a Collider and ask Collider.clash(). Whether the parts meet on the way from one pose to the next is blacksmith.sweptClash()'s question.

blacksmith.sweptClash()

function sweptClash(parts: Iterable<Solid>, poses: Iterable<Iterable<FrameLike>>, others?: Iterable<Solid> | null, otherPoses?: Iterable<Iterable<FrameLike>> | null, clearance?: number, tolerance?: number | null, resolution?: number, maxSteps?: number, allowed?: ArrayLike<number>): SweptClash[];

Every pair of parts — or, with others, every part of parts against every part of others — that penetrates, touches or comes within clearance of the other anywhere on a path, as SweptClash rows: blacksmith.clash()'s question asked of the motion, not only of the poses. Each part is its own group: pose k of poses is one Frame (or twelve numbers) per part of parts, and pose k of other_poses one per part of others; others and other_poses go together, and the two have as many poses. The motion between poses, the guarantee, resolution and max_steps are Collider.sweptClash()'s; clearance, tolerance (the meshing tolerance, absolute, 0.05 by default) and allowed are blacksmith.clash()'s, and a row's a indexes parts, its b others (or parts again; then a < b). Rows come in pair order. others without other_poses or the other way round, a different number of poses in the two, a pose with the wrong number of frames, an empty set, fewer than two poses, an allowed pair that is not two indices or one out of range, a part that is not a closed solid, or a bad frame, tolerance, clearance, resolution or max_steps throws BuildError; the kernel's own words are prefixed swept_clash:.

blacksmith.thickness()

function thickness(solids: Iterable<Solid>, maximum: number, sharpAngle?: number, tolerance?: number | null): Thickness[];

Every wall-thickness reading within maximum on solids, measured against each other, as Thickness rows by body then vertex: a ThicknessGauge built at tolerance (0.01 by default), asked ThicknessGauge.thickness() once and freed. Build the gauge yourself to ask more than once. maximum not positive and finite, sharp_angle negative or not finite, or a tolerance not positive and finite throws BuildError, with the gauge call's own prefix (thickness_gauge_new:, thickness_gauge_measure:).

blacksmith.meshThickness()

function meshThickness(meshes: Iterable<ThicknessMeshInput>, maximum: number, sharpAngle?: number): MeshThickness[];

The wall-thickness rule on plain meshes, measured against each other, as MeshThickness rows by mesh then vertex. Each of meshes is a pair: its points, (x, y, z) each, and its triangles, three indices into its own points each. From a vertex P the thickness is the distance to the nearest triangle that opposes one of P's own triangles (their normals more than 89 degrees apart) with P on or behind its plane — not a ray cast along the normal. A triangle with a vertex exactly at P is skipped; if one of those meets P's own at an interior angle under sharp_angle radians, P is a knife edge and reads 0. A vertex with no such triangle, or one further than maximum, gives no row: readings are dropped, not clamped. At the sharp rims of faceted holes it can read the wall far too thin (the distance to a neighbouring facet), an open finding. A mesh that is not such a pair, a position not finite, a triangle naming a point past its mesh, maximum not positive and finite, or sharp_angle negative or not finite throws BuildError.

meshThickness(meshes, maximum, sharpAngle): each mesh is a { positions, triangles } object or a [positions, triangles] pair, points as [x, y, z], triangles as three indices; an index must be a whole number from 0 to 4294967295.

blacksmith.closestPoints()

function closestPoints(hay: Iterable<Point3>, needles: Iterable<Point3>, limit: number): number[][];

For each of needles, the indices of the hay points within limit of it, nearest first and equal distances by index — one RTree over hay answers every needle. A point within exactly limit counts. A limit negative or NaN, then the first hay point and the first needle with a NaN or infinite coordinate, by index, throws BuildError.

blacksmith.kNeighbors()

function kNeighbors(hay: Iterable<Point3>, needles: Iterable<Point3>, k: number): number[][];

For each of needles, the indices of the k nearest hay points, nearest first and equal distances by index (the smaller indices win a tie at the k-th place); every hay point when k is over their count. The first hay point and the first needle with a NaN or infinite coordinate, by index, or a k above 1,000,000, throws BuildError.

Profile

class Profile

A closed outline with holes, in its own x/y — what gets extruded, revolved, lofted or swept. Immutable: every method returns a new one.

Its loops must be simple: an outline that crosses or touches itself (a figure-eight, a vertex landing on another side), a hole that runs into the boundary, or two holes that overlap are refused by every call that builds a face or a closed solid, naming the loops — extrude: hole 0 crosses the boundary. The open calls (extrude_open, revolve_open, sweep_open, loft_open) build sheets, and take such a profile as it is.

Profile.rect()

static rect(w: number, h: number): Profile

A w × h rectangle centred on the origin.

Profile.circle()

static circle(r: number): Profile

A circle of radius r about the origin.

Profile.slot()

static slot(centre: Point2, length: number, r: number): Profile

A slot (stadium) length long overall, with end radius r, centred on centre and running along x. length must exceed 2 * r.

Profile.polygon()

static polygon(points: Point2[]): Profile

A closed polygon through the points, in order, its side back to the first point a segment of its own. At least three points.

Profile.regularPolygon()

static regularPolygon(centre: Point2, radius: number, sides: number, angle?: number): Profile

A regular polygon of sides sides (at least 3) on the circle of radius about centre, its first corner at angle radians from the sketch's x axis (0 by default), the rest counter-clockwise. More than a million sides throws BuildError.

Profile.circumscribedPolygon()

static circumscribedPolygon(centre: Point2, radius: number, sides: number, angle?: number): Profile

A regular polygon of sides sides (at least 3) whose sides touch the circle of radius about centre — the polygon across flats, as a nut's hex is specified: its corners on the circle of radius / cos(pi / sides), each side's midpoint on the circle of radius. The first corner is at angle radians from the sketch's x axis (0 by default), the rest counter-clockwise, on the same rays as Profile.regularPolygon()'s corners for the same angle, so the inscribed and circumscribed polygons of one circle nest corner to corner. More than a million sides throws BuildError.

Profile.star()

static star(centre: Point2, outer: number, inner: number, points: number, angle?: number): Profile

A star of points tips (at least 3) on the circle of outer about centre, its inner corners on the circle of inner (positive, under outer), alternating: the first tip at angle radians from the sketch's x axis (0 by default), the rest counter-clockwise, each inner corner half a step on from the tip before it. 2 * points straight sides; an inner not under outer, or more than a million points, throws BuildError.

Profile.text()

static text(text: string, size?: number, font?: string, halign?: 'left' | 'center' | 'right', valign?: 'baseline' | 'bottom' | 'center' | 'top', spacing?: number, direction?: 'ltr' | 'rtl', fontBytes?: Uint8Array | ArrayBuffer | null): Profile[]

text set in a font, one profile per closed shape — a letter with its counters as holes (o one, 8 two; i is two profiles) — on the sketch plane, the baseline along x from the origin, each outline counter-clockwise and its holes clockwise, a curved side the font's own cubic Bezier kept exactly: an extruded O has curved walls, and writes to STEP as splines. size (10 by default) is roughly the height of a capital. font is a family, optionally with a style ("Liberation Sans:style=Bold"), a font file's path, or empty for the bundled Liberation Sans Regular — which also serves when the family is not found, so text never comes back empty; font_bytes a font file's bytes, used instead of font when given (a page or a phone fetches its own font). halign is left (default), center or right; valign baseline (default), bottom, center or top; spacing (1 by default) multiplies the gap between glyphs; direction ltr (default) or rtl. Glyphs are laid out one after another by their advance widths — no shaping, so Latin sets as expected and scripts that need ligatures or reordering do not. Empty text is an empty list. A size or spacing not positive and finite, an alignment or direction not one of those words, or font bytes that are not a font throws BuildError.

Profile.spline()

static spline(points: Point2[], degree?: number, weights?: ArrayLike<number> | null, closed?: boolean): Profile

A spline of degree (3 by default) through the control polygon points, weights one per point or null. Open, it starts on the first point and ends on the last: an open chain, for Solid.extrudeOpen() or Profile.chain(). Closed, it is periodic — smooth through its own start, no corner there — and a closed profile. The degree is lowered to fit the points; a degree of zero, too few points (two open, three closed) or a weight not positive throws BuildError.

Profile.path()

static path(start: Point2): Path

Start drawing an outline segment by segment at start; see Path.

Profile.parabola()

static parabola(vertex: Point2, axis: Point2, focal: number, from: number, to: number): Path

Start drawing on the arc of the parabola with vertex, axis direction axis and focal length focal, over the across-axis coordinates from..to: the path begins at the arc's first point and holds the arc as one conic segment — a reflector from rim to rim; parabola((0, 0), (0, 1), 20, -50, 50) is a dish 100 wide opening up. A zero axis, a focal length not positive and finite, or from not under to throws BuildError.

Profile.chain()

static chain(pieces: Iterable<Profile>, tolerance?: number | null): Profile

Open profiles — paths ended open — joined end to end into one: the forge's merge. They may come in any order and either way round: each next piece is the first of the rest with an end within tolerance (1e-6 by default) of either end of the chain so far, reversed where that makes it meet. Every segment is kept exactly — a line a line, an arc an arc, a spline the same spline. Closed where the chain's two ends meet, otherwise an open chain. A piece that is empty, has holes, is closed on its own or meets none of the others throws BuildError naming it by its index.

Profile.fromLoops()

static fromLoops(loops: Iterable<Profile>): Profile

Closed loops, in any order, as one profile: the loop enclosing the most area is the boundary and every other a hole in it, in the order given — a sketch's rectangle and the circles drawn inside it. Each loop is a closed profile with no holes of its own, wound either way; one that closes within rounding is closed exactly. A loop that is open, empty or encloses no area, loops that cross or touch, a hole outside the boundary, or one inside another hole (an island) throws BuildError, naming the loops by their index.

Profile.closeLoop()

closeLoop(): Profile

This profile closed — the forge's sketch "close": where its last segment stops short of its start (a path ended open), a straight segment back to it; where it already comes back within 1e-9 of its extent, its last segment made to land on the start exactly. A closed profile comes back as it is, and holes are closed the same way.

Profile.polyline()

static polyline(points: Point2[], closed?: boolean): Profile

A polyline through points in order, a straight segment per side: an open chain, or with closed a side from the last point back to the first. A side of no length is kept, so a corner dragged onto its neighbour still draws. Fewer than two points (three closed) throws BuildError.

Profile.arc()

static arc(centre: Point2, r: number, a0: number, a1: number): Profile

The arc of radius r about centre from angle a0 counter-clockwise to a1 (radians from the sketch's x axis): one exact arc, open, the sweep taken the counter-clockwise way round. Equal angles are the whole circle, closed, starting at a0 — a circle anywhere on the sketch. A radius not positive and finite throws BuildError.

Profile.arcThrough()

static arcThrough(start: Point2, through: Point2, end: Point2): Profile

The arc from start through through to end: one exact arc leaving the start, open — the circle through the three points, swept the way round that passes through. Three points in a line throws BuildError.

Profile.gearInvolute()

static gearInvolute(module: number, teeth: number, options?: GearInvoluteOptions): GearProfile

An involute spur gear of teeth teeth of module, tooth 0 centred on the sketch's x axis, as a GearProfile: the flanks NURBS within tolerance of the true involute, the tips, root fillets and root arcs exact — one closed outline that extrudes, cuts and exports as any other. null is the default: pressure_angle 20 degrees (radians), shift 0, addendum 1 and dedendum 1.25 (factors of the module), root_fillet 0.38 module, backlash 0 (taken off this gear's tooth), tolerance 1e-4 module. Undercut is flagged in the report, not drawn. Fewer than 4 teeth, a module not positive, a pressure angle outside (0, pi/4), a pointed tooth or a root fillet that does not fit throws BuildError; blacksmith.gearCentreDistanceInvolute() places its mate.

Profile.gearWheelCycloidal()

static gearWheelCycloidal(module: number, teeth: number, pinionLeaves: number, options?: GearWheelCycloidalOptions): GearProfile

A cycloidal clock wheel of teeth teeth of module driving a pinion of pinion_leaves leaves, tooth 0 centred on the sketch's x axis, as a GearProfile: addendum flanks within tolerance of the true epicycloid rolled by a circle of half the pinion's pitch radius, radial dedendum flanks, fillets and root arcs exact. null is the default: thickness pi module / 2, addendum up to the flanks' crossing with the point rounded, dedendum 1.57 (a factor of the module), root_fillet 0.25 module, tolerance 1e-4 module. The centre distance to the pinion is the two reports' pitch radii added. A pinion of under 6 leaves, a wheel no larger than it, a size not positive or a fillet that does not fit throws BuildError.

Profile.gearPinionCycloidal()

static gearPinionCycloidal(module: number, leaves: number, wheelTeeth: number, options?: GearPinionCycloidalOptions): GearProfile

A cycloidal clock pinion of leaves leaves of module driven by a wheel of wheel_teeth teeth, leaf 0 centred on the sketch's x axis, as a GearProfile: radial flanks inside the pitch circle and a tip "round" (a semicircle of half the leaf thickness) or "ogive" (the epicycloid, truncated at 0.855 module). null is the default: thickness 1.05 module (6 to 10 leaves) or 1.25 module, clearance 0.4 module below the wheel's addendum, root_fillet 0.25 module, tolerance 1e-4 module. Under 6 leaves, a wheel no larger than the pinion, a size not positive, a negative clearance, a tip that is neither or a fillet that does not fit throws BuildError.

Profile.ellipse()

static ellipse(centre: Point2, rx: number, ry: number): Profile

The ellipse about centre with semi-axes rx along x and ry along y, closed: four exact quarter conics, counter-clockwise from the point rx along x. A semi-axis not positive and finite throws BuildError.

Profile.fromBeziers()

static fromBeziers(beziers: ArrayLike<number>, recognise?: boolean): Profile

Rational cubic Béziers end to end as one open profile — sixteen numbers each, x y z w per control point (the point, then its weight), the record Profile.beziers() hands back. With recognise (the default) a straight Bézier becomes an exact line and a circular one an exact arc, so a trim, an extrusion or a fillet meets lines and cylinders; without it every Bézier is kept as the exact cubic it is, and Profile.chain() or Profile.closeLoop() hands the same Béziers back. No Béziers, a number not finite or a weight not positive throws BuildError.

Profile.beziers()

beziers(frame?: ArrayLike<number> | null): Float64Array

This profile as rational cubic Béziers, sixteen numbers each — x y z w per control point, the point and its weight: a line one straight Bézier, an arc exact conic pieces of a quarter turn or less, a free-form side its own decomposition; the outline from its start, then each hole's. On the sketch plane (z = 0), or with frame carried onto that frame's plane — what a page draws a curve with.

Profile.loops()

static loops(pieces: Iterable<Profile>, tolerance?: number | null): number[][]

The closed loops among pieces, each read by its two ends, the way a CAD sketch finds them: ends meet within tolerance; a loop is a chain of pieces through corners where exactly two ends meet (a corner of three or more is ambiguous, and no loop runs through it); a piece whose own ends meet, a closed one included, is a loop of its own. Each loop is its pieces' indices in the order it runs, from its lowest; each piece is in at most one. A piece with holes or nothing drawn throws BuildError.

Profile.chainOrder()

static chainOrder(pieces: Iterable<Profile>, tolerance?: number | null): Array<[number, boolean]>

The order Profile.chain() takes pieces in, from the chain's start to its end: per piece its index and whether it was turned round to meet — what reorders a sketch's own curve list to match the chained profile. Refused as Profile.chain() is.

Profile.fromPieces()

static fromPieces(pieces: string | Iterable<Record<string, unknown>>, closed?: boolean, tolerance?: number | null): Profile

A profile from piece definitions in the curve.polycurve grammar — a line {kind, x0, y0, x1, y1}, an arc through xm, ym, a circle, an ellipse, a rect, a polygon, a polyline or a spline — each made exact, put in chain order and turned to run on, joined where ends meet within tolerance (none: the pieces' effective tolerance). Closed where the chain's ends meet, or with a closing side when closed asks. What Profile.piecesJson() writes reads back to the same profile. A piece it cannot read, or pieces that do not chain, throws BuildError, naming the piece by index.

pieces an array of objects or their JSON text.

Profile.piecesJson()

piecesJson(): Array<Record<string, any>>

This profile's outline as piece definitions, one per segment from its start: a line {x0, y0, x1, y1}, an arc {x0, y0, xm, ym, x1, y1} through its middle (a whole circle as two halves), anything else a cubic spline piece per Bézier — what an app stores and edits, and what Profile.fromPieces() reads back. A profile with holes throws BuildError.

Parsed: an array of objects.

Profile.filletCorner()

static filletCorner(a: Profile, b: Profile, radius: number, tolerance?: number | null): { a: Array<Record<string, any>>; b: Array<Record<string, any>>; arc: Record<string, any> }

A sketch fillet between two open profiles that meet at an end, within tolerance: both cut back to the tangent points, each still running the way it ran, and the arc from the first's side to the second's, all as pieces Profile.fromPieces() reads — {a, b, arc}. Profiles that do not meet at an end, run straight on or fold back, or a radius that does not fit, throws BuildError.

Parsed: an object.

Profile.bounds()

bounds(): [number, number, number, number]

The exact box of this profile in its sketch — min x, min y, max x, max y — over the outline and the holes, from the curves' own extremes rather than their control points: an arc's bulge is in it, a spline's control polygon is not.

Profile.reversed()

reversed(): Profile

This profile walked the other way, as a new one: its end the new start, its segments in reverse order, each turned round; each hole turned round in place. Twice is the profile.

Profile.pieces()

pieces(cutters: Iterable<Profile>, tolerance?: number | null): Profile[]

This curve cut where the cutters cross, touch or run along it — the sketch trim's pieces: in order along the curve from its start, each an open profile of portions of this one's own segments (a line's stretch a line, an arc's an arc, a spline's the same spline over part of its domain, nothing refitted). One piece, this curve, where nothing cuts it; a closed curve's piece round its start is one piece. Cuts closer than tolerance to each other fold onto one. A curve with no segments throws BuildError.

Profile.trim()

trim(cutters: Iterable<Profile>, piece: number, tolerance?: number | null): Profile[]

This curve with piece piece of Profile.pieces() taken away — the sketch trim, the forge's: what is left, as open profiles. One for a closed curve (its other pieces run together from where the removed one ended), the stretches before and after for an open one, none where the piece was the whole curve. A piece the curve does not have throws BuildError.

Profile.withHole()

withHole(hole: Profile): Profile

This outline with hole cut out of it.

Profile.hits()

hits(other: Profile, tolerance?: number | null): Hit[]

Where this outline's curves cross, touch or run along other's, both read in one plane, as Hit values ordered along this outline. Points closer than tolerance merge; two curves within tolerance of each other for longer than it are one run when they part only where one of them ends or the stretch is flat — one curve following the other, offset within tolerance or tilted by under about half of it, even where it leaves mid-both; a tangency or a shallow crossing is one point. A loop that stops short of its start is an open chain, its closing side not tested.

Profile.common()

common(other: Profile, tolerance?: number | null): Profile[]

The region this outline and other share, both read in one plane, as a list of zero or more profiles — each boundary counter-clockwise, each hole clockwise, arcs and splines kept exact. An arc kept from an input can still come out split at that input's own seam point (two circles' lens is four arcs, one pair per circle) — exact, not an approximation. Two loops of a result may touch at a point (two holes whose corners meet, one from each input): a right point set that the verbs needing simple loops — Solid.extrude(), a boolean taking it as an input — refuse. Both must be closed and simple; no shared area is an empty list. A tolerance not positive and finite, an outline open or crossing itself, a tolerance too fine for these outlines (following their arcs and splines to a tenth of it would take more than 8 million points, about 128 MB), and, as a defect rather than an outcome, a result that fails to close, throws BuildError.

Profile.translate()

translate(dx: number, dy: number): Profile

This outline moved by (dx, dy).

Profile.rotate()

rotate(centre: Point2, radians: number): Profile

This outline turned radians (counter-clockwise) about centre.

Profile.scale()

scale(centre: Point2, sx: number, sy: number): Profile

This outline scaled by sx, sy about centre. An arc stays an arc where the two are equal in size, and becomes exact conics (rational quadratics) otherwise; a negative factor mirrors across that axis, and a zero one throws BuildError.

Profile.mirror()

mirror(point: Point2, direction: Point2): Profile

This outline reflected across the line through point along direction; each arc's sense turns. A zero direction throws BuildError.

Profile.transform2d()

transform2d(m: ArrayLike<number>): Profile

This outline under the 2D affine map m, six numbers row-major (2×3): x' = m0·x + m1·y + m2, y' = m3·x + m4·y + m5. Lines, Béziers, conics and NURBS map by their points, exactly; a singular map throws BuildError.

Profile.coloured()

coloured(colour: string | Iterable<number>): Profile

A new outline coloured (r, g, b), each 0..1, "#rgb", "#rrggbb" or a CSS colour name ("tomato", "RebeccaPurple"): how it is drawn. The verbs that make a profile from one carry it (translate, round, with_hole keeps the outer's, chain and from_loops the first's); a solid made from it takes nothing — colour a solid with Solid.coloured().

Profile.colour

readonly colour: [number, number, number] | null

The outline's colour as (r, g, b), or none.

Profile.round()

round(radius: number, corners?: Iterable<number> | null, open?: boolean): Profile

This outline with its corners rounded by radius: at each corner both segments are cut back — lines, arcs and splines alike, each staying the curve it was — and an exact arc tangent to both goes between them. A corner the two run straight on through is no corner. With no corners every corner is rounded, the holes' too; a list picks corners of the outline — corner k is where segment k ends, and a picked corner that runs straight on is refused. open reads the profile as an open chain whose two ends stay square. A radius that does not fit throws BuildError naming the corner.

Profile.toArcs()

toArcs(tolerance?: number | null): Profile

This profile with every free-form side (a Bezier, a conic, a NURBS) replaced by lines and arcs within tolerance of it — what a G-code writer can say. Lines and arcs pass through as they are, every loop closes on itself exactly, holes are converted the same way. tolerance (0.01 by default) not positive and finite, or a spline that does not evaluate, throws BuildError.

Profile.offset()

offset(distance: number, tolerance?: number | null, corner?: OffsetCorner): Profile[]

This profile grown by distance (shrunk where it is negative), as zero or more profiles, all lines and arcs: outward corners rounded by |distance|, holes moving against the boundary (a hole shrinks as the profile grows). Free-form sides are fitted to tolerance first (Profile.toArcs()). A shrink that eats the whole profile is an empty list. corner styles every corner where the moved sides part: round (the arc about the corner, the default), sharp (the sides extended along their tangents until they meet; chamfered past a miter of 100 times the distance), smooth (the parabola tangent to both sides, an exact conic) or chamfer (a line across). A distance not finite, a tolerance (0.01 by default) not positive and finite, a loop with no sides, loops that cross or touch, or another style, throws BuildError.

Profile.offsetOpen()

offsetOpen(distance: number, tolerance?: number | null, corner?: OffsetCorner, end?: OffsetEnd): Profile[]

This profile read as an open chain (its implicit closing side and holes ignored), offset by distance. With no end style: the one-sided offset, open chains moved distance to the right of travel (negative, the left), the overlaps at inside corners trimmed. Ends flat or round: the closed outline both sides at |distance|, each end capped by a line across or a half circle. corner styles the joins as Profile.offset() does. A distance not finite (or 0 with ends), a chain with no sides, or another style, throws BuildError.

Profile.union()

union(other: Profile, tolerance?: number | null): Profile[]

The region this outline or other covers, both read in one plane, as zero or more profiles — each boundary counter-clockwise, each hole clockwise, arcs and splines kept exact. Both must be closed and simple; refused as Profile.common() is.

Profile.difference()

difference(other: Profile, tolerance?: number | null): Profile[]

The region of this outline that other does not cover, as zero or more profiles, exact as Profile.union(); refused as Profile.common() is.

Profile.regions()

static regions(profiles: Iterable<Profile>, tolerance?: number | null): Profile[]

Every region the closed profiles split the plane into, each once, exact: two overlapping squares are three regions. Which inputs hold a region: those it Profile.relationship()s as inside or equal. A boolean's refusal throws BuildError naming the input.

Profile.contains()

contains(point: Point2, tolerance?: number | null): ProfileContainment

Where point lies against this closed outline: on within tolerance of any loop (holes included; the distance exact to lines, arcs and splines), else inside or outside by the even-odd rule. An open chain is read closed by its implicit side. A profile with no segments or a point not finite throws BuildError.

Profile.relationship()

relationship(other: Profile, tolerance?: number | null): ProfileRelation

How this closed outline's region stands to other's: disjoint (no point in common), touching (the boundaries meet, the interiors do not overlap), overlapping (the interiors overlap and neither holds the other), a inside b (this one inside other), b inside a, or equal (one region, to the tolerance). An input open or crossing itself throws BuildError.

Profile.deviation()

deviation(other: Profile, tolerance?: number | null): Deviation

The largest and smallest distance between this outline and other's (every loop), both ways round, with the two points of each: a Deviation. Every figure within tolerance of the true one. A profile with no segments or a spline that does not evaluate throws BuildError.

Profile.reduceSegments()

reduceSegments(tolerance?: number | null, open?: boolean): Profile

This outline with every run of consecutive straight segments simplified by Douglas–Peucker within tolerance: a vertex goes where the run stays within tolerance of it. Arcs, splines and the ends of every run are kept. open reads it as an open chain.

Profile.mergeColinear()

mergeColinear(angleTolerance?: number, open?: boolean, includeSeam?: boolean): Profile

This outline with neighbouring segments that are one curve made one: two lines turning less than angle_tolerance radians, two arcs on one circle turning one way (never a full circle). include_seam merges a closed loop's last and first segments too. An angle outside [0, pi) throws BuildError.

Profile.breakAtKinks()

breakAtKinks(angle: number, open?: boolean): Profile[]

The outer loop cut into open pieces wherever the direction of travel turns by more than angle radians at a joint. A closed loop with no kink comes back whole; with kinks, as open pieces starting at its first. An angle outside [0, pi] or no segments throws BuildError.

Profile.isConvex()

isConvex(strict?: boolean): boolean

Whether this closed outline is convex: no holes, and its outer loop turns one way only (every joint, arc and spline) through one full turn. strict also refuses a joint between two lines that does not turn.

Profile.makeClosed()

makeClosed(tolerance?: number | null): Profile

This open chain closed by moving its end onto its start where the two are within tolerance: a line's end moves, an arc's centre moves onto the bisector of its new chord, a Bézier's end moves with its last inner control point, a spline's last control point moves. A wider gap, or a chain that closed would enclose nothing, throws BuildError.

Profile.withSeam()

withSeam(point: Point2): Profile

This closed outline with its outer loop restarted at its point nearest point: the segment there split exactly and the loop rotated; a point at a joint rotates it without a split. Holes kept.

Profile.documentPath()

documentPath(): { [key: string]: any }

This profile as its exact segments, as a Document's profile.path node holds it: a record of its start, its segments (each a line, arc, bezier, conic or nurbs with its points, weights and knots, never flattened), its holes and its colour. What Document.addProfile() puts in a document.

Profile.polylines()

polylines(tolerance?: number | null): Float32Array[]

The outline, then each hole, as polylines at z = 0 within tolerance of its arcs and splines — what a viewer draws it with. A closed loop repeats its first point at the end; an open chain (a profile ended open) stays open. Views, like Solid.mesh() — copies in Node, Godot and Python.

Profile.show

Draw the outline and holes with the viewer in use, from the top by default. Keywords as Solid.show(); edges= is ignored, the lines being the whole picture. With the GPU library (import cadaclysm.view.wgpu) the drawing replaces what one shared window shows and stays live — at the REPL, in IPython and in Jupyter by themselves, in a script until it exits; cadaclysm.view.View draws several items or several windows.

Comes with the viewers follow-up.

Profile.view

Orbit the outline with the viewer in use; returns the camera where it was left — a dict of eye, target, up, orthographic, azimuth and elevation — and pick, what was last clicked (item, node, face) or None. A fresh window, run until closed, with the GPU library.

Comes with the viewers follow-up.

Profile.svg()

svg(path: string, options?: SvgOptions): void

This profile's own loops as SVG: a line a line, an arc an arc, a spline the NURBS' own Béziers — exact curves, nothing flattened to the polyline Profile.polylines() samples. The keywords are blacksmith.writeSvg()'s own, except view= defaults to top here rather than iso: a profile lies in z = 0, so its own plane is already the page and it reads flat and true. In the languages whose options are a struct (view already iso, not nullable), that default holds only when no options value is passed at all — pass one for anything else and its own view applies. With path, writes the file and returns null; without, returns the SVG text. throws BuildError on a refused option or a failed write.

Profile.length()

length(accuracy?: number): Length

The perimeter of the outer loop — holes are not counted — as a Length: its exact curves measured to the relative accuracy, 0 asking for measure.default_accuracy (see blacksmith.setOption()). An accuracy of NaN, infinite or 1 or more throws BuildError.

Profile.areaProperties()

areaProperties(accuracy?: number | null): AreaProperties

The region's area properties in the profile's own plane, as an AreaProperties: the outer loop less its holes, whatever their winding — Fusion's Profile.areaProperties, Rhino's AreaMassProperties of closed planar curves. Lines and arcs in closed form, polynomial splines exactly, rational ones to the relative accuracy (none or 0: 1e-9). An accuracy outside (0, 1), or a hole with holes of its own, throws BuildError.

Profile.pointAtLength()

pointAtLength(s: number, accuracy?: number): At

The point at arc length s along the outer loop, as an At: s is absolute, measured from the loop's start, and lies in [0, length] (see Profile.length()) — past either end by no more than the length's own error is that end, further throws BuildError. The sample names its side in segment, and parameter is that side's own: a line's 0 to 1, an arc's angle about its centre (a clockwise arc's angle decreasing along it), a spline's parameter. accuracy is relative, 0 or less asking for measure.default_accuracy; NaN, infinite or 1 or more throws BuildError.

Profile.divideByCount()

divideByCount(n: number, accuracy?: number): At[]

The outer loop in n pieces of equal arc length, as a list of At: a profile is closed, so n samples from its start, never the start again. n is 1 to 1,000,000; accuracy as Profile.pointAtLength().

Profile.divideByLength()

divideByLength(step: number, accuracy?: number): At[]

Samples of the outer loop every step of arc length from its start, as a list of At: the last piece is whatever is left over, kept short, and the start is never repeated. step is positive and finite and may give at most 999,999 steps; accuracy as Profile.pointAtLength().

Path

class Path

An outline drawn a segment at a time — lines, arcs, Béziers, NURBS — then closed into a Profile. Ending it consumes the builder.

Path.lineTo()

lineTo(x: number, y: number): this

A straight segment to (x, y).

Path.arcTo()

arcTo(x: number, y: number, centre: Point2, ccw?: boolean): this

A circular arc to (x, y) about centre, counter-clockwise unless ccw is false.

Path.bezierTo()

bezierTo(c1: Point2, c2: Point2, to: Point2): this

A cubic Bézier through control points c1, c2 to to.

Path.conicTo()

conicTo(x: number, y: number, control: Point2, weight: number): Path

A conic arc to (x, y) through the control point control with middle weight: under 1 an elliptical arc, 1 a parabola, over 1 a hyperbola — the rational quadratic Bézier, kept exact. A weight not positive and finite, an end on the current point, or a control point on the chord throws BuildError.

Path.parabolaTo()

parabolaTo(x: number, y: number, control: Point2): Path

A parabolic arc to (x, y) whose end tangents meet at control: Path.conicTo() with weight 1.

Path.hyperbolaTo()

hyperbolaTo(x: number, y: number, control: Point2, weight: number): Path

A hyperbolic arc to (x, y) through control with middle weight over 1; a weight of 1 or under throws BuildError.

Path.parabolaByVertex()

parabolaByVertex(x: number, y: number, vertex: Point2): Path

The parabolic arc to (x, y) whose vertex is vertex: the axis and focal length are solved from the two ends. A vertex on the chord, or one no parabola through both ends has (the vertex must be the arc's extreme point), throws BuildError.

Path.parabolaByFocus()

parabolaByFocus(x: number, y: number, focus: Point2): Path

The parabolic arc to (x, y) whose focus is focus: of the two parabolas through the ends with that focus, the one whose vertex lies between the ends' projections, then the one whose arc cups the focus (the focus between the arc and its chord), then the more symmetric; with the focus beyond the chord that is the arch over the ends, not the shallow dish — draw that one with Profile.parabola(). A focus on the chord throws BuildError.

Path.nurbsTo()

nurbsTo(control: Point2[], knots: ArrayLike<number>, degree: number, weights?: ArrayLike<number> | null): this

A NURBS segment: control is every control point after the current one, the endpoint last; knots the full knot vector; weights one per control point including the current one, or null for a non-rational curve.

Path.end()

end(): Profile

Close the outline back to its start and return the Profile.

Path.endOpen()

endOpen(): Profile

The path as it stands, not closed: an open chain for Solid.extrudeOpen(), Solid.sweepOpen() or Solid.loftOpen().

SweepPath

class SweepPath

The 3D path a profile is carried along by Solid.sweep(): lines and circular arcs. Sweeping only borrows it, so one path can be swept many times; close it when done.

SweepPath.at()

static at(point: Point3): SweepPath

Start a path at a 3D point.

SweepPath.along()

static along(curve: Profile, frame: FrameLike, tolerance?: number | null, open?: boolean): SweepPath

The path a 2D chain (usually from Path.endOpen()) draws on frame: a line a straight piece, an arc a circular one, a Bézier or spline fitted with biarcs — arcs tangent to each other and to the curve — within tolerance, so the path is tangent throughout and the sweep exact along it. open false closes the path back to its start.

SweepPath.lineTo()

lineTo(point: Point3): this

A straight piece to a 3D point.

SweepPath.arc()

arc(centre: Point3, axis: Point3, angle: number): this

Turn angle radians (in (0, 2π]) about the axis through centre along axis.

SweepPath.close()

close(): void

Free the path.

Slant

class Slant

A plane a Solid.extrudeBetween() starts or ends on, read as a height over the sketch plane at each point: at + grad · (x, y). Flat for an ordinary cap; sloped for a mitre.

Slant.at

readonly at: number

The height at the sketch origin.

Slant.grad

readonly grad: readonly [number, number]

The slope in x and y.

Slant.flat()

static flat(at: number): Slant

A flat plane at height at.

Slant.ofPlane()

static ofPlane(frame: FrameLike, point: Point3, normal: Point3): Slant

The plane through point square to normal, as heights over frame. A plane that contains the extrusion direction has no height and throws BuildError.

Frame

class Frame implements Iterable<number>

A frame built for you instead of twelve numbers typed out: an origin and three unit axes, square to each other and right-handed (z = x × y). It goes wherever a frame does. Immutable. The constructor takes the origin and the three axes, normalises them, and throws BuildError when they are not square or not right-handed.

Frame.xy()

static xy(origin?: Point3): Frame

The world XY plane through origin: z up, as Workplane.xy().

Frame.xz()

static xz(origin?: Point3): Frame

The world XZ plane through origin: x along X, y along Z, so z is -Y, as Workplane.xz().

Frame.yz()

static yz(origin?: Point3): Frame

The world YZ plane through origin: x along Y, y along Z, so z is +X, as Workplane.yz().

Frame.at()

static at(origin: Point3, normal: Point3, x?: Point3 | null): Frame

The plane through origin square to normal, which becomes the frame's z (it need not be unit). Its x axis is x laid onto that plane; with none, world X laid onto it, or world Y when the normal is within about 25° of X — the axes Solid.faceFrame() gives a face facing normal. So a normal along +Z, -Y or +X gives exactly Frame.xy(), Frame.xz() or Frame.yz(). A zero normal, or an x along the normal, throws BuildError.

Frame.of()

static of(frame: FrameLike): Frame

Twelve numbers — what Solid.faceFrame() and Workplane.frame hand back — as a checked frame, to read its axes or move it.

Frame.midplane()

static midplane(a: FrameLike, b: FrameLike): Frame

The plane midway between the planes of frames a and b: for parallel planes the one halfway between, on a's axes; for planes that meet, the plane bisecting them through the line they meet on, its x along that line.

Frame.through()

static through(p: Point3, q: Point3, r: Point3): Frame

The plane through the points p, q and r: its origin p, its x towards q, its z the normal the three turn about counter-clockwise. Three points on one line throws BuildError.

Frame.origin

readonly origin: number[]
readonly x: number[]
readonly y: number[]
readonly z: number[]

The origin and the three axes, each three numbers.

Frame.translate()

translate(dx: number, dy: number, dz: number): Frame

This frame moved by (dx, dy, dz) in world coordinates.

Frame.offset()

offset(distance: number): Frame

This frame moved distance along its own z: Frame.xy().offset(5) is the XY plane at z = 5.

Frame.fit()

static fit(points: Iterable<Point3>): { frame: Frame; deviation: number }

The least-squares plane through points (three or more, not all on one line) as a frame, and the largest distance any point lies off it: (frame, deviation). Fewer points, or points on one line, throws BuildError.

Frame.flip()

flip(): Frame

The same plane facing the other way: x and y swapped, z reversed.

Frame.rotate()

rotate(radians: number, axis: Point3): Frame

This frame turned radians about axis through its origin, right-handed.

Frame.toLocal()

toLocal(p: Point3): number[]

The point p in this frame's coordinates.

Frame.closestPoint()

closestPoint(p: Point3): number[]

The point p dropped onto the frame's plane along its z.

Frame.distanceTo()

distanceTo(p: Point3): number

How far p lies above the frame's plane, along its z: negative below.

Transform

class Transform implements Iterable<number>

An affine map of space: a 4×4 matrix, row-major, its bottom row 0 0 0 1 (a projective one throws BuildError). Immutable, with nothing to free; it iterates as its 16 numbers. a @ b is a after b. The constructors and decompositions are the library's own, so every language computes them alike. A frame argument is a Frame or 12 numbers: one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError.

Transform.fromRows()

static fromRows(rows: MatrixLike): Transform

The map 16 numbers state, row-major, or four rows of four.

Transform.identity()

static identity(): Transform

The map that moves nothing.

Transform.translation()

static translation(v: Point3): Transform

p + v.

Transform.rotation()

static rotation(point: Point3, direction: Point3, radians: number): Transform

A turn of radians about the line through point along direction, right-handed.

Transform.mirror()

static mirror(plane: FrameLike): Transform

The reflection across plane, its z the normal.

Transform.scale()

static scale(centre: Point3, k: number): Transform

A uniform scale by k about centre.

Transform.scaleXyz()

static scaleXyz(frame: FrameLike, sx: number, sy: number, sz: number): Transform

A scale by sx, sy, sz along frame's axes, about its origin.

Transform.shear()

static shear(plane: FrameLike, direction: Point3, factor: number): Transform

Every point slid along direction by factor times its height above plane. direction is normalised, so factor alone sets the slide; one off the plane throws BuildError.

Transform.planeToPlane()

static planeToPlane(a: FrameLike, b: FrameLike): Transform

The rigid map sending frame a onto frame b.

Transform.changeBasis()

static changeBasis(from: FrameLike, to: FrameLike): Transform

Coordinates in frame from_ to coordinates in frame to.

Transform.planarProjection()

static planarProjection(plane: FrameLike): Transform

The orthogonal projection onto plane (singular by design).

Transform.projectAlong()

static projectAlong(plane: FrameLike, direction: Point3): Transform

The parallel projection onto plane along direction; a direction in the plane throws BuildError.

Transform.rows

readonly rows: number[]

The 16 numbers, row-major.

Transform.point()

point(p: Point3): [number, number, number]

Where the map takes the point p.

Transform.inverse()

inverse(): Transform

The map undoing this one; a singular map throws BuildError.

Transform.isRigid()

isRigid(tolerance?: number): boolean

Whether the linear part is orthogonal (AᵀA = I to tolerance, 1e-9 by default): a rotation or a mirror.

Transform.isSimilarity()

isSimilarity(tolerance?: number): number | null

The scale k where the linear part is k times an orthogonal one (to tolerance, relative to k²); null otherwise.

Transform.decomposeRigid()

decomposeRigid(tolerance?: number): { translation: number[]; orthogonal: Transform } | null

(translation, orthogonal part) for a rigid map; null otherwise.

Transform.decomposeSimilarity()

decomposeSimilarity(tolerance?: number): { translation: number[]; orthogonal: Transform; k: number } | null

(translation, orthogonal part, k) for a similarity; null otherwise.

Transform.decomposeAffine()

decomposeAffine(): { translation: number[]; rotation: Transform; axes: Transform; stretch: number[] } | null

(translation, rotation, axes, stretch) with the linear part rotation · axes · diag(stretch) · axesᵀ: rotation carries the mirror, axes is a proper rotation whose columns are the stretch directions, the stretches come largest first. null for a singular map, or one stretched past 1e7:1.

Quaternion

class Quaternion implements Iterable<number>

A rotation as w + xi + yj + zk. Immutable; it iterates as w, x, y, z. q and -q are the same rotation; a non-unit one is normalised where it becomes a rotation, and a zero one throws BuildError there. a * b turns by b, then by a.

Quaternion.fromAxisAngle()

static fromAxisAngle(direction: Point3, radians: number): Quaternion

The turn of radians about direction, right-handed.

Quaternion.fromTransform()

static fromTransform(t: Transform | MatrixLike): Quaternion

The rotation in t's linear part (its translation ignored); anything but a proper rotation throws BuildError.

Quaternion.slerp()

static slerp(a: Quaternion, b: Quaternion, s: number): Quaternion

From a (s = 0) to b (s = 1) along the shorter arc.

Quaternion.toTransform()

toTransform(centre?: Point3): Transform

This rotation as a Transform fixing centre.

Quaternion.w

readonly w: number
readonly x: number
readonly y: number
readonly z: number

The four numbers.

Quaternion.length

readonly length: number

Its length; 1 for a rotation as made here.

Quaternion.angle

readonly angle: number

The turn, in [0, 2π].

Quaternion.axis

readonly axis: [number, number, number] | null

The turn's axis; null for the identity.

Quaternion.conjugate()

conjugate(): Quaternion

The opposite turn.

Quaternion.normalize()

normalize(): Quaternion

This quaternion at length 1; a zero one throws BuildError.

Interval

class Interval implements Iterable<number>

A parameter range t0..t1, in either order: length and swapped keep the order, the set operations (grown, union, intersect) answer increasing. Immutable and hashable; it iterates as (t0, t1), so two numbers go wherever an Interval does. The values' angle and height ranges and the surfaces' domains are intervals.

Interval.of()

static of(value: IntervalLike): Interval

An Interval, or two numbers, as an Interval; any other count throws BuildError.

Interval.t0

readonly t0: number
readonly t1: number

The two ends, as given.

Interval.length

readonly length: number

t1 - t0: negative for a decreasing interval.

Interval.mid

readonly mid: number

The middle, (t0 + t1) / 2.

Interval.min

readonly min: number
readonly max: number

The smaller and the larger end.

Interval.isIncreasing

readonly isIncreasing: boolean

Whether t0 < t1.

Interval.isSingleton

readonly isSingleton: boolean

Whether t0 == t1.

Interval.swap()

swap(): Interval

The interval t1..t0.

Interval.grown()

grown(t: number): Interval

The increasing interval holding this one and t.

Interval.union()

union(o: IntervalLike): Interval

The increasing interval holding this one and o.

Interval.intersect()

intersect(o: IntervalLike): Interval | null

The increasing overlap with o; null where the two are apart. Two that touch give a singleton.

Interval.contains()

contains(t: number): boolean

Whether t lies in the closed range, in either order.

Interval.parameterAt()

parameterAt(s: number): number

t0 + s (t1 - t0): the fraction s of the way from t0; outside 0..1 extrapolates.

Interval.normalizedParameterAt()

normalizedParameterAt(t: number): number | null

The fraction of the way t lies from t0 toward t1; null for a singleton.

Tolerances

interface Tolerances

What a solid declares about its own precision, as a named tuple: absolute, a length in the model's own units, and angular, in radians — each none where nothing declared it. What Solid.tolerances returns.

CurveFoot

class CurveFoot

The closest point of a curve value, as a named tuple: its parameter t, the point, and unique — false where several points lie equally near and point is a fixed pick among them (a point on a circle's axis, one equidistant from an arc's ends).

SurfaceFoot

class SurfaceFoot

The closest point of a surface value, as a named tuple: its parameters u, v, the point, and unique — false where several points lie equally near and point is a fixed pick among them (a sphere's centre, a point on an axis).

Line

class Line implements Iterable<number>

The segment from start to end, as a value: a piece of construction geometry to measure, to project onto and to map, without building a solid. Its parameter runs 0..1. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Line.start

readonly start: number[]
readonly end: number[]

The two ends.

Line.pointAt()

pointAt(t: number): number[]

The point at t: the fraction t of the way from start to end (0..1 spans the segment).

Line.tangentAt()

tangentAt(t: number): number[]

The unit tangent at t, the way t grows.

Line.length()

length(): number

The length.

Line.closestPoint()

closestPoint(p: Point3): CurveFoot

The CurveFoot nearest p: its parameter t, the point and unique. Exact for every kind, in closed form rather than by iteration. unique is false where several points lie equally near and the answer is a fixed pick among them — a point on a circle's axis, one equidistant from an arc's two ends; true otherwise.

Line.distanceTo()

distanceTo(p: Point3): number

How far p lies from the curve: the distance to its closest_point.

Line.toNurbs()

toNurbs(): NurbsCurve

The curve as its exact NurbsCurve (a conic as a rational quadratic).

Line.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Line.transform()

transform(t: Transform | MatrixLike): Line

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Circle

class Circle implements Iterable<number>

The circle of radius about the frame's origin in its x-y plane, running counter-clockwise about its z from its x, as a value. Curve's value gives an edge's circle. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Circle.through()

static through(a: Point3, b: Point3, c: Point3): Circle

The circle through the points a, b and c: its x toward a, turning a, b, c counter-clockwise. Three points on one line throws BuildError.

Circle.radius

readonly radius: number

The radius.

Circle.pointAt()

pointAt(t: number): number[]

The point at t: t the angle in radians from the frame's x toward its y.

Circle.tangentAt()

tangentAt(t: number): number[]

The unit tangent at t, the way t grows.

Circle.length()

length(): number

The length.

Circle.closestPoint()

closestPoint(p: Point3): CurveFoot

The CurveFoot nearest p: its parameter t, the point and unique. Exact for every kind, in closed form rather than by iteration. unique is false where several points lie equally near and the answer is a fixed pick among them — a point on a circle's axis, one equidistant from an arc's two ends; true otherwise.

Circle.distanceTo()

distanceTo(p: Point3): number

How far p lies from the curve: the distance to its closest_point.

Circle.toNurbs()

toNurbs(): NurbsCurve

The curve as its exact NurbsCurve (a conic as a rational quadratic).

Circle.frame

readonly frame: Frame

The Frame the value is placed on.

Circle.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Circle.transform()

transform(t: Transform | MatrixLike): Circle

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Arc

class Arc implements Iterable<number>

The part of a circle over angle (an Interval or two numbers, increasing, by at most a full turn), as a value: the circle's frame and radius, its angles measured from the frame's x toward its y. Curve's value gives an edge's arc. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Arc.through()

static through(a: Point3, b: Point3, c: Point3): Arc

The arc from a through b to c. Three points on one line throws BuildError.

Arc.fromStartTangentEnd()

static fromStartTangentEnd(a: Point3, tangent: Point3, c: Point3): Arc

The arc leaving a along tangent and ending at c. A zero tangent, or a c on the tangent's line, throws BuildError.

Arc.radius

readonly radius: number

The radius.

Arc.angle

readonly angle: Interval

The angle range, an Interval.

Arc.start

readonly start: number[]
readonly end: number[]
readonly mid: number[]

The points at the start, the end and halfway along.

Arc.pointAt()

pointAt(t: number): number[]

The point at t: t the angle in radians from the frame's x toward its y.

Arc.tangentAt()

tangentAt(t: number): number[]

The unit tangent at t, the way t grows.

Arc.length()

length(): number

The length.

Arc.closestPoint()

closestPoint(p: Point3): CurveFoot

The CurveFoot nearest p: its parameter t, the point and unique. Exact for every kind, in closed form rather than by iteration. unique is false where several points lie equally near and the answer is a fixed pick among them — a point on a circle's axis, one equidistant from an arc's two ends; true otherwise.

Arc.distanceTo()

distanceTo(p: Point3): number

How far p lies from the curve: the distance to its closest_point.

Arc.toNurbs()

toNurbs(): NurbsCurve

The curve as its exact NurbsCurve (a conic as a rational quadratic).

Arc.frame

readonly frame: Frame

The Frame the value is placed on.

Arc.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Arc.transform()

transform(t: Transform | MatrixLike): Arc

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Ellipse

class Ellipse implements Iterable<number>

The ellipse of radius r1 along the frame's x and r2 along its y, as a value. Unlike a circle it takes any affine map that keeps it an ellipse. Curve's value gives an edge's whole ellipse (an elliptical arc's range stays on the Curve). Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Ellipse.fromCircle()

static fromCircle(circle: Circle): Ellipse

circle as an ellipse of two equal radii, to map by a non-uniform scale or a shear.

Ellipse.r1

readonly r1: number
readonly r2: number

The radii along the frame's x and y.

Ellipse.pointAt()

pointAt(t: number): number[]

The point at t: t the eccentric angle in radians, from the frame's x toward its y.

Ellipse.tangentAt()

tangentAt(t: number): number[]

The unit tangent at t, the way t grows.

Ellipse.length()

length(): number

The perimeter, in closed form.

Ellipse.closestPoint()

closestPoint(p: Point3): CurveFoot

The CurveFoot nearest p: its parameter t, the point and unique. Exact for every kind, in closed form rather than by iteration. unique is false where several points lie equally near and the answer is a fixed pick among them — a point on a circle's axis, one equidistant from an arc's two ends; true otherwise.

Ellipse.distanceTo()

distanceTo(p: Point3): number

How far p lies from the curve: the distance to its closest_point.

Ellipse.toNurbs()

toNurbs(): NurbsCurve

The curve as its exact NurbsCurve (a conic as a rational quadratic).

Ellipse.frame

readonly frame: Frame

The Frame the value is placed on.

Ellipse.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Ellipse.transform()

transform(t: Transform | MatrixLike): Ellipse

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Sphere

class Sphere implements Iterable<number>

The sphere of radius about the frame's origin, as a value: u the longitude from the frame's x, v the latitude toward its z. Measure it, project onto it, test points against it, or make it a solid with to_solid. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Sphere.radius

readonly radius: number

The radius.

Sphere.pointAt()

pointAt(u: number, v: number): number[]

The point at (u, v), in the ranges domain gives.

Sphere.normalAt()

normalAt(u: number, v: number): number[]

The outward unit normal at (u, v).

Sphere.closestPoint()

closestPoint(p: Point3): SurfaceFoot

The SurfaceFoot nearest p on the surface (a cylinder's and a cone's side, not their caps): its u, v, the point and unique. Exact for every kind, in closed form. unique is false where several points lie equally near and the answer is a fixed pick among them — a sphere's centre, a point on a cylinder's, cone's or torus's axis; true otherwise.

Sphere.distanceTo()

distanceTo(p: Point3): number

How far p lies from the surface: the distance to its closest_point.

Sphere.domain()

domain(): [Interval, Interval]

The u and v ranges, as two Intervals.

Sphere.toNurbsSheet()

toNurbsSheet(): Solid

The surface alone, as an open sheet on its exact NURBS form.

Sphere.contains()

contains(p: Point3, tolerance?: number): boolean

Whether p lies inside the closed shape or within tolerance of it (1e-9 by default).

Sphere.area()

area(): number

The boundary's area, in closed form: a cylinder's and a cone's caps included.

Sphere.volume()

volume(): number

The volume enclosed, in closed form.

Sphere.toSolid()

toSolid(): Solid

The shape as a closed exact B-rep Solid, to join, cut and write.

Sphere.frame

readonly frame: Frame

The Frame the value is placed on.

Sphere.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Sphere.transform()

transform(t: Transform | MatrixLike): Sphere

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Cylinder

class Cylinder implements Iterable<number>

The capped cylinder of radius about the frame's z over height (an increasing Interval along z, or two numbers), as a value: u the angle from the frame's x, v the height. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Cylinder.radius

readonly radius: number

The radius.

Cylinder.height

readonly height: Interval

The range along the frame's z, an Interval.

Cylinder.pointAt()

pointAt(u: number, v: number): number[]

The point at (u, v), in the ranges domain gives.

Cylinder.normalAt()

normalAt(u: number, v: number): number[]

The outward unit normal at (u, v).

Cylinder.closestPoint()

closestPoint(p: Point3): SurfaceFoot

The SurfaceFoot nearest p on the surface (a cylinder's and a cone's side, not their caps): its u, v, the point and unique. Exact for every kind, in closed form. unique is false where several points lie equally near and the answer is a fixed pick among them — a sphere's centre, a point on a cylinder's, cone's or torus's axis; true otherwise.

Cylinder.distanceTo()

distanceTo(p: Point3): number

How far p lies from the surface: the distance to its closest_point.

Cylinder.domain()

domain(): [Interval, Interval]

The u and v ranges, as two Intervals.

Cylinder.toNurbsSheet()

toNurbsSheet(): Solid

The surface alone, as an open sheet on its exact NURBS form.

Cylinder.contains()

contains(p: Point3, tolerance?: number): boolean

Whether p lies inside the closed shape or within tolerance of it (1e-9 by default).

Cylinder.area()

area(): number

The boundary's area, in closed form: a cylinder's and a cone's caps included.

Cylinder.volume()

volume(): number

The volume enclosed, in closed form.

Cylinder.toSolid()

toSolid(): Solid

The shape as a closed exact B-rep Solid, to join, cut and write.

Cylinder.frame

readonly frame: Frame

The Frame the value is placed on.

Cylinder.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Cylinder.transform()

transform(t: Transform | MatrixLike): Cylinder

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Cone

class Cone implements Iterable<number>

The capped cone of base radius on the frame's x-y plane, its apex height up its z, as a value: u the angle from the frame's x, v the height. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Cone.radius

readonly radius: number

The base radius.

Cone.height

readonly height: number

How far up the frame's z the apex lies.

Cone.pointAt()

pointAt(u: number, v: number): number[]

The point at (u, v), in the ranges domain gives.

Cone.normalAt()

normalAt(u: number, v: number): number[]

The outward unit normal at (u, v).

Cone.closestPoint()

closestPoint(p: Point3): SurfaceFoot

The SurfaceFoot nearest p on the surface (a cylinder's and a cone's side, not their caps): its u, v, the point and unique. Exact for every kind, in closed form. unique is false where several points lie equally near and the answer is a fixed pick among them — a sphere's centre, a point on a cylinder's, cone's or torus's axis; true otherwise.

Cone.distanceTo()

distanceTo(p: Point3): number

How far p lies from the surface: the distance to its closest_point.

Cone.domain()

domain(): [Interval, Interval]

The u and v ranges, as two Intervals.

Cone.toNurbsSheet()

toNurbsSheet(): Solid

The surface alone, as an open sheet on its exact NURBS form.

Cone.contains()

contains(p: Point3, tolerance?: number): boolean

Whether p lies inside the closed shape or within tolerance of it (1e-9 by default).

Cone.area()

area(): number

The boundary's area, in closed form: a cylinder's and a cone's caps included.

Cone.volume()

volume(): number

The volume enclosed, in closed form.

Cone.toSolid()

toSolid(): Solid

The shape as a closed exact B-rep Solid, to join, cut and write.

Cone.frame

readonly frame: Frame

The Frame the value is placed on.

Cone.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Cone.transform()

transform(t: Transform | MatrixLike): Cone

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Torus

class Torus implements Iterable<number>

The torus of major radius about the frame's z and minor radius about that circle, as a value: u the angle about the z from the frame's x, v the angle about the tube. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Torus.major

readonly major: number
readonly minor: number

The radius of the tube's centre circle, and the tube's own.

Torus.pointAt()

pointAt(u: number, v: number): number[]

The point at (u, v), in the ranges domain gives.

Torus.normalAt()

normalAt(u: number, v: number): number[]

The outward unit normal at (u, v).

Torus.closestPoint()

closestPoint(p: Point3): SurfaceFoot

The SurfaceFoot nearest p on the surface (a cylinder's and a cone's side, not their caps): its u, v, the point and unique. Exact for every kind, in closed form. unique is false where several points lie equally near and the answer is a fixed pick among them — a sphere's centre, a point on a cylinder's, cone's or torus's axis; true otherwise.

Torus.distanceTo()

distanceTo(p: Point3): number

How far p lies from the surface: the distance to its closest_point.

Torus.domain()

domain(): [Interval, Interval]

The u and v ranges, as two Intervals.

Torus.toNurbsSheet()

toNurbsSheet(): Solid

The surface alone, as an open sheet on its exact NURBS form.

Torus.contains()

contains(p: Point3, tolerance?: number): boolean

Whether p lies inside the closed shape or within tolerance of it (1e-9 by default).

Torus.area()

area(): number

The boundary's area, in closed form: a cylinder's and a cone's caps included.

Torus.volume()

volume(): number

The volume enclosed, in closed form.

Torus.toSolid()

toSolid(): Solid

The shape as a closed exact B-rep Solid, to join, cut and write.

Torus.frame

readonly frame: Frame

The Frame the value is placed on.

Torus.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Torus.transform()

transform(t: Transform | MatrixLike): Torus

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Cuboid

class Cuboid implements Iterable<number>

The box over x, y, z (increasing Intervals, or pairs) along its frame's axes, as a value: an oriented bounding box, a region to test points against, a block to make a solid of. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Cuboid.fromBounds()

static fromBounds(min: Point3, max: Point3): Cuboid

The world-aligned box from min to max; an empty or flat one throws BuildError.

Cuboid.around()

static around(frame: FrameLike, points: Iterable<Point3>): Cuboid

The tightest box holding points, aligned to frame. No points, or points flat along one of the frame's axes (a sheet, not a box), throws BuildError.

Cuboid.x

readonly x: Interval
readonly y: Interval
readonly z: Interval

The three ranges along the frame's axes, as Intervals.

Cuboid.corners()

corners(): number[][]

The eight corners: the z0 face counter-clockwise about the frame's z from (x0, y0), then the z1 face in the same order.

Cuboid.pointAt()

pointAt(sx: number, sy: number, sz: number): number[]

The point the fractions sx, sy, sz of the way along each range.

Cuboid.closestPoint()

closestPoint(p: Point3): number[]

The closest point of the solid box to p: p itself where it lies inside.

Cuboid.contains()

contains(p: Point3, tolerance?: number): boolean

Whether p lies inside the closed shape or within tolerance of it (1e-9 by default).

Cuboid.area()

area(): number

The boundary's area, in closed form: a cylinder's and a cone's caps included.

Cuboid.volume()

volume(): number

The volume enclosed, in closed form.

Cuboid.toSolid()

toSolid(): Solid

The shape as a closed exact B-rep Solid, to join, cut and write.

Cuboid.frame

readonly frame: Frame

The Frame the value is placed on.

Cuboid.bounds()

bounds(): [number[], number[]]

The exact world box, (min, max), from the closed form rather than from samples.

Cuboid.transform()

transform(t: Transform | MatrixLike): Cuboid

This value under t (a Transform, or 16 numbers), a value of the same type. A line takes any map that keeps its ends apart and an ellipse any that keeps it an ellipse; every other value only a similarity — turn a circle into an Ellipse first for anything else. Any other map throws BuildError.

Rectangle

class Rectangle implements Iterable<number>

The rectangle over x and y (increasing Intervals, or pairs) in its frame's x-y plane, as a value — Rhino's Rectangle3d. As a curve it is its boundary: t runs 0..4, one unit a side, from corner (x0, y0) counter-clockwise about the frame's z. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Rectangle.x

readonly x: Interval
readonly y: Interval

The two ranges along the frame's x and y, as Intervals.

Rectangle.frame

readonly frame: Frame

The Frame the rectangle lies on.

Rectangle.corners()

corners(): number[][]

The four corners in Rhino's Corner(i) order: (x0, y0), (x1, y0), (x1, y1), (x0, y1).

Rectangle.area()

area(): number

The filled rectangle's area.

Rectangle.pointAt()

pointAt(t: number): number[]

The boundary's point at t: side k for t in k..k+1. A t outside 0..4 is clamped, as Rhino's PointAt does, not wrapped.

Rectangle.tangentAt()

tangentAt(t: number): number[]

The unit direction of t's side: the frame's x, y, -x, -y in turn.

Rectangle.length()

length(): number

The boundary's length, the circumference.

Rectangle.closestPoint()

closestPoint(p: Point3): CurveFoot

The CurveFoot on the boundary nearest p (projected onto the plane first). unique is false where two sides lie equally near — the centre, any point on the medial axis — and the answer is a fixed pick among them.

Rectangle.distanceTo()

distanceTo(p: Point3): number

How far p lies from the boundary.

Rectangle.closestPointIn()

closestPointIn(p: Point3, includeInterior?: boolean): number[]

Rhino's ClosestPoint(p, includeInterior): p projected onto the plane and clamped into the filled rectangle when include_interior (the default), else the boundary's closest point.

Rectangle.contains()

contains(p: Point3, tolerance?: number | null): 'inside' | 'outside' | 'on'

Where p, projected onto the plane, lies: "inside", "outside", or "on" within tolerance of the boundary (Rhino's Contains). tolerance None (or NaN) is unset — the rectangle's own effective tolerance, tolerance.relative times its diagonal; 0 is exact, so only a point exactly on the boundary is on it. A negative or infinite one throws BuildError.

Rectangle.toSheet()

toSheet(): Solid

The filled rectangle as a one-face planar sheet Solid, facing the frame's z.

Rectangle.toNurbs()

toNurbs(): NurbsCurve

The boundary as its exact closed degree-1 NurbsCurve, a knot at each corner, so its parameter is t.

Rectangle.bounds()

bounds(): [number[], number[]]

The world box of the four corners, (min, max).

Rectangle.transform()

transform(t: Transform | MatrixLike): Rectangle

This rectangle under t (a Transform, or 16 numbers): any map that keeps its sides square — a similarity, a mirror, a stretch along its own axes. A shear in its plane, or a map that flattens it, throws BuildError (Rhino's Transform answers a rectangle that is not the image).

Triangle

class Triangle implements Iterable<number>

The triangle a, b, c, as a value — Rhino's Triangle3d. Collinear or coincident points (an area at most 1e-12 of the longest side squared) throws BuildError. Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Triangle.a

readonly a: number[]
readonly b: number[]
readonly c: number[]

The three vertices.

Triangle.area()

area(): number

The area.

Triangle.perimeter()

perimeter(): number

The sum of the three sides.

Triangle.centroid()

centroid(): number[]

The area centroid, the vertices' mean (Rhino's AreaCenter).

Triangle.circumcircle()

circumcircle(): Circle

The Circle through a, b and c: its x toward a, turning them counter-clockwise.

Triangle.pointAt()

pointAt(wa: number, wb: number, wc: number): number[]

The point of barycentric weights wa, wb, wc, used as given (they need not sum to 1).

Triangle.barycentric()

barycentric(p: Point3): number[]

The weights (wa, wb, wc), summing to 1, of p projected onto the triangle's plane.

Triangle.closestPoint()

closestPoint(p: Point3): number[]

The closest point of the filled triangle to p, exact (by the vertex, edge and face regions, no iteration).

Triangle.distanceTo()

distanceTo(p: Point3): number

How far p lies from the filled triangle.

Triangle.edge()

edge(i: number): Line

Edge i as a Line: 0 a to b, 1 b to c, 2 c to a. Any other i throws BuildError.

Triangle.toSheet()

toSheet(): Solid

The filled triangle as a one-face planar sheet Solid, its normal turning a, b, c counter-clockwise.

Triangle.bounds()

bounds(): [number[], number[]]

The world box of the three vertices, (min, max).

Triangle.transform()

transform(t: Transform | MatrixLike): Triangle

This triangle under t (a Transform, or 16 numbers): any affine map, the vertices to their images. One that flattens it throws BuildError.

Ray

class Ray implements Iterable<number>

The half-line from position along direction, as a value — Rhino's Ray3d. The direction is kept as given, not unitised, so t counts lengths of it; a zero one throws BuildError. Shooting a ray at a solid is not here: see Solid.hits(). Immutable, with nothing to free: equal by value, hashable, iterating as its numbers, the maths the library's own, so every language answers alike. A frame argument is a Frame or 12 numbers; one within 1e-6 of right-handed and orthonormal is squared up, any other throws BuildError, as does a size that is not positive and finite.

Ray.position

readonly position: number[]
readonly direction: number[]

The start and the direction.

Ray.pointAt()

pointAt(t: number): number[]

position + t * direction, for any t — behind the start too, as Rhino's PointAt.

Ray.closestPoint()

closestPoint(p: Point3): CurveFoot

The CurveFoot on the ray nearest p: t clamped at 0, so a point behind the start answers the start. Always unique.

Ray.distanceTo()

distanceTo(p: Point3): number

How far p lies from the ray.

Ray.bounds()

bounds(): [number[], number[]]

A ray has no box: this throws BuildError.

Ray.transform()

transform(t: Transform | MatrixLike): Ray

This ray under t (a Transform, or 16 numbers): any affine map, the position as a point and the direction as a vector. One that kills the direction throws BuildError.

Workplane

class Workplane

The fluent chain: a frame, the solid built so far, and the face last picked. A build step replaces the solid rather than adding to it — combine solids explicitly with Solid.join(). Every step throws BuildError at once rather than holding the error for later.

Workplane.xy()

static xy(): Workplane

Start on the XY plane at the origin (Z up). Workplane.xz() and Workplane.yz() start on the other two.

Workplane.xz()

static xz(): Workplane

Start on the XZ plane.

Workplane.yz()

static yz(): Workplane

Start on the YZ plane.

Workplane.on()

static on(frame: FrameLike): Workplane

Start on any frame (see Frames).

Workplane.fromSolid()

static fromSolid(solid: Solid): Workplane

Start from an existing solid, on the XY plane — the usual way to pick one of its faces and build on it.

Workplane.frame

frame: number[]

The current frame, 12 numbers.

Workplane.cuboid()

cuboid(x: number, y: number, z: number): this

A box x × y × z centred on the current frame's origin and aligned to its axes — on a picked face, half of it below the face; replaces the solid.

Workplane.cylinder()

cylinder(r: number, h: number): this

A cylinder of radius r and height h standing on the current frame; replaces the solid.

Workplane.face()

face(profile: Profile): this

The planar sheet the profile bounds on this frame — see Solid.face(); replaces the solid.

Workplane.extrude()

extrude(profile: Profile, height: number): this

The profile extruded height along the frame's z; replaces the solid.

Workplane.revolve()

revolve(profile: Profile, angle: number): this

The profile revolved angle radians about the frame's y axis; replaces the solid.

Workplane.translate()

translate(dx: number, dy: number, dz: number): this

Slide the current solid. Keeps the face selection — a rigid move keeps every face's index.

Workplane.faces()

faces(selector: Selector): this

Pick a face of the current solid with a Selector.

Workplane.workplane()

workplane(): this

Move the frame onto the face last picked (outward normal as z), so the next step builds on it.

Workplane.solid()

solid(): Solid

The solid built so far. On an empty chain it throws BuildError.

Selector and Axis

class Selector

Which face to pick: the one furthest along an axis, furthest against it, the one facing a direction, or by index. Used by Workplane.faces() and Solid.selectFace().

Selector.max()

static max(axis: AxisValue): Selector

The face furthest along axis.

Selector.min()

static min(axis: AxisValue): Selector

The face furthest against axis.

Selector.normal()

static normal(direction: Point3): Selector

The face whose outward normal is nearest direction (need not be unit).

Selector.index()

static index(i: number): Selector

The face with this index.

Axis.X

readonly X: 0
readonly Y: 1
readonly Z: 2

X, Y, Z: the axes Selector.max() and Selector.min() take.

Solid

class Solid

An exact B-rep solid (or an open sheet): planes, cylinders, cones, spheres, tori and NURBS, trimmed and joined, never approximated by triangles. Immutable — every operation returns a new one. Close it when done, or let the language's scope do it; see Lifetimes.

Primitives

Solid.cuboid()

static cuboid(x: number, y: number, z: number): Solid

A box x × y × z, centred on the origin.

Solid.cylinder()

static cylinder(r: number, h: number): Solid

A cylinder of radius r, from z = 0 to h.

Solid.cone()

static cone(r: number, h: number): Solid

A cone of base radius r and height h, apex up.

Solid.sphere()

static sphere(r: number): Solid

A sphere of radius r about the origin.

Solid.torus()

static torus(major: number, minor: number): Solid

A torus about the z axis: major to the tube's centre, minor the tube's radius. A tube wider than its ring (minor > major, a spindle) builds the solid it sweeps, the outer sheet with a pole at each end on the axis; minor == major is refused.

Solid.wedge()

static wedge(x: number, y: number, z: number, topX: number): Solid

A box whose top face is top_x long instead of x: a ramp.

Solid.pyramid()

static pyramid(sides: number, r: number, h: number): Solid

A pyramid of sides sides (at least 3): its base the regular polygon of radius r on z = 0 (r to a corner, the first on +x), its tip at height h.

From a profile

Solid.extrude()

static extrude(profile: Profile, frame: FrameLike, height: number): Solid

The profile on frame, extruded height along the frame's z.

Solid.extrudeOpen()

static extrudeOpen(profile: Profile, frame: FrameLike, height: number): Solid

The walls only, no caps: an open sheet. Takes an open Path.endOpen() chain as well as a closed profile.

Solid.extrudeTapered()

static extrudeTapered(profile: Profile, frame: FrameLike, height: number, taper: number): Solid

Extrude with a draft: the walls lean out by taper radians as they rise (in, when negative). Every wall stays exact — a plane off a line, a cone off an arc.

Solid.extrudeOpenTapered()

static extrudeOpenTapered(profile: Profile, frame: FrameLike, height: number, taper: number): Solid

The tapered walls without caps.

Solid.extrudeBetween()

static extrudeBetween(profile: Profile, frame: FrameLike, bottom: SlantLike, top: SlantLike): Solid

Extrude between two planes rather than two heights: bottom and top are each a Slant (a bare number is a flat one). With both flat this is Solid.extrude(); with a slope it is the mitred end of a frame member. A top that comes down to or through the bottom throws BuildError.

Solid.extrudeOpenBetween()

static extrudeOpenBetween(profile: Profile, frame: FrameLike, bottom: SlantLike, top: SlantLike): Solid

Solid.extrudeBetween() without the caps.

Solid.revolve()

static revolve(profile: Profile, axis: AxisLine, angle: number): Solid

The profile swung angle radians about axis (a point and a direction — see Frames). The profile's x is read as the radius and its y as the height along the axis, so it must lie to one side of it.

Solid.revolveOpen()

static revolveOpen(profile: Profile, axis: AxisLine, angle: number): Solid

The revolved surface of an open profile: a sheet.

Solid.revolveInPlane()

static revolveInPlane(profile: Profile, frame: FrameLike, a: Point2, b: Point2, angle: number): Solid

The profile on frame swung angle radians about the axis through the sketch points a and b (each (x, y) on the frame) — the profile and its axis drawn together, as a sketch draws them, where Solid.revolve() reads the profile as (radius, height). The profile may lie on either side of the axis and touch it (a half-disc with its diameter on the axis turns into a ball), but not cross it. The sweep starts where the profile is drawn and turns right-handed about b - a, so a partial turn leaves one end of the solid over the profile itself.

Solid.revolveOpenInPlane()

static revolveOpenInPlane(profile: Profile, frame: FrameLike, a: Point2, b: Point2, angle: number): Solid

Solid.revolveInPlane() for a curve: its segments swung into a sheet, no caps.

Solid.coil()

static coil(profile: Profile, axis: AxisLine, pitch: number, turns: number): Solid

The profile coiled about axis (a point and a direction): read as Solid.revolve() reads it — x the distance from the axis, y along it — and turned turns times while climbing pitch along the axis each turn: a spring, a thread. The walls follow the helix to a few millionths of the radius (a helix is not a NURBS curve, so they are a close fit, exact at both ends); the two ends are the profile itself, flat. A profile reaching the axis, one with holes, or — from a full turn up — a pitch no taller than the profile throws BuildError.

Solid.loft()

static loft(a: Profile, frameA: FrameLike, b: Profile, frameB: FrameLike): Solid

The solid between profile a on one frame and b on another: ruled walls between matching sides (both profiles need the same number of sides, and no holes), capped by the two.

Solid.loftOpen()

static loftOpen(a: Profile, frameA: FrameLike, b: Profile, frameB: FrameLike): Solid

The ruled walls without the caps.

Solid.loftThrough()

static loftThrough(sections: Iterable<[Profile, FrameLike]>): Solid

The solid smooth through every section — a profile on its frame, in order: each wall interpolates its side across all the profiles (cubic through four or more, quadratic through three, Solid.loft() through two), capped by the first and the last. Every section of the result is its profile exactly, arcs and all. The profiles must have the same number of sides and no holes; otherwise throws BuildError.

Solid.loftThroughOpen()

static loftThroughOpen(sections: Iterable<[Profile, FrameLike]>): Solid

The walls through the curves without the caps: an open sheet.

Solid.sweep()

static sweep(profile: Profile, frame: FrameLike, path: SweepPath): Solid

The profile on frame, carried along a SweepPath. A straight piece is an extrusion and an arc a revolution about the arc's axis, so nothing is approximated — a circle along an arc is an exact torus wall.

Solid.sweepOpen()

static sweepOpen(profile: Profile, frame: FrameLike, path: SweepPath): Solid

The swept walls without caps: an open sheet.

Solid.pipe()

static pipe(path: SweepPath, radius: number, thickness?: number): Solid

A circle of radius carried along a SweepPath, square to where it starts: a solid rod, or with a positive thickness a tube whose walls are that thick. The path is only borrowed, as by Solid.sweep(), and refused the same way.

Solid.extrudeFaces()

extrudeFaces(height: number): Solid

Every face of a sheet pushed height along its own normal, walled and closed: the sheet as a solid of that thickness.

Solid.face()

static face(profile: Profile, frame: FrameLike): Solid

The flat sheet a profile bounds on frame: one planar face, each hole a hole through it, its normal the frame's z however the profile winds, every edge the exact line, arc or spline its segment is. An open sheet — raise it with Solid.extrudeFaces(), cut it with Solid.trim().

Placing

Solid.place()

place(frame: FrameLike): Solid

A solid built about the origin moved onto frame: its origin to the frame's origin, its axes to the frame's (see Frames).

Solid.translate()

translate(dx: number, dy: number, dz: number): Solid

Moved by (dx, dy, dz).

Solid.scale()

scale(factor: number): Solid

Scaled by factor about the origin: every length times factor, exactly. factor must be positive and finite.

Solid.rotate()

rotate(axis: AxisLine, radians: number): Solid

Turned radians about axis (a point and a direction).

Solid.mirror()

mirror(plane: FrameLike): Solid

Reflected across plane: a frame whose z is the mirror plane's normal.

Solid.transform()

transform(t: Transform | MatrixLike): Solid

Through the affine map t — a Transform, or 16 numbers row-major — exactly, colours and name kept. A rigid map or a similarity keeps every surface's kind; a map within 1e-6 of a similarity (AᵀA against k²I, relative to k²: a rotation written in float32 among them) is applied as the exact similarity nearest it, moving a point p by at most about 1e-6·|A|·|p|. Any other map — a non-uniform scale, a shear — turns the curved surfaces into their exact NURBS and maps those. A singular map throws BuildError.

Solid.convertToNurbs()

convertToNurbs(level?: NurbsLevel): Solid

Every surface level selects rewritten as its exact NURBS: "procedural" the revolutions, extrusions and sums; "analytic" those and the cylinders, cones, spheres and tori; "all" everything, planes and edge curves too. Colours and name kept.

Solid.inexactTrims

readonly inexactTrims: number

On a solid from Solid.transform() or Solid.convertToNurbs(), the trims that call lost: face boundaries kept only as a polyline lifted through the old surface, where no exact edge curve was left. Per call — not the solid's history — and 0 for a rigid map or a similarity, and on every other solid.

Booleans

Solid.join()

join(other: Solid, tolerance?: number | null, progress?: Progress | null, merge?: boolean): Solid

The union with other, as an exact B-rep. merge (off by default, so face and edge numbers stay as they were) merges the flush faces the join leaves, as Solid.mergeFlush() does — Go takes it as a trailing true, Java as an overload; Solid.cut() and Solid.common() take it too. tolerance (0.05 by default) is the mesh tolerance the boolean decides at: both solids are meshed at it, so a tighter one is as correct and slower. It is also the resolution: two faces on one surface to within it — a peg the size of its hole, or a hair thinner — are one surface, and the join is a fit; a gap wider than it is a gap. progress, where the wrapper takes one, is called with a phase name and a done/total count.

Solid.cut()

cut(other: Solid, tolerance?: number | null, progress?: Progress | null, merge?: boolean): Solid

This solid with other removed.

Solid.common()

common(other: Solid, tolerance?: number | null, progress?: Progress | null, merge?: boolean): Solid

What this solid and other share.

Solid.intersect()

intersect(other: Solid, tolerance?: number | null, progress?: Progress | null): Intersection

Where this solid's faces cross or coincide with other's, at tolerance, as an Intersection: every crossing as a Chain, every coincident face pair that shares a region as an Overlap. Not a boolean: neither solid changes, nothing is built. tolerance (0.05 by default) is read as Solid.join()'s — both solids' mesh resolution and how close a point may sit to both faces' exact surfaces to be reported. No crossing at all is an empty Intersection, never an error. progress, where the wrapper takes one, is called with a phase and a done/total count: meet on the exact route; mesh, cull, cross, snap, curve where it falls back to the mesh route.

There is one chain per face pair per branch: a chain does not cross a face boundary or a closed curve's own seam, so a crossing that runs past either comes back as more than one chain, joined by matching ends. Two faces on one surface sharing no region — an edge or a rim resting against another face, two flush faces meeting along a line — are silent: neither a chain nor an overlap. Known limit: a crossing narrower than tolerance — two surfaces passing within it of each other without their meshes actually crossing — can be missed; where this bites the surfaces are near-tangent, and the chain that is found (if any) carries tangent.

Solid.selfIntersections()

selfIntersections(tolerance?: number | null, progress?: Progress | null): Intersection

Where this solid passes through itself, at tolerance, as an Intersection — what Solid.intersect() reports with this solid on both sides, so every Chain and Overlap names two faces of this solid. Never along its own topology: faces meeting at the edges and vertices they share are not a crossing, so a clean solid is an empty Intersection, never an error. A chain whose two faces are one face is that face folding through itself, and has no curve. The solid is not changed; it may be an open sheet. tolerance (0.05 by default) is the mesh resolution, as Solid.intersect()'s: the solid is meshed once and crossed against itself, the exact face-pair engine refining each crossing of two faces, so the same known limit holds — a crossing narrower than tolerance can be missed. progress, where the wrapper takes one, hears mesh, cull, cross, snap, curve. A tolerance not positive and finite, a solid with no faces or one that meshes to nothing, throws BuildError.

Solid.check()

check(other?: Solid | null, operation?: CheckOperation | null, tolerance?: number | null, progress?: Progress | null): Finding[]

What is wrong with this solid (and other, if given) as the arguments of operation, at tolerance, as a list of Finding — OCCT's BRepAlgoAPI_Check, gathered from what the kernel already measures. An empty list is a valid pair; nothing is changed. Each argument is checked alone whatever the operation: no faces, features smaller than tolerance as Solid.health() finds them, shared edges whose sides part, edges that leave a face's surface, creases where the geometry is only C0, and where it passes through itself as Solid.selfIntersections() finds it. operation — join, cut, common, split_sheet, trim, merge or intersect — adds what that verb refuses each argument for: a boolean wants both closed (one open finding per free edge) and holding no region wall (a merge's body); a split or trim only its tool closed; a merge closed manifolds of planes, cylinders, cones, spheres and tori. Without other, this solid is held to what the operation asks of its first argument. A free edge is no fault without an operation that asks for a closed solid: an open sheet is a fine body.

An edge leaves a face's surface (curve_on_surface) where its descriptions — its trim in the face's parameters carried onto the surface, its curve and its polyline in space — part from the surface, or from one another there, by more than tolerance (or the edge's own recorded tolerance, if larger); a polyline is measured at its points only, so a file's coarse flattening is no fault. A crease (c0_inside) is a line where the geometry turns a corner inside a face — a spline knot of full multiplicity, a kink in a swept surface's profile, every point of a profile a file flattened to a polyline — or along an edge's own curve, sharper than the angular tolerance: the solid's declared one, else the tolerance.angular option (one degree). A knot where the two sides meet tangent is no crease, unlike OCCT's check, which flags any C0 parametrisation. Both are sampled, so a deviation narrower than the sampling can be missed.

With other, the sub-shapes of the two a boolean would merge or struggle with come too, whatever the operation, each as a finding with argument 0, index in this solid and other in other: two vertices further apart than the weld (1e-6, inside which two points are one) but within tolerance (merge_vertex); two edges running along one another within tolerance and parallel within the angular tolerance over a stretch longer than tolerance, without being one edge (merge_edge); two faces lying on one another only within tolerance (merge_face); and two faces whose crossing runs where they are tangent within the angular tolerance — a cylinder lying on a block, which a join refuses as touching itself along a line (tangent_face). Vertices, edges and faces exactly on one another are what a boolean handles, and are none. The face findings are read off Solid.intersect()'s answer, so a point contact, which has no crossing, is not found, and a crossing shallower than the angular tolerance is a crossing. progress, where the wrapper takes one, hears health, curve_on_surface and continuity, then the self-intersection's phases, then — with other — pairs. An unknown operation or a tolerance not positive and finite, throws BuildError.

Solid.section()

section(z: number, tolerance?: number | null): Profile[]

This solid cut by the plane Z = z: its closed outlines there, in XY, nested into profiles with holes (boundaries counter-clockwise, holes clockwise), a line or a circle crossing kept exact and any other curve as lines within tolerance. A plane that misses the solid is an empty list. A z not finite, a tolerance (0.05 by default) not positive and finite, a face lying in the plane (section a little above or below it), or a crossing that does not close, throws BuildError.

Solid.sectionCurves()

sectionCurves(origin: Point3, normal: Point3, tolerance?: number | null): SectionCurve[]

This body cut by the plane through origin square to normal, as curves in space, as Rhino's Intersection.BrepPlane: each a SectionCurve, each closed section loop one closed curve, an open sheet's crossing one open curve. A crossing on a line, circle, ellipse or NURBS is that curve exactly; any other a cubic fitted at tolerance (0 or null the body's own; its error says how far). A face lying in the plane gives its own edges, exactly. A plane missing the body gives an empty list.

Solid.contourCurves()

contourCurves(start: Point3, end: Point3, interval: number, tolerance?: number | null): SectionCurve[]

This body cut by the planes square to end - start through start and every interval on towards end, as Rhino's Brep.CreateContourCurves, as Solid.sectionCurves() cuts by one: every plane's SectionCurves in plane order, each one's plane its index. start and end the same point, an interval not positive and finite, or more than 10,000 planes, throws BuildError.

Solid.hits()

hits(profile: Profile, frame: FrameLike, tolerance?: number | null, progress?: Progress | null): SolidHits

Where profile, placed on frame, pierces this solid's faces, and the pieces its loops cut into, as a SolidHits. Neither is changed. A point hit lies within tolerance of the segment's exact curve and of the face's exact surface, inside the face's trim; its profile spot (Hit.aStart: loop, segment, t) and face spot (Hit.bStart: face, u, v) evaluate to the point within tolerance; touch where the curve's tangent lies within 1e-3 (sine) of the surface's tangent plane there (a graze), false at a crossing. A run is a stretch of one segment lying within tolerance of one face and inside it, longer than tolerance. Hits within tolerance of each other merge (a hit at a segment join reported once, as (k, t = 1); a closed loop's closing join reads (0, 0)). Every point is in world space (the frame applied).

Pieces (Piece) only for a closed body — an open body has none — in loop order, covering every loop exactly; a piece's spots read a segment join as the next segment's start (k + 1, 0), and an open chain runs from (0, 0) to (n - 1, 1); a loop no hit cuts is one closed piece. inside by the piece middle's winding number over the body's mesh; a piece lying on the surface is inside. Known limit: a segment passing within tolerance of a face without its polyline crossing the mesh can be missed (near-tangent grazes).

progress, where the wrapper takes one, is called with phases mesh, cull, hits and pieces and a done/total count. A tolerance not positive and finite, a solid with no faces or that meshes to nothing, a profile with no segments, or a free-form segment that is not an evaluable NURBS curve throws BuildError.

Solid.splitSheet()

splitSheet(tool: Solid, tolerance?: number | null, progress?: Progress | null): Solid

This solid or sheet cut along tool's boundary with nothing removed: each face comes back as its pieces outside tool and then its pieces inside, in the original face order — the start of a surface trim. tool must be a closed solid. Keep the pieces you want with Solid.dropFaces(), or split and drop in one call with Solid.trim().

Faces and sheets

Solid.faceSheet()

faceSheet(face: number): Solid

One face alone, as an open sheet: its surface, its loops and the exact curves on its edges, the rest of the solid left behind — raised by Solid.extrudeFaces() it is the prism over that face. Keeps the face's colour.

Solid.dropFaces()

dropFaces(faces: Iterable<number>): Solid

This solid without the faces listed: the rest keep their surfaces, curves and colours in their order, so an index into the result is this one's with the dropped ones closed up. Dropping every face throws BuildError.

Solid.trim()

trim(tool: Solid, keep?: 'outside' | 'inside', tolerance?: number | null, progress?: Progress | null): Solid

This sheet (or solid) cut along the closed tool's boundary and the pieces on one side thrown away: keep "outside" (the default) keeps what lies outside the tool — a hole punched through — and "inside" what lies within it. Nothing on the kept side throws BuildError. tolerance and progress as for Solid.join().

Solid.splitByCurve()

splitByCurve(curve: NurbsCurve, direction?: Point3 | null, tolerance?: number | null): Solid

This sheet cut along curve — a NurbsCurve lying on it, typically projected or pulled onto it — with nothing removed: each face comes back as its pieces outside the cutter and then its pieces inside, as Solid.splitSheet() orders them. The cutter is the curve run along direction (null: the mean of the sheet's normals along the curve) through the whole sheet, so the cut follows the curve wherever the sheet is one layer along that direction. A closed curve's inside is the island it bounds; an open curve's is the side left of its run, seen from where direction points, and an open curve is run on straight past both ends, so it should reach the sheet's boundary. Where the cut lies on the curve — a curve drawn on the sheet — the rim is one edge carrying the curve's own span exactly, its ends on the curve, so another sheet built along the same curve sews to it with Solid.joinSheets(). A direction that is zero, or a curve running along it, throws BuildError.

Solid.trimByCurve()

trimByCurve(curve: NurbsCurve, keep?: TrimKeep, direction?: Point3 | null, tolerance?: number | null): Solid

This sheet cut along curve and one side thrown away (see Solid.splitByCurve()): keep "outside" (the default) keeps the sheet with the hole a closed curve cuts, "inside" the island; for an open curve "left" (the same as "inside") keeps the side left of its run seen from where direction points, "right" the other. Nothing on the kept side throws BuildError. The kept pieces keep their faces' colours.

Solid.flange()

flange(edges: Iterable<Edge | number>, section: NurbsCurve, tolerance?: number | null, join?: boolean): Solid

A section swept along each of edges — naked edges of this sheet, bordered by one face — on the face's own frame, the new sheets sewn to this one: at every point of the edge the section's x runs outward from the face (square to the edge, in its tangent plane) and its y along the face's normal, so a section from (0, 0) to (0, -10) turns the edge under by 10 all along it however the panel curves — a flange round an opening, a wheel arch's lip, a door-seal return — (0, 0) to (10, 0) carries the face on, and a lip stands proud with y > 0. section is a NurbsCurve in the plane z = 0 starting at the origin. With join false the sweeps come back alone, sewn to each other. Each is fitted within tolerance, and its side along the edge too; sheet_error says how close. An edge bordered by two faces, a section not starting at the origin, or sweeps that did not sew on throws BuildError.

Solid.extrudeTo()

extrudeTo(edges: Iterable<Edge | number>, direction: Point3, target: Solid, tolerance?: number | null, join?: boolean): Solid

Each of edges — naked edges of this sheet — slid along direction until it meets target: every point of the edge travels along the direction to its first hit on target's faces (the trimmed faces, not their whole surfaces). One wall per edge, the edge's own curve swept straight and bounded by the curve through the hits, fitted within tolerance of every hit (sheet_error), so the wall shares the edge exactly and meets the target within the tolerance — a wheel arch cut in a panel run in to the well's inner wall as its liner. The walls come back sewn to this sheet, or alone with join false. A direction of no length, or a point whose line misses the target (named), throws BuildError.

Solid.splitAlongCurve()

splitAlongCurve(curve: NurbsCurve, tolerance?: number | null): Solid

This sheet cut along curve, a NurbsCurve lying on it (within ten times tolerance), with no direction: each face is cut in its own parameters where the curve crosses it, so the cut follows the curve however far the sheet rolls, and runs on across the seams of a joined sheet. An open curve is carried on along the sheet past both ends to its boundary; a closed one cuts out the island it bounds. Nothing is removed. Where the cut lies on the curve the rim is one edge carrying the curve's own span exactly. A curve that leaves the sheet throws BuildError.

Solid.panelGap()

panelGap(curve: NurbsCurve, gap?: number, flange?: number, tolerance?: number | null): [Solid, Solid]

This sheet parted along curve (lying on it, as for Solid.splitAlongCurve()) into two panels with a shut line between them — a car body's panel gap: each trimmed back gap / 2 from the curve, measured along the sheet, and given a flange flange along the faces' outward normals on the edge it was cut back to (negative turns it under; 0 for none). Only the cut edges are flanged, not the sheet's own edges, and each flange ends square where the curve runs off the sheet. The panel left of the curve's run (seen from the outward side) first, then the right one; a loop run counter-clockwise from that side has the island on its left. A curve that leaves the sheet, or a gap that leaves nothing of a panel, throws BuildError.

Solid.joinSheets()

static joinSheets(sheets: Iterable<Solid>, tolerance?: number | null): [Solid, JoinReport]

Separate sheets joined into one body, their faces in order, beside a JoinReport of what was done: every two naked edges whose ends and curves agree within tolerance (0: a rounding of the body's size) sewn into one edge — a gap closed is kept as that edge's own tolerance, nothing moves — the faces turned to agree across their edges, and a closed result turned to face out: a solid Solid.cut(), Solid.mass() and the writers take like any other. Edges that carry exact curves are compared to the tolerance however coarsely each sheet sampled them. One sheet's edge running along part of another's is not sewn and stays naked. No sheets, a negative tolerance, or faces that cannot be turned to agree (a one-sided surface) throws BuildError.

Solid.mirrorJoin()

mirrorJoin(plane: FrameLike, snap?: number, tolerance?: number | null): [Solid, SymmetryReport]

This half and its reflection across plane (a Frame, its z the plane's normal) joined into one symmetric body — half a car, a hull or a bottle modelled once and mirrored — the half's faces first, beside a SymmetryReport of how well the seam on the plane meets. With snap above 0, every NURBS face that is its whole surface and has a side whose control points all lie within snap of the plane is squared to it first: that side pulled onto the plane and the next row of control points stood straight off it along the plane's normal, keeping its distance from the plane. The surface then crosses the plane at 90 degrees, so it meets its mirror tangent and curvature continuous; nothing past that row moves, and neighbouring faces along the plane whose shared side agrees are squared alike and sew back. snap 0 mirrors the half as it is, a crease wherever it leans. The halves are sewn within tolerance (0: a rounding of the body's size). A half on both sides of the plane, no edge of it on the plane, or a face that cannot be squared (its next row on the plane or past it) throws BuildError.

Solid.pattern()

pattern(transforms: Iterable<Transform | MatrixLike>, tolerance?: number | null): [Solid, PatternReport]

This body and its copies at transforms (rigid Transforms, typically from Pattern, instance 0 the identity keeping the original) as one body — a pattern of bodies — beside a PatternReport. Copies apart from each other are put together with no boolean at all; copies that overlap are joined, one boolean a group. No transforms, or one that is not rigid, throws BuildError.

Solid.patternFeature()

patternFeature(tool: Solid, op: FeatureOp, transforms: Iterable<Transform | MatrixLike>, tolerance?: number | null): [Solid, PatternReport]

tool — any closed solid, typically a _tool call's result — placed at each of transforms and applied to this body by op, "cut" or "join": a pattern of features, Fusion's compute type *identical*, beside a PatternReport. Copies apart from each other are one multi-lump tool and one boolean, however many there are; overlapping copies fall into a few groups. A copy that shares no volume with the body is missed: dropped for a cut, kept as a body of its own for a join. An unknown op, no transforms, one not rigid, or a tool that is not closed throws BuildError.

Solid.hole()

hole(points: Point3 | Iterable<Point3>, diameter: number, options?: HoleOptions): [Solid, HoleReport]

This body drilled at points — one point, or several: one hole each, all of one spec, in one cut — beside a HoleReport. The bore is an exact cylinder of diameter, a counterbore an exact cylinder, a countersink and a drill point exact cones. direction is the drilling direction, into the material, shared by every point; null drills each point along the inward normal of the face it lies on (on an edge, the lowest-numbered face's).

extent: "through" everything ahead of the point; "blind", depth of full bore then a drill point of included angle tip_angle (0 or pi: a flat bottom); "to_face", until the axis first meets face face, the bore ending on it whatever its shape; "to_next", until the bore first leaves the material (OCCT's thru-next). head: null, "counterbore" (head_diameter across, head_depth deep) or "countersink" (head_diameter across at the point, included angle head_angle), measured from the point. Angles in radians. An unknown choice, a diameter not positive, a depth or face its extent does not take, a head not wider than the bore, an angle out of range, a point not on a face with no direction, a hole that removes nothing, or a face the axis never meets throws BuildError.

Tapped holes: thread (a designation or a ThreadSize) taps every hole. A diameter of 0 is then the tap drill (major - pitch), a given one must lie in the thread's internal band, and a head must be wider than the major. The thread starts at the point (a counterbore's floor) and runs thread_depth (null: the bore's length). thread_modelled cuts it in one more boolean after the holes; false drills the bore alone and writes a cosmetic record on each hole's bore face (Solid.threadRecord()). left_handed climbs the other way; the report's thread_depths has one per hole.

The keyword arguments are an options object.

Solid.holeTool()

holeTool(points: Point3 | Iterable<Point3>, diameter: number, options?: HoleOptions): Solid

The tool Solid.hole() cuts with, from the same arguments: a closed solid, one lump a point — for Solid.patternFeature() or a boolean of your own. A modelled thread's coils are joined into it (one more boolean, the tool's alone).

The keyword arguments are an options object.

Solid.thread()

thread(face: number, size?: string | ThreadSize | null, options?: ThreadOptions): [Solid, ThreadReport]

This body with a screw thread cut into cylindrical face face — external on a rod, internal in a bore (the face's normal decides) — beside a ThreadReport. The cutter is one coil of the basic ISO 68-1 profile at angle (the included flank angle, radians; 60 degrees by default), cut in one boolean.

size is a designation ("M10", "m10 x 1.25", "1/4-20": blacksmith.threadSize()'s forgiving lookup) or a ThreadSize; without one, pitch is required and diameter is the major (null: the face's diameter on a rod, the face taken as the basic minor in a bore). The face must lie in the thread's band: external [D2, D + P/8], internal [D1 - P/8, D2]. The span runs along the axis from the face's open end (air past it: a rod's tip, a bore's mouth; else the end lower along the face cylinder's axis; reverse the other) after offset, for length (null: the rest of the face). Where it ends at an open end the groove runs out through it; elsewhere the coil stops on its own cap, under a pitch short (no run-out). left_handed climbs the other way. A face past the end or not cylindrical, a size not in the table, a size and a pitch or diameter both given, neither, figures not positive, an angle out of range, the face outside the band, the span past the face, or a cut that removes nothing throws BuildError.

The keyword arguments are an options object.

Solid.threadTool()

threadTool(face: number, size?: string | ThreadSize | null, options?: ThreadOptions): Solid

The cutter Solid.thread() cuts with, from the same arguments: one closed coil.

The keyword arguments are an options object.

Solid.cosmeticThread()

cosmeticThread(face: number, size?: string | ThreadSize | null, options?: CosmeticThreadOptions): Solid

This body unchanged but for a cosmetic thread on face face: validated as Solid.thread() validates it (60 degree flanks), its figures written as the face's attributes thread.designation, thread.major, thread.pitch, thread.length, thread.offset, thread.internal, thread.left_handed and thread.reverse — strings, so they go wherever face attributes go, and every verb carries them to the faces of its result. Refused as Solid.thread() is.

The keyword arguments are an options object.

Solid.threadRecord()

threadRecord(face: number): ThreadRecord | null

Face face's cosmetic thread as a ThreadRecord, or null where it carries no complete record (every thread.* attribute present and parsable). A face past the end throws BuildError.

Solid.threadRecords()

threadRecords(): [number, ThreadRecord][]

Every face's cosmetic thread, as (face, record) pairs in face order.

Solid.rib()

rib(curve: NurbsCurve, plane: FrameLike, thickness: number, options?: RibOptions): Solid

This body with a rib along curve, an open NurbsCurve lying in plane (a Frame): the region of the plane between the curve and the body on the toward side (a direction in the plane; null: toward the body's nearest point), the curve's ends carried on along their tangents until they meet the body, thickened thickness along the plane's normal — side "both" (half each side), "front" (+z) or "back" (-z) — and joined in one boolean (OCCT's linear form). An unknown side, a curve closed or not in the plane, a thickness not positive, a slab that meets nothing, or a region not closed by the body throws BuildError.

Solid.ribTool()

ribTool(curve: NurbsCurve, plane: FrameLike, thickness: number, options?: RibOptions): Solid

The slab Solid.rib() joins, alone, from the same arguments.

Solid.ribRevolved()

ribRevolved(curve: NurbsCurve, axisPoint: Point3, axisDirection: Point3, angle: number, options?: RibRevolvedOptions): Solid

This body with a revolved rib: the region Solid.rib() would fill, drawn in the plane holding the axis (through axis_point along axis_direction) and curve (an open NurbsCurve in that plane), clipped to the curve's side of the axis and swung angle radians about it, symmetric about the curve's plane, then joined in one boolean. toward as Solid.rib()'s. An angle not in (0, 2 pi), a zero axis direction, a curve closed or not in one plane with the axis, a slab that meets nothing, or a region not closed by the body throws BuildError.

Solid.ribRevolvedTool()

ribRevolvedTool(curve: NurbsCurve, axisPoint: Point3, axisDirection: Point3, angle: number, options?: RibRevolvedOptions): Solid

The solid Solid.ribRevolved() joins, alone, from the same arguments.

Solid.web()

web(curves: NurbsCurve | Iterable<NurbsCurve>, plane: FrameLike, thickness: number, options?: WebOptions): Solid

This body with a web along each of curves (one open NurbsCurve or several, in plane): each offset in the plane to thickness — side "both", "left" or "right" of the curve's run, the plane's normal up — its ends carried along their tangents to the body, its walls run along the plane's normal until they meet the body (depth null) or for depth, one way (the normal's) or both when both_ways. All the webs are one tool and one join; crossing curves make a network. An unknown side, no curves, one closed or not in the plane, a thickness not positive, or walls that meet nothing or are not closed by the body throws BuildError.

Solid.webTool()

webTool(curves: NurbsCurve | Iterable<NurbsCurve>, plane: FrameLike, thickness: number, options?: WebOptions): Solid

The walls Solid.web() joins, alone, from the same arguments.

Solid.recess()

recess(outline: NurbsCurve, depth: number, draft?: number, fillet?: number, pane?: boolean, tolerance?: number | null): [Solid, [number, number, number, number]]

This sheet with an opening recessed into it along outline — a window, a lamp, a grille or an air intake set into a panel — beside how many of the result's faces are each part's: the sheet's, the fillet's, the walls' and the pane's, the faces in that order. outline is a closed NurbsCurve on the sheet (one face, or several joined by Solid.joinSheets()); each of its points is found on the sheet, so a curve drawn a little off it recesses cleanly. The sheet is cut along it and walls run back depth along the sheet's own normal at every point of the rim — not along one view, so an opening set into a panel that rolls over from side to roof still runs straight in — behind the face (against its normal; negative: in front), leaning in toward the opening by draft radians (negative: out) and meeting on the mitre at the outline's corners. fillet above 0 rounds the rim between the sheet and the walls with a ball of that radius; pane closes the back with one patch whose four sides end where the outline turns most — a rectangle's corners, the middle of a rounded rectangle's corner arcs — so it does not twist. Every piece is sewn to the next: only the sheet's own boundary is left naked, and the walls' foot where there is no pane. An outline that is not closed, a corner with a fillet, or a fillet deeper than the walls throws BuildError.

Solid.health()

health(options?: HealthOptions): HealthReport

What is wrong with this solid, as a HealthReport: the free edges and the wires they chain into, each with its nearest partner and the gap to it; the features below tolerance; the loose edges; and what sewing would join and leave. Nothing moves. tolerance is an absolute length, as Rhino's model tolerance is, by default 1e-4 times the diagonal; a NaN, infinite, zero or negative one takes the default, and the report shows what was used. A partner is the nearest free edge other than a neighbour on the wire, so a rim reads as a gap the size of the part; shared_ends 2 is what Solid.joinSheets() joins. mesh=True also meshes the solid and reports where the mesh cracks; an open body's crack census is empty by design (not asked), and cracks are only counted on a closed body. Loose edges are compared against the larger of the tolerance recorded and the one given. A solid that cannot be read throws BuildError.

Solid.heal()

heal(options?: HealOptions): { solid: Solid; report: HealReport }

This solid with its small features removed, beside a HealReport of what was done and left, as a new Solid; this one is left as it was. It heals what Solid.health() lists as small at the same tolerance, so health first tells what it will do.

Each kind's fix: a short edge's two ends are merged into one vertex and the edge dropped; a collapsed edge (a trim collapsed to a point where its surface is not singular) is dropped; a sliver face's short ends are merged, then the face is dropped and its two long sides sewn into one edge; a tiny face's corners are merged into one vertex and the face is dropped with its edges; a small hole (an inner loop whose edges are all free: a pinhole in an open sheet) is dropped from its face. A hole with walls (a bore) is not a small hole, and a tiny body is listed but never removed.

Everything is a vertex merge no wider than tolerance: a cluster of vertices that spans more, measured by every trim end at them, is refused (chain), so a run of short edges cannot swallow a long one, nor a loosely written corner move an end further. No edit moves a trim further than tolerance: a trim end on a surface pole keeps its uv, an end sent further is left, and a curve edit that would move further is discarded and only the vertex moves. A stack of slivers whose outer faces part by more than tolerance is not sewn across (neighbours_part). Each edge that moved records how far as its Solid.edgeTolerance(), as sewing records a gap; an end that could not move records how far it was left from the merged vertex.

A guard compares the result's health with this solid's. If it is worse — less closed, more free or non-manifold edges, or no faces left — healing retries with the face pass off; if that is still worse, this solid comes back as it was. guarded is set whenever the guard refused a fix. So a lone sliver sheet comes back as a face of two trims: its short ends merged, the sliver refused.

edges, faces and holes switch each kind of fix; a kind switched off is refused as toggled. tolerance null, NaN, infinite, zero or negative takes the default, 1e-4 times the diagonal; the report shows what was used. In the browser the reader module's Scene.healed returns the report only: heal the body through the blacksmith module's Solid.heal. A solid that cannot be read throws BuildError.

Solid.edgeTolerance()

edgeTolerance(edge: number): number | null

How far edge edge (a brep edge id, as a HealFix or FreeEdge names one) may lie off its curve: 0 for an exact edge, the distance healing or sewing moved it where that is recorded, null when no trim names the id (an edge healing removed). A solid that cannot be read throws BuildError.

Solid.recognize()

recognize(options?: RecognizeOptions): { solid: Solid; report: RecognizeReport }

This solid with its free-form surfaces and edge curves given their analytic kind, beside a RecognizeReport of what was taken and left, as a new Solid; this one is left as it was. A NURBS, revolved, extruded or swept surface that is a plane, cylinder, cone, sphere or torus within tolerance of every sample of its faces and every point of their edges becomes exactly that; an edge curve that is a line, circle or ellipse within it likewise, over the same stretch run the same way. So a file that stored its analytic faces as NURBS — a .3dm above all, and many STEP and SAT exports — comes back as it was made, and verbs that read a face's kind (a hole's axis, a fillet's radius) work on it.

Faces and edges keep their numbers, so a face or edge picked before is the same one after. The faces of one surface are taken together or not at all. A face given only by trims in its old surface's parameters (.3dm, IGES) is lifted to space edges first. Volume and area move by no more than the tolerance allows.

tolerance null, NaN, infinite, zero or negative takes the default, 1e-6 of the body's extent; the report shows what was used. Not the file's declared tolerance: at a STEP file's usual 0.01, a fillet's blend reads as a torus and the body's area moves by parts in a thousand. In the browser the reader module's Scene.recognized returns the report only: recognise the body through the blacksmith module's Solid.recognize. A solid that cannot be read throws BuildError.

Solid.tolerances

readonly tolerances: Tolerances

What this solid declares about its own precision, as Tolerances: read from its file, inherited through every verb from the loosest of its inputs, or set by Solid.withTolerances(); none in a field nothing declared. A verb given no tolerance works at blacksmith.effectiveTolerance(), which takes it into account.

Solid.withTolerances()

withTolerances(absolute?: number | null, angular?: number | null): Solid

A new solid: this one declaring absolute (a length) and angular (radians) instead of what it declared, its name, paint and marks kept. None or 0 declares nothing for that field; a negative or infinite value throws BuildError.

Solid.vertexTolerance()

vertexTolerance(point: ArrayLike<number>): number | null

How loose this solid's vertex at point is, where its producer said (an OCCT .brep records one per vertex): the tolerance of the nearest recorded vertex within its own tolerance of point. None where none is recorded there.

Solid.pushPull()

pushPull(face: number | Iterable<number>, distance: number, tolerance?: number | null, progress?: Progress | null): Solid

Face face pushed out by distance along its outward normal — pulled in, negative — as a face extrude does it: the prism over it joined on (cut out) at tolerance, and the flush faces merged, so a box's top raised is one taller box of six faces rather than a box and a prism with every side wall split at the seam. A face on a cylinder, a cone, a sphere or a torus moves out along its normal instead, as a press-pull does: the surface a step out — a boss fatter, a bore or a countersink narrower, a dome fuller — with the flat faces beside it carried along in their own planes. Any other curved face is refused, as is a curved face with anything but a plane it can follow beside it, reaching a cone's apex, pushed to its axis or centre, off a plane beside it or run into another edge. A flat face keeps its own colour where it now lies.

Several faces push together, as a press-pull on a selection: each by its own rule, one after another in the order given, each found again after the pushes before it renumbered the faces — a box's top and a side pushed 5 is the box 5 taller and 5 wider, a boss's top and wall the boss taller and fatter. A face on the same curved surface as one before it, and joined to it, moved with that one and is not pushed twice. No faces, or a face an earlier push took away, throws BuildError.

face is a face index or an iterable of them.

Solid.refillet()

refillet(face: number, radius: number, tolerance?: number | null): Solid

The round face belongs to — a fillet's bands, balls and rim bands joined to that face — made again at radius, as a press-pull on a fillet face: taken back to the sharp edges it replaced, and those rounded again, so the round is the one Solid.fillet() makes at that radius. Rounds of straight edges between planes (their ends square corners, mitres, balls, or a cylinder, cone or sphere the edge runs into — a D-cut shaft's top edge, a rib's into a boss) and of circular rims between a plane and a cylinder or cone (a boss's foot, a bore's mouth, a counterbore's step); a face that is not one, or a radius that does not fit, throws BuildError.

Solid.unfillet()

unfillet(face: number): Solid

The round face belongs to taken off, the faces beside it made sharp again, meeting on the edges the round replaced — the delete of a fillet face. The same rounds as Solid.refillet().

Solid.rechamfer()

rechamfer(face: number, distance: number, tolerance?: number | null): Solid

The chamfer face belongs to — its bevels (flat between two planes, cones round rims) and the corner triangles joined to that face — cut again at distance, as a press-pull on a chamfer face: taken back to the sharp edges it cut, and those bevelled again, so the chamfer is the one Solid.chamfer() cuts at that distance. A flat bevel's ends may run into a cylinder, cone or sphere, as a round's may. A face that is not a chamfer's bevel, or a distance that does not fit, throws BuildError.

Solid.unchamfer()

unchamfer(face: number): Solid

The chamfer face belongs to taken off, the faces beside it made sharp again — the delete of a chamfer face. The same chamfers as Solid.rechamfer().

Solid.faceRoundRadius()

faceRoundRadius(face: number): number

The radius of the round face belongs to — one Solid.unfillet() can take back — or 0 where it is none: only the cylinders, spheres and tori a fillet made are asked. A face the solid does not have throws BuildError.

Solid.faceChamferDistance()

faceChamferDistance(face: number): number

The distance of the chamfer face belongs to — one Solid.unchamfer() can take back — or 0 where it is none: only the planes and cones a chamfer made are asked. A face the solid does not have throws BuildError.

Solid.mergeFlush()

mergeFlush(): Solid

This solid with its flush faces merged: flat faces on one plane, facing one way and meeting along their edges — the seams Solid.join() leaves where two parts are flush — made one face, and the vertices left mid-way along a straight edge taken out.

Solid.split()

split(tool: Solid, tolerance?: number | null, progress?: Progress | null): Solid[]

This solid split by tool into bodies — returned as a list: a closed tool gives the parts outside it, then the parts inside; a flat sheet (a Solid.face()) splits by the whole plane it lies on. Each connected part is a body of its own, so a U cut across both arms is three. The new faces are pieces of the tool's, the colours carried over. A tool that does not cross the solid, or a curved sheet, throws BuildError. tolerance and progress as for Solid.join().

Solid.splitByPlane()

splitByPlane(plane: FrameLike, tolerance?: number | null, progress?: Progress | null): Solid[]

This solid split by the plane through plane's origin, square to its z (a frame): the bodies in front of it first, then those behind.

Solid.splitByProfile()

splitByProfile(profile: Profile, frame: FrameLike, tolerance?: number | null, progress?: Progress | null): Solid[]

This solid split by the closed Profile profile drawn on frame, pushed straight through it along the frame's z both ways — a split by a sketch profile: the bodies outside the profile first, then those inside. Where the plane lies along z does not matter, only the outline across it: a circle cores a sphere wherever it is drawn above it. The new faces are the profile's walls exactly. A profile that misses the solid, takes all of it or encloses nothing throws BuildError. tolerance and progress as for Solid.join().

Solid.lumps()

lumps(): Solid[]

This solid's connected bodies, each a solid of its own — faces sharing an edge are one body — in the order of their first faces. One body comes back as itself; a boolean that leaves two parts gives two.

Solid.merge()

merge(other: Solid, tolerance?: number | null, progress?: Progress | null): Solid

This solid and other as one body that keeps every piece — a union that keeps the inside pieces, as Rhino's MergeBreps: every face of both, split where they cross, the walls they share stored once. Its Solid.regions() are this solid less other, the two together and other less this one, those that are not empty; one solid inside the other gives the outer one with a void and the inner one, two solids apart give both. Faces keep the colours of the faces they are pieces of.

The body is non-manifold: where a wall between two cells meets the outside, an edge has three or four faces. The verbs that need a manifold solid — Solid.join(), Solid.cut(), Solid.common(), the splits and trims, Solid.fillet(), Solid.chamfer(), Solid.shell(), Solid.thicken(), Solid.mass() and the STEP writer — refuse it and name the way out: take each cell with Solid.regionSolid().

Built exactly, on the exact boolean route: both solids closed, every face a plane, cylinder, cone, sphere or torus. A face of any other kind throws BuildError, naming it; so do walls of the two lying on one another in part (two boxes sharing part of a side, equal solids) — a case the exact route does not take yet, refused in words, with no mesh fallback. tolerance (0.05 by default) is the resolution the sections are found to; progress as for Solid.join().

Solid.draft()

draft(faces: number | Iterable<number>, plane: FrameLike, angle: number, tolerance?: number | null, progress?: Progress | null): Solid

Faces faces drafted to angle (radians) against the pull direction plane's z, about the neutral plane through plane's origin square to it — OCCT's BRepOffsetAPI_DraftAngle, Fusion's Draft. angle is each face's new draft angle, absolute, in (-pi/2, pi/2): asin(n . d), n the face's outward normal and d the pull, so it is positive where the face looks partly along the pull — an outer wall narrowing towards +z, a hole widening. A plane turns about the line where it crosses the neutral plane, which stays where it was; a cylinder along the pull becomes the cone through the circle it cuts there (a cone along the pull the same from its own circle). The faces beside a drafted one follow it, every vertex moving onto the drafted faces and the planes it lay on, a vertex in the neutral plane not at all; the faces keep their order, colours and marks. A face parallel to the neutral plane, a cylinder across the pull, a sphere, torus or free-form face, a curved neighbour not drafted with it, a hole through a drafted plane, a face that closes up at the angle asked, or a result that does not close throws BuildError. tolerance and progress as for Solid.join().

Solid.draftTwoSided()

draftTwoSided(faces: number | Iterable<number>, plane: FrameLike, above: number, below: number, tolerance?: number | null, progress?: Progress | null): Solid

Faces faces drafted both ways from the neutral plane plane — a parting line: above it (along its z) to above against +z, below it to below against -z, so for positive angles both halves narrow away from the plane; above == below is Fusion's symmetric draft. A face wholly on one side is drafted as Solid.draft() drafts it; otherwise the solid is split by the plane, each side drafted, and the halves joined back on their cut faces, the faces the plane cut in two made one again. The faces come back in the join's order, each keeping its colour, a drafted half its face's. What Solid.draft() refuses throws BuildError here too.

Solid.draftAngleAt()

draftAngleAt(face: number, point: Point3, pull: Point3): DraftPoint

The point of face face nearest point and the draft angle there against the pull direction pull (normalised), as a DraftPoint — Rhino's BrepFace.DraftAnglePoint. The angle is Solid.draft()'s, asin(n . d): +pi/2 a top, 0 a wall along the pull, -pi/2 a bottom; a point on the face's boundary reads the face's own normal there, not the mean of the faces meeting. A face index out of range, a point not finite, or a pull zero or not finite throws BuildError.

Solid.draftAnalysis()

draftAnalysis(pull: Point3, threshold?: number, tolerance?: number | null): FaceDraft[]

Every face's draft against pull (normalised), one FaceDraft per face in face order — Fusion's draft analysis. The body is meshed at tolerance (none: the effective one); each triangle's angle is read exactly at its centre and its area banded by threshold (radians, in [0, pi/2), 1 degree by default) into positive, negative and vertical; a triangle drafting either way casts a ray along the way it releases, and one that meets the body is undercut — a ledge under an overhang. A pull zero or not finite, a threshold out of range, or a negative tolerance throws BuildError.

Solid.sheetBase()

static sheetBase(profile: Profile, rule: SheetRule, frame?: FrameLike | null, tolerance?: number | null): Solid

The base flange: profile as a flat sheet under frame (none: the world's xy), its top in the frame's plane and the sheet the SheetRule's thickness below it — Fusion's Flange from a sketch, Inventor's Face. A rule out of range throws BuildError.

Solid.sheetContour()

static sheetContour(path: Iterable<Point2>, width: number, rule: SheetRule, frame?: FrameLike | null, tolerance?: number | null): Solid

A contour flange: the open path path (points in frame's plane, the sheet seen edge on) swept width along the frame's z, each corner a bend of the rule's radius. A path of fewer than two points, a corner too tight for the bend, or a width not positive throws BuildError.

Solid.sheetLoftedFlange()

static sheetLoftedFlange(a: Iterable<Point3>, b: Iterable<Point3>, rule: SheetRule, tolerance?: number | null): Solid

A lofted flange between the open polylines a and b (points, at least two each), the sheet's top face — Fusion's Lofted Flange, press-brake style: the strip between them is cut into facets (neighbours in one plane merged), every crease a bend of the rule's radius, so the part reads and unfolds like any other. Sample an arc into as many points as facets wanted (a square-to-round is a square's sides and a sampled circle). The sheet lies under the facets' normal, along a crossed with towards b: reverse both to put it on the other side. Each facet is cut back by its bends' set-backs and each bend zone ends square a little inside its facets, so the outline steps in at each end of a crease. Fewer than two points, a repeated point, a facet with no area, or a facet its bends' set-backs leave nothing of (fewer facets or a smaller radius) throws BuildError.

Solid.sheetFlange()

sheetFlange(edges: Iterable<Edge | number>, angle: number, length: number, rule: SheetRule, offsets?: [number, number] | null, tolerance?: number | null): Solid

Edge flanges on edges (edges of a broad face of a sheet body), each turned angle radians (> 0 up, towards the side the edge's face looks) and length high outside, bent at the rule's radius. offsets none for flanges the full length of their edges, else how far in each starts from its edge's two ends, the rule's bend relief cut there. Two flanges meeting at a corner are mitred with the rule's gap. An edge not on a broad face's rim, a body that is not sheet metal, an angle out of range or a length shorter than the bend throws BuildError.

Solid.sheetHem()

sheetHem(edges: Iterable<Edge | number>, kind: HemKind, length: number, rule: SheetRule, gap?: number, angle?: number, tolerance?: number | null): Solid

Hems on edges: kind flat (the lip folded flat on the sheet), open (folded back with a gap), rolled (rolled round through angle, 0: 1.5 pi), teardrop, rope (curled round a rod gap across until it comes back down to the sheet) or double (folded twice and pressed flat, three layers); length the lip (a rope hem has none), gap the gap inside (0: the thickness). What Solid.sheetFlange() refuses throws BuildError here too.

Solid.sheetFold()

sheetFold(face: number, line: [Point3, Point3] | ArrayLike<number>, angle: number, rule: SheetRule, tolerance?: number | null): Solid

A bend on the line through the two points line across the flat broad face face: the material on the line's left, seen from the face's outside, turned angle radians — Fusion's Bend. A face that is not a flat broad face, a line that does not cross it, or a fold through another bend throws BuildError.

Solid.sheetRip()

sheetRip(edges: Iterable<Edge | number>, gap?: number, tolerance?: number | null): Solid

Rips along edges (sharp edges between two walls of a shelled solid): a slot gap wide (0: a tenth of the wall) through the wall, so Solid.sheetConvert() can lay a closed box flat.

Solid.sheetConvert()

sheetConvert(fixedFace: number, rule: SheetRule, tolerance?: number | null): Solid

A shelled solid of constant thickness made sheet metal from fixed_face: every sharp edge between two flat broad faces becomes a bend of the rule's radius, the outside kept — Fusion's Convert to Sheet Metal. A solid not of one thickness, or a closed loop of walls that needs a rip first, throws BuildError.

Solid.sheetCornerRelief()

sheetCornerRelief(rule: SheetRule, tolerance?: number | null): Solid

The rule's corner relief (square, round or tear, its size) cut at every corner where two bend zones end close together.

Solid.sheetRipPoints()

sheetRipPoints(face: number, a: Point3, b: Point3, gap?: number, tolerance?: number | null): Solid

A rip from point a to point b on the flat broad face face — Fusion's point-to-point rip: a slot gap wide (0: a tenth of the thickness) cut through that wall only. An end on the face's outline breaks through it; an end inside the face stops there, a slit. Works on any body of one thickness, folded or not. A face that is not a flat broad face, or a point off it, throws BuildError.

Solid.sheetRipFace()

sheetRipFace(face: number, tolerance?: number | null): Solid

The wall under the broad face face (flat or a bend) removed through the thickness — Fusion's face rip: a closed box opened, a bend ripped out between its two walls. A face that is not a broad face, or a rip that leaves nothing, throws BuildError.

Solid.sheetJoin()

sheetJoin(edgeA: Edge | number, edgeB: Edge | number, rule: SheetRule, tolerance?: number | null): Solid

Two walls joined by a bend of the rule's radius — Fusion's Join by Bend. edge_a and edge_b are outline edges where each wall's broad face meets its square end, parallel and of one extent: each wall runs on to the other's far face, which makes one sharp corner with the outer faces meeting on the mould line, and the corner is bent, both legs kept to that line. Walls in one plane facing each other are joined flat. Two parts are Solid.join()ed into one body first. Edges that are not wall ends, not parallel or of different extent, walls that overlap or lie parallel in two planes, or a rule thickness not the walls', throws BuildError.

Solid.sheetFillet()

sheetFillet(edges: Iterable<Edge | number>, radius: number, rule: SheetRule, tolerance?: number | null): Solid

Rounds of radius on thickness edges (straight edges across the sheet where two of its sides meet, at a corner of the outline, on a flat region) — Fusion's sheet-metal fillet. Each is a corner of the flat pattern: rounded there (cut on a convex corner, filled on a concave one) and the part folded again, so it stays sheet metal and Solid.flatPattern() lays the round flat. An edge that is not a thickness edge, an edge on a bend, or a round that runs past the sides beside it throws BuildError.

Solid.sheetChamfer()

sheetChamfer(edges: Iterable<Edge | number>, distance: number, rule: SheetRule, tolerance?: number | null): Solid

Chamfers distance along both sides on thickness edges, laid into the flat pattern as Solid.sheetFillet() lays its rounds. What it refuses throws BuildError here too.

Solid.isSheetMetal()

isSheetMetal(tolerance?: number | null): boolean

Whether the body reads as sheet metal: two broad sides of constant thickness, flat faces and cylindrical bends, side faces one thickness wide.

Solid.sheetBendFaces()

sheetBendFaces(tolerance?: number | null): number[]

The faces of every bend, two a bend (inner and outer). A body that is not sheet metal throws BuildError.

Solid.sheetInfo()

sheetInfo(fixedFace?: number | null, tolerance?: number | null): SheetInfo

The body read as sheet metal from fixed_face (none: its largest flat broad face), as a SheetInfo: its thickness, the face it is laid from, and every bend as a BendInfo. A body that is not sheet metal throws BuildError.

Solid.flatPattern()

flatPattern(fixedFace: number, rule: SheetRule, tolerance?: number | null): FlatPattern

The body unfolded from the flat broad face fixed_face under the rule, as a FlatPattern: every bend laid flat at its allowance |angle| (R + K T) — OCCT has no sheet metal; Fusion's and Inventor's Flat Pattern. A body that is not sheet metal, a face that is not a flat broad face, a rule thickness not the body's, or a flat that overlaps itself throws BuildError.

Solid.foldFlat()

static foldFlat(profile: Profile, bends: Iterable<Bend>, rule: SheetRule, frame?: FrameLike | null, tolerance?: number | null): Solid

A flat outline folded: profile under frame (none: the world's xy), each of bends (a Bend) a bend — a FlatPattern's outline and fold bends, edited and folded again. A bend line that does not cross the outline, or two bends crossing, throws BuildError.

Solid.unroll()

unroll(faces?: Iterable<number> | null, curves?: Iterable<NurbsCurve>, points?: Iterable<Point3>, explode?: boolean, tolerance?: number | null): Unrolled

Faces faces (none: all) laid flat in the xy plane, as an Unrolled — Rhino's Unroller. Planes, cylinders and cones unroll exactly, any other surface whose Gaussian curvature vanishes within tolerance by its own flattening. Faces sharing an edge stay joined unless joined they would overlap (or explode), the largest face placed first. curves follow onto the flat, in pieces where they cross a cut, and points to their spots. A face that is not developable is left out and reported, never stretched. A face out of range, or no developable face, throws BuildError.

Solid.squish()

squish(faces?: Iterable<number> | null, curves?: Iterable<NurbsCurve>, points?: Iterable<Point3>, explode?: boolean, deformation?: SquishDeformation, preserveBoundary?: boolean, tolerance?: number | null): Squished

Faces faces (none: all) laid flat in the xy plane with the least distortion, developable or not, as a Squished — Rhino's Squisher, the companion to Solid.unroll(). Faces sharing an edge flatten together unless explode; a group whose faces are all developable is laid exactly as Solid.unroll() lays it, the others are meshed finely and relaxed (a conformal start, then an energy over each triangle's stretch). deformation reads from the flat to the shape, as Rhino's: "free", "stretch_mostly" and "stretch_only" (flat lengths at most their 3D lengths: the pattern stretches to cover the shape), "compress_mostly" and "compress_only" (at least); *only* holds in every triangle in every direction. preserve_boundary (on by default) keeps the outline's length. curves follow onto the flat (in pieces where they leave the faces), points to their spots. A face out of range, a bad deformation, or faces that close on themselves (a closed surface has no edge to open from) throws BuildError.

Solid.regions()

regions(): Region[]

The regions of space this solid's faces bound, as Region values — Rhino's GetRegions, computed on demand from the faces' order round every edge. Region 0 is the infinite one, the outside; the finite ones follow in a fixed order, so the same body gives the same list. An ordinary solid has two (the outside, in front of every face, and the inside, behind them), a Solid.merge() one per cell, a solid with a cavity three (the cavity is a region of its own).

Each region lists its sides as FaceSide values: a face and its sense, +1 where the region is the side the face's normal points to, -1 the other — a solid's own inside is behind its faces, at -1. Its shells come outer boundary first, then one per void inside it. Faces that leave an edge the same way (tangent along it, to the second order) throws BuildError.

Solid.regionSolid()

regionSolid(region: number): Solid

Finite region region (an index into Solid.regions()) as a closed solid of its own — Rhino's BrepRegion.BoundaryBrep: the faces bounding it, each turned to point out of it, each keeping its colour. A Solid.merge()'s cells come out one at a time this way, ready for Solid.mass() and the booleans. A closed manifold unless the region touches itself along an edge. Region 0 (the infinite region) or a region past the count throws BuildError.

Finishing

Solid.edges()

edges(): Edge[]

The solid's edges as Edge values — what Solid.fillet() and Solid.chamfer() take. Copied; safe to keep.

Solid.fillet()

fillet(edges: Iterable<Edge | number>, radius: number, tolerance?: number | null, progress?: Progress | null, radiusEnd?: number | null): Solid

Round the given edges (Edge values or their indices) with radius. Exact: the blend faces are cylinders, tori and NURBS, and the neighbours are trimmed back onto them. A spline edge — the crease between two faces on NURBS surfaces, running from one free edge of the shell to another, as between a fender patch and a door patch — is rounded by a ball rolled along it, the two faces cut back to where it touches them, in a call of its own (not with straight or circular edges); tolerance is then the fillet surface's fit. radius_end (spline edges only) runs the radius linearly from radius to it in arc length along the edge. A spline edge ending where other shared edges meet, a closed one, or a varying radius on a straight or circular edge throws BuildError.

Solid.filletLaw()

filletLaw(edges: Iterable<Edge | number>, law: Iterable<[number, number]>, tolerance?: number | null): Solid

Round a chain of spline edges (Edge values or their indices) with the radius following a law: law is the radius at stations along the chain, each (share, radius) — the share of the chain's arc length from its start, 0 to 1 — run through smoothly by a monotone cubic, so the radius never swings past its stations, and held flat before the first station and after the last. [(0, 4), (1, 12)] grows from 4 at one end to 12 at the other, as a car's shoulder fillet does. The edges must run end to end into one open chain, each running on tangent into the next; the chain runs the way the first edge's curve does. Where the faces either side change from one edge to the next they must meet smooth along a seam through the vertex between, and the fillets meet on one shared end there. tolerance is the fillet surfaces' fit. Straight or circular edges, a branching or closed chain, or edges meeting at an angle throws BuildError.

Solid.chamfer()

chamfer(edges: Iterable<Edge | number>, distance: number, tolerance?: number | null): Solid

A flat bevel instead of a round: each edge cut back distance along both its faces.

Solid.shell()

shell(thickness: number, open?: Iterable<number>, tolerance?: number | null, progress?: Progress | null): Solid

Hollow the solid to walls thickness thick — inward for a positive thickness, outward (the solid becoming the cavity) for a negative one. The faces listed in open are removed so the hollow is reachable.

Solid.thicken()

thicken(thickness: number, tolerance?: number | null, progress?: Progress | null): Solid

A sheet made a solid thickness thick: its faces, their twins moved thickness along the faces' normals (against them for a negative thickness), and a wall round every open edge. Two faces of a folded sheet meet on their offsets' mitre; a closed sheet thickens to a hollow. Free-form (NURBS) faces offset by a fit held to tolerance. A thickness a face cannot take — a radius used up, a free-form offset folding over — throws BuildError.

Solid.offset()

offset(distance: number, tolerance?: number | null): Solid

This solid offset by distance: every face moved along its outward normal — outward for a positive distance, inward for a negative one — and the moved faces' new neighbours meeting at sharp joins, on their offsets' intersection (no rounded joins). A closed solid grows or shrinks to the solid its moved skin bounds; an open sheet moves to its twin, its rims left open. Each face keeps the colour, id and attributes of the face it was moved from, however far it moved; edges are matched by position. A face the offset uses up is gone, its neighbours meeting sharp. Free-form faces are fitted within tolerance (none: the solid's effective tolerance). A distance that is 0, NaN or infinite, a face that folds over, or a skin the offset leaves open throws BuildError.

Solid.offsetFace()

offsetFace(face: number, distance: number, tolerance?: number | null): Solid

Face face alone, as an open sheet moved distance along its outward normal (against it for a negative distance), still facing this solid's way, in the face's own colour: Solid.faceSheet() then Solid.offset(). A face closed on itself — a sphere's only face — gives a closed solid. tolerance as for Solid.offset(). A face this solid has not, a distance that is 0, NaN or infinite, or an offset that folds over throws BuildError.

Asking

Solid.faces

readonly faces: number

How many faces.

Solid.faceKind()

faceKind(face: number): string

A face's surface: plane, cylinder, cone, sphere, torus, nurbs, revolution, extrusion or other.

Solid.selectFace()

selectFace(selector: Selector): number

The index of the face a Selector picks.

Solid.faceFrame()

faceFrame(face: number): number[]

The frame on a face: origin at its centre, z its outward normal, x world X laid onto the face (world Y on a face facing close to X) — Frame.at()'s rule, so the top of a box gets the XY plane's axes. What Workplane.workplane() moves onto.

Solid.faceRef()

faceRef(face: number): number[]

A face by what it is, eight numbers: the surface's kind (plane 0, cylinder 1, cone 2, sphere 3, torus 4, NURBS 5, revolution 6, extrusion 7, sum 8), a point on the surface at the face's middle (x, y, z), the outward normal there (x, y, z), and the face's extent. What a feature made on a face keeps — a sketch on it, a shell's opening — so the face is found again with Solid.findFace() when the solid is rebuilt with its faces moved, split or renumbered. Take it before any move you apply to the solid, and look it up on the unmoved one.

Solid.findFace()

findFace(faceRef: Iterable<number>, hint?: number | null, tolerance?: number | null): number | null

The face a reference from Solid.faceRef() refers to: among the faces of that kind whose surface passes through the point, facing the same way, the one the point lies in — or, where it lies in none (the face shrank away, a hole opened under it), the one whose boundary comes nearest. hint is the index the face had, preferred among faces that fit equally well; tolerance how far the point may sit off a surface to still be on it. None where the face is gone.

Solid.bounds

readonly bounds: [number[], number[]]

The axis-aligned box, at the same cost whatever the solid's size: its mesh at a thousandth of its own extent, in double, so the box is inside the exact one and short of it by at most that. Worked out once per solid, apart from the tessellation Solid.mesh() caches. Solid.boundsAt() is the box of the mesh at a tolerance you name.

Solid.boundsAt()

boundsAt(tolerance: number): [number[], number[]]

The bounds over the tessellation at tolerance — the same cache Solid.mesh() fills, so asking both costs one mesh.

Solid.bounds64

readonly bounds64: [number[], number[]]
boundsAt64(tolerance: number): [number[], number[]]

Solid.bounds in double precision: the axis-aligned bounds over the mesh's unnarrowed positions at tolerance (0.05 where the language defaults it) — exact far from the origin, where Solid.bounds's float32 mesh is not.

Solid.leakedEdges()

leakedEdges(tolerance?: number | null): number

How many mesh edges at tolerance are bound by anything other than two triangles: zero for a closed solid. A seam two solids share along a line does not count; a hole or a fold does.

Solid.unpairedEdges()

unpairedEdges(tolerance?: number | null): number

How many mesh edges have triangle uses that do not cancel out: zero for a closed, consistently oriented solid. Unlike Solid.leakedEdges() this catches a fold — two triangles running the same way.

Solid.isWatertight()

isWatertight(tolerance?: number | null): boolean

Whether Solid.leakedEdges() is zero.

Solid.manifold

readonly manifold: Manifold

Whether the faces make a manifold — every edge bordered by one face or two, the faces round every vertex one fan — and whether it is closed, as a Manifold. Read off the solid's topology, not a mesh, so it takes no tolerance; whether the faces all face out is Solid.unpairedEdges()'s question.

Solid.edgeBeziers()

edgeBeziers(tolerance?: number | null): Float64Array

The edges as rational cubic Béziers, sixteen numbers each — x, y, z, w per control point, the point Cartesian and its weight beside it, the record a profile's Béziers use — what a viewer draws the edges by: exact where an edge's curve has a Bézier form (a line one Bézier, a circle quarter-turn conics, a spline its own pieces), flattened within tolerance where it has none (left out: the solid's effective tolerance). A tolerance negative or infinite throws BuildError.

Solid.isocurveBeziers()

isocurveBeziers(density?: number, tolerance?: number | null): Float64Array

The faces' isoparametric curves as Béziers, sixteen numbers each as Solid.edgeBeziers() gives them: density interior lines each way on every curved face, clipped to the face, plus the lines at the ends of its parameter span; a flat face draws none. Exact where the surface has a closed form for the line (a cylinder's rings are circles), flattened within tolerance elsewhere.

Solid.faceIsoIntervals()

faceIsoIntervals(face: number, alongU: boolean, at: number): [number, number][]

The intervals of the swept parameter along which face face's isocurve lies inside its trims, as Rhino's TrimAwareIsoIntervals, ascending, as (start, end) pairs: along u at v = at when along_u, else along v at u = at. NurbsCurve.faceIsocurves() gives the pieces as curves. A face past the end or an at not finite throws BuildError.

Solid.mass()

mass(accuracy?: number): Mass

What this solid measures, per unit density, as a Mass: area, volume, centroid, the inertia tensor about the centroid and its principal moments and axes — each figure beside a bound on its own error. Measured on the exact surfaces, refined until every error is under accuracy (a share of the figure) or the refinement gives up, which Mass.accuracyMet reports; the values are honest either way, they are simply less certain, and the errors say by how much. Volume, centroid and inertia mean something only where the body is closed — Mass.closed — and a body whose faces all point inward is measured as if they did not, which Mass.inverted says. An accuracy not positive and finite throws BuildError.

Solid.orientedBox()

orientedBox(accuracy?: number): OrientedBox

This closed solid's box on its principal axes, as an OrientedBox. The axes are the inertia's, so the box is tight along a clear long direction but not the minimal box in general; where two moments are equal (a cube, a cylinder about its axis) any axes in that plane are as principal as the others, so which come back is a free choice. The half-extents are grown by the tolerance the measurement settled on, so they hold the body and may exceed its own extent by about that much. It costs as much as Solid.mass() at the same accuracy, because the axes come from the same inertia: tens of seconds at 1e-7 on a free-form body read from a file. accuracy is relative, and 0 or less asks for the box's own default, 1e-5 — not measure.default_accuracy — because a finer one buys little box: the half-extents are grown by the diagonal times the larger of accuracy and a sixteenth of the integration's tolerance, which starts at 5e-4 of the diagonal, so a body that settles at once (planes, cylinders, cones) is grown by about 3.1e-5 of its diagonal however fine the accuracy. A coarser accuracy (1e-3, say) is the fast route. An open body has no oriented box, and an accuracy that is NaN or infinite throws BuildError.

Solid.edgeLength()

edgeLength(edge: number, accuracy?: number): Length

The length of one edge over its own range, as a Length: edge is the index Solid.edges() uses (Python also takes the Edge itself), and accuracy the relative accuracy, 0 asking for measure.default_accuracy. An edge past the end, or one with no curve to measure, throws BuildError. A body whose trims are 2D-only (Rhino .3dm, IGES entity 144) has no fillet-table edges at all, so this cannot be asked of it.

Solid.edgePointAtLength()

edgePointAtLength(edge: number, s: number, accuracy?: number): At

The point at arc length s along one edge, as an At: s is absolute, measured from the start of the edge's own range (the t0 of its Edge.curve), and lies in [0, length] — past either end by no more than the length's own error is that end, further throws BuildError. edge is the index Solid.edges() uses (Python also takes the Edge itself); accuracy is relative, 0 or less asking for measure.default_accuracy. The sample's segment is empty on an edge. An edge past the end or with no exact curve, or an accuracy NaN, infinite or 1 or more, throws BuildError.

Solid.edgeDivideByCount()

edgeDivideByCount(edge: number, n: number, accuracy?: number): At[]

One edge in n pieces of equal arc length, as a list of At: an open edge gives n + 1 samples from its start to its end, a closed one (its range the curve's whole closed loop: a whole circle or ellipse, a closed spline's whole domain) n, never its start again. The first sample is exactly the range's start and an open edge's last exactly its end. n is 1 to 1,000,000; accuracy as Solid.edgePointAtLength(), and so are the refusals.

Solid.edgeDivideByLength()

edgeDivideByLength(edge: number, step: number, accuracy?: number): At[]

Samples of one edge every step of arc length from its start, as a list of At. The last piece is whatever is left over, kept short: an open edge's end is a sample only where a step lands on it (to within the length's error), and a closed edge never repeats its start. A step longer than the edge gives the start alone. step is positive and finite and may give at most 999,999 steps; accuracy as Solid.edgePointAtLength(), and so are the refusals.

Solid.loftCurves()

static loftCurves(sections: Iterable<NurbsCurve>, degree?: number, loose?: boolean, closed?: boolean): Solid

A sheet lofted through sections (NurbsCurves): one face on one NURBS surface whose u runs along the sections and v across them, degree across them (lowered to what the sections allow). loose=True shapes it by the sections instead — through the first and last only, smoother between; closed=True makes it periodic across them, the last section back to the first. Fewer than two sections (three closed) throws BuildError.

Solid.sweepRail()

static sweepRail(rail: NurbsCurve, sections: Iterable<NurbsCurve>, frame?: SweepFrame, up?: Point3 | null, tolerance?: number | null): Solid

A sheet of sections swept along rail: each section carried by the rail's frame from the rail point nearest its centre, the sections between blended by their place along the rail. frame="rmf" turns the sections no more than the rail makes them (rotation-minimising); "fixed" keeps up upright, as a sweep along a car's side does. Fitted through enough stations to lie within tolerance of that definition; Solid.sheetError says how close it came.

Solid.sweepTwoRails()

static sweepTwoRails(railA: NurbsCurve, railB: NurbsCurve, sections: Iterable<NurbsCurve>, tolerance?: number | null): Solid

A sheet of sections swept between two rails: each section's first end on rail_a and its last on rail_b, carried by the rotation and uniform scale that keep them there, the rails matched by arc length (so a section spreads as the rails do). A section whose ends are not on the rails throws BuildError. Fitted within tolerance (Solid.sheetError).

Solid.edgeSurface()

static edgeSurface(curves: Iterable<NurbsCurve>, tolerance?: number | null): Solid

The Coons sheet of 2, 3 or 4 boundary curves meeting end to end within tolerance, given in order round the boundary (each either way round): three leave the fourth side a point, two give the ruled sheet between them. Exact for non-rational boundaries; rational ones (arcs) are fitted first, and Solid.sheetError is that fit's error. Curves that do not meet throws BuildError.

Solid.networkSurface()

static networkSurface(uCurves: Iterable<NurbsCurve>, vCurves: Iterable<NurbsCurve>, tolerance?: number | null): Solid

The Gordon sheet of a curve network: u_curves in order across one way, v_curves across the other, every one of the first crossing every one of the second within tolerance. The curves are re-fitted so their crossings share parameters, then blended; Solid.sheetError is the largest distance from the sheet to the curves given. A pair that does not cross throws BuildError, naming both.

Solid.continuity()

continuity(side: SheetSide, other: Solid, otherSide: SheetSide, face?: number, otherFace?: number, samples?: number): Continuity

How well this solid's face face meets other's face other_face along their sides — a side is "u0", "u1", "v0" or "v1", a boundary isocurve of the face's NURBS surface — as a Continuity: the largest gap between the sides (G0), the largest angle between their normals (G1), the largest difference of curvature across the edge (G2), each with where it is, from samples points along the first side. A face that is not NURBS, or a side that is not one of the four, throws BuildError.

Solid.edgeContinuity()

edgeContinuity(edge: Edge | number, samples?: number): Continuity

How well the two faces of edge edge (an Edge or its index) meet along it, as a Continuity: samples points along the edge, each projected onto both faces, and the largest gap between the two (G0), angle between the faces' normals (G1; each normal the way its face faces, so a square crease reads pi/2) and difference of their normal curvatures across the edge (G2), each with where it is. Any two faces of one body, of any kind of surface — where Solid.continuity() compares two NURBS faces' sides. A test fails a design on these: a G1 seam reads an angle near 0, a G2 one a curvature near 0 too. An edge bounding one face, or three, throws BuildError.

Solid.faired()

faired(tolerance?: number | null, degree?: number, controls?: [number, number] | null, keep?: SheetKeep, noInflection?: 'u' | 'v' | 'uv' | null, face?: number): Solid

Face face faired, as a sheet of its own: the smoothest surface within tolerance of its NURBS surface — least squares plus its third derivatives squared, what a zebra's ripple costs, weighed as heavily as the tolerance allows — so a sheet lofted through traced sections comes back calm between them. controls none fairs on the face's own net, its degree raised to degree (3 to 7) and its spans split to a dozen each way at least, keeping a kept side exactly; (n_u, n_v) fairs on a uniform net that size, its kept sides within the tolerance. keep says what each side keeps, one level for all four or one per side ("u0", "u1", "v0", "v1"): none free to move, 0 its position, 1 the tangent plane across it, 2 its curvature too — what Solid.match() gave it. no_inflection "u", "v" or "uv" holds the isocurves along those directions from turning their curvature over. Solid.sheetError is the largest distance between the two surfaces. A rational face, a degree outside 3 to 7, or a tolerance no such fair is within throws BuildError, the last with the nearest distance found.

Solid.curvatureTurns()

curvatureTurns(face?: number, samples?: number): CurvatureTurns

Where face face's Gaussian and mean curvature change sign, on a grid of samples steps each way over its surface (8 at fewest), as a CurvatureTurns: how many separate areas of each sign, and the points between opposite signs. A dome or a saddle reads one area and no turn; a sheet whose sections wobble reads several — the surface's NurbsCurve.inflections(). A face index out of range throws BuildError.

Solid.highlightKink()

highlightKink(edge: Edge | number, samples?: number): HighlightKink

The worst kink of the highlight lines crossing edge edge (an Edge or its index), at samples points along it, as a HighlightKink: the lines of straight light tubes a body's size away from the surface, every tube direction tried. They run on through an edge where the two faces' curvatures agree (G2) and kink where it jumps — a fillet's seam beside a flat face. Beside Solid.edgeContinuity()'s curvature jump, this is the number a zebra shows. An edge bounding one face, or three, throws BuildError.

Solid.facePoint()

facePoint(face: number, p: Point3, tolerance?: number | null): FacePoint

Where point p lies against face face, as a FacePoint: its nearest point of the face (exact, inside the trims or on their boundary) and where — inside, on the boundary (on an edge or a vertex of the face, or within tolerance of one) or off (farther than tolerance). Fusion's isPointOnFace is "not off"; Rhino's IsPointOnFace the same three. tolerance none (or 0) is the solid's blacksmith.effectiveTolerance(). A face out of range, a point not finite or a tolerance negative or infinite throws BuildError.

Solid.faceInnerPoint()

faceInnerPoint(face: number): FacePoint

A point strictly inside face face's trims, on its surface, as a FacePoint (inside, distance 0) — Fusion's pointOnFace. A face out of range, or one where no point inside is found, throws BuildError.

Solid.edgePoint()

edgePoint(edge: Edge | number, p: Point3, tolerance?: number | null): EdgePoint

The nearest point to p of edge edge (an Edge or its index) on its own curve over its range, as an EdgePoint: the point, the curve's parameter t there (as Solid.edgeClosestPoint()'s) and on where it is within tolerance (none: the solid's blacksmith.effectiveTolerance()). An edge out of range, a point not finite or a tolerance negative or infinite throws BuildError.

Solid.edgeInnerPoint()

edgeInnerPoint(edge: Edge | number): EdgePoint

A point on edge edge: its curve at the middle of its range (a whole circle half a turn from its start), as an EdgePoint — Fusion's pointOnEdge. An edge out of range throws BuildError.

Solid.faceSize()

faceSize(face: number): [number, number]

The width and height of the rectangle face face would flatten to — Rhino's GetSurfaceSize: over the uv box its trims span, the longest of five u-isocurves and the longest of five v-isocurves. A face out of range throws BuildError.

Solid.edgeConvexity()

edgeConvexity(edge: Edge | number, angularTolerance?: number | null, samples?: number): EdgeConvexity

How edge edge's two faces meet along it, at samples points (16 at fewest), as an EdgeConvexity: smooth (within angular_tolerance of tangent everywhere), convex (a ridge), concave (a valley), mixed (both along it) or open (one face, or three and more), with the smallest and largest signed turn between the faces' normals. angular_tolerance none (or 0) is the angle the solid declares, else the option tolerance.angular (see blacksmith.setOption()). An edge out of range, or an angular tolerance negative, infinite or not below a right angle, throws BuildError.

Solid.edgesConvexity()

edgesConvexity(angularTolerance?: number | null): Convexity[]

Every edge's convexity kind (as Solid.edgeConvexity()'s, at 16 samples), in the order of Solid.edges().

Solid.concaveEdges()

concaveEdges(angularTolerance?: number | null): number[]

The indices of the edges whose faces meet concave all along — Fusion's concaveEdges.

Solid.convexEdges()

convexEdges(angularTolerance?: number | null): number[]

The indices of the edges whose faces meet convex all along — Fusion's convexEdges.

Solid.tangentFaces()

tangentFaces(face: number, angularTolerance?: number | null): number[]

Face face and every face reached from it across edges whose faces meet smoothly (Solid.edgeConvexity() smooth at angular_tolerance): breadth first, the face first, then each face's new neighbours ascending — Fusion's tangentiallyConnectedFaces. A face out of range throws BuildError.

Solid.tangentEdges()

tangentEdges(edge: Edge | number, angularTolerance?: number | null): number[]

Edge edge and every edge reached from it through vertices where two edges' curves run on with the same tangent, in the order found (the edge first) — Fusion's tangentiallyConnectedEdges. An edge out of range throws BuildError.

Solid.tangentFaceGroups()

tangentFaceGroups(angularTolerance?: number | null): number[][]

The faces in groups joined smoothly (as Solid.tangentFaces()), each group's faces ascending, the groups in the order of their lowest face — Rhino's GetTangentConnectedComponents, as face groups.

Solid.angleTo()

angleTo(kind: AngleEntity, index: Edge | number, other: Solid, otherKind: AngleEntity, otherIndex: Edge | number): Angle

The angle between this solid's face or edge index and other's (other may be this solid), as an Angle: a planar face is read as its plane, a cylinder's, cone's or revolved face as its axis, a straight edge as its line, a circular edge as its circle's plane — Fusion's measureAngle. Two planes read the angle between their outward normals (0 to pi), two lines between their directions (0 to pi), a line and a plane the line's angle to the plane (0 to pi/2). Any other face or edge, or an index out of range, throws BuildError.

Solid.faceMinimumRadius()

faceMinimumRadius(face: number, samples?: number): MinimumRadius

Face face's smallest radius of curvature, 1 / max(|k1|, |k2|), as a MinimumRadius: a plane infinite, a cylinder or a sphere its radius, a cone and a torus in closed form over the face's trims, any other face on a grid of samples steps each way (16 at fewest) polished at its tightest — Fusion's MinimumRadiusAnalyses. A face out of range throws BuildError.

Solid.match()

match(side: SheetSide, other: Solid, otherSide: SheetSide, level?: number, face?: number, otherFace?: number): Solid

Face face as a sheet of its own, its side side bent to meet other's other_side at Glevel: 0 onto the other side, 1 into its tangent plane, 2 with its curvature too. The opposite side stays where it was; the face is refined across the edge first if it has too few rows. Both faces non-rational NURBS: a rational one, or a level outside 0 to 2, throws BuildError.

Solid.filletSurfaces()

static filletSurfaces(a: Solid, b: Solid, radius: number, radiusEnd?: number | null, flipA?: boolean, flipB?: boolean, tolerance?: number | null, faceA?: number, faceB?: number): [Solid, NurbsCurve, NurbsCurve]

The rolling-ball fillet between a's face face_a and b's face face_b — their whole NURBS surfaces — as (fillet, rail_a, rail_b): the fillet sheet (its Solid.sheetError set) and the NurbsCurves the ball touches each face along, to trim the faces back with Solid.trimByCurve() and join the three with Solid.joinSheets(). The ball sits on the side each face's normal points to (flip_a, flip_b turn it to the other side); its radius is radius, or runs linearly from radius at the fillet's first end to radius_end at its last. A radius not positive, or sides where the ball cannot touch both faces, throws BuildError.

Solid.blendSides()

static blendSides(a: Solid, sideA: SheetSide, b: Solid, sideB: SheetSide, level?: number, bulge?: number, faceA?: number, faceB?: number): Solid

A sheet spanning from a's side side_a to b's side side_b, meeting each at Glevel (1 a cubic across, 2 a quintic, matching curvature too); bulge scales how far it leaves each edge along its neighbour's tangent. Both faces non-rational NURBS.

Solid.nSidedPatch()

static nSidedPatch(boundaries: Iterable<PatchBoundary>, bulge?: number, tolerance?: number | null): Solid

The sheet filling a hole of three or more sides — where several character lines meet, which four-sided patches cannot close: N four-sided NURBS faces round a central point, one per corner, meeting each other at G1 or G2. Each of boundaries, in order round the hole and either way round, is a sheet's side met at G2, (sheet, side); (sheet, side, level) with level 0, 1 or 2; a dict with sheet, side and any of level, face and range ((from, to) of the side's parameter: (0, 1) the whole side, (1, 0) the whole side backwards); or a NurbsCurve, met at G0. A side is "u0", "u1", "v0" or "v1". The boundaries must meet end to end within tolerance; bulge scales how far the patch leaves each neighbour along its own tangent. Face i meets boundary i's second half along its "v0" side and boundary i + 1's first half along its "u1", so Solid.continuity() measures each neighbour; Solid.patchReport holds the worst of them. It joins its neighbours with Solid.joinSheets(). Fewer than three boundaries, ends that do not meet, two boundaries running on tangent through a corner, or a rational boundary throws BuildError.

Solid.patchReport

readonly patchReport: PatchReport | null

On a sheet from Solid.nSidedPatch(), the PatchReport of how well it meets; null on every other solid.

Solid.sheetError

readonly sheetError: number | null

On a sheet from Solid.sweepRail(), Solid.sweepTwoRails(), Solid.edgeSurface() or Solid.networkSurface(), how far it came from its definition; null on every other solid.

Solid.contains()

contains(point: Point3, tolerance?: number | null): Containment

Where point is relative to this closed solid: inside, outside, or on, within tolerance of its boundary — absolute, in model units (0.05 by default). The body is meshed on every call; for more than a few points build a Solid.classifier() once. An open body, a point not finite, or a tolerance not positive and finite throws BuildError.

Solid.classifier()

classifier(tolerance?: number | null): Classifier

A Classifier for this closed solid at tolerance — absolute, in model units (0.05 by default): the body meshed once, then asked point after point. It keeps its own reference to the body, so it goes on answering after this solid is closed. An open body, or a tolerance not positive and finite, throws BuildError.

Solid.closest()

closest(other: Solid, tolerance?: number | null, progress?: Progress | null): Closest

The closest points between this solid's boundary and other's, to tolerance — absolute, in model units (0.05 by default) — as a Closest; this solid is side a. Boundaries are measured, not volumes: a solid wholly inside another is the gap between their skins, not 0, and boundaries that cross are 0 apart (ask Solid.contains() for containment). progress, where the wrapper takes one, hears "meshing", "pruning" and "refining"; in the browser it is never called. A tolerance not positive and finite, or a solid with no faces, throws BuildError. Whether two parts overlap, touch or lie within a clearance of each other is blacksmith.clash()'s question, asked of a whole set.

Solid.closestPoint()

closestPoint(p: Point3, maxDistance?: number | null, tolerance?: number | null): PointFoot | null

The nearest point of this solid's boundary to p, as a PointFoot, or null where it lies beyond max_distance (Rhino's maximumDistance). A point inside a closed body is answered by its nearest boundary point, not 0. max_distance none, NaN or infinite is no limit; a point a rounding error past it is not beyond, so 0 finds a point that lies on the body. tolerance — absolute, in model units — is unset when none, 0 or NaN, and the tolerance policy then resolves it to the solid's effective tolerance; it sizes the mesh search only: every face within reach is refined exactly, and where a nearer candidate fails to refine the mesh's answer comes back with refined false, within [d - 2/3 tolerance, d + tolerance] of the true distance d. The body is meshed on every call; for more than a few points build a Solid.projector() once. A point not finite, a negative max_distance, a negative or infinite tolerance, or a body that meshes to nothing throws BuildError.

Solid.projector()

projector(tolerance?: number | null): Projector

A Projector for this solid at tolerance (none, 0 or NaN is unset, which the tolerance policy resolves to the solid's effective tolerance): the body meshed once, then asked Projector.closestPoint() point after point, the same answers as Solid.closestPoint() — a refined false answer within [d - 2/3 tolerance, d + tolerance] of the true distance d. It keeps its own reference to the body, so it goes on answering after this solid is closed. Open bodies and sheets are accepted. A negative or infinite tolerance, or a body that meshes to nothing, throws BuildError.

Solid.curveClosestPoints()

curveClosestPoints(curve: NurbsCurve, maxDistance?: number | null, tolerance?: number | null): CurveBodyFoot | null

The nearest points of curve and this solid's boundary, as a CurveBodyFoot, or null where the body lies beyond max_distance (none, NaN or infinite: no limit). Where the curve passes through the boundary the answer is a crossing, distance exactly 0, at the earliest crossing in t. tolerance — absolute, in model units; none, 0 or NaN is unset, which the tolerance policy resolves to the solid's effective tolerance — sizes the march along the curve and the mesh search: a refined false answer is within [d - 2/3 tolerance, d + tolerance] of the true distance d. The body is meshed on every call; for more than a few curves build a Solid.projector() once and ask Projector.curveClosestPoints(). A negative max_distance, a negative or infinite tolerance, a body that meshes to nothing, or a curve too long for the tolerance throws BuildError.

Solid.triangleMesh()

triangleMesh(tolerance?: number | null): TriangleMesh

This solid's measuring tessellation as a TriangleMesh: the mesh the measuring queries search, within a third of tolerance of the surface — finer than the display mesh Solid.mesh() gives at the same tolerance. Answers against it are exact for the mesh, not for the body. tolerance — absolute, in model units; none, 0 or NaN is unset, which the tolerance policy resolves to the solid's effective tolerance. The mesh is a copy: it answers on after this solid is closed. A negative or infinite tolerance, or a body that meshes to nothing, throws BuildError.

Solid.faceSurface()

faceSurface(face: number): NurbsSurface

Face face's surface (its row in the face table), its trims ignored, as an exact NurbsSurface: a NURBS face as it is (clamped if it came unclamped); a cylinder, cone, sphere or torus in its exact rational form over a parameter range that covers the face (never smaller, but for a rare holed tube face); a plane as the bilinear patch over the rectangle its trims span. (u, v) are the NURBS's own parameters. The surface is a copy: it answers on after this solid is closed. A face out of range or a surface with no exact NURBS form throws BuildError.

Solid.faceClosestPoint()

faceClosestPoint(face: number, p: Point3): PointFoot

The nearest point to p of face face alone, inside its trims or on its boundary, as a PointFoot: exact, with no mesh, so always refined. A foot on the face's boundary names the edge or vertex it lies on. A face past the end (face_closest_point: face 99 of 6), a point not finite, or a face that gives no point throws BuildError.

Solid.edgeClosestPoint()

edgeClosestPoint(edge: number | Edge, p: Point3): EdgeFoot

The nearest point to p of one edge, on its own curve over its range: (t, point, distance), t the curve's parameter as Edge.curve and Solid.edgePointAtLength() use it. edge is the index Solid.edges() uses — a PointFoot's edge (Python also takes the Edge itself). Exact, with no mesh. An edge past the end, one with no exact curve, or a point not finite throws BuildError.

Solid.thicknessAtFace()

thicknessAtFace(face: number, options: ThicknessAtFaceOptions & { tolerance?: number | null }): FaceThickness | null

How thick this solid's walls are at face face, as a FaceThickness, on a ThicknessGauge of this solid alone built at tolerance (0.01 by default), asked ThicknessGauge.thicknessAtFace() once and freed: at at's foot on the face, or with no at over the face's vertices. maximum has no default. null where nothing on the face reads within maximum, or at's foot lies off the face. A face past the end, an at not finite, maximum not positive and finite, or a tolerance not positive and finite throws BuildError.

thicknessAtFace(face, { at, maximum, tolerance }): one options object, since JavaScript has no required argument after an optional one. at defaults to null, tolerance to 0.01; a missing maximum throws BuildError (thickness_gauge_face: the maximum must be positive and finite).

Solid.boundsBox()

boundsBox(tolerance?: number | null): Box

This solid's Box at tolerance (0.05 by default): its boolean mesh, padded by twice that — the broad phase's own bound, cheaper to move and to test against another than the solid itself. Collider builds one of these per part at construction. A tolerance not positive and finite, or a solid that meshes to nothing, throws BuildError.

Solid.faceTree()

faceTree(): RTree

An RTree over this solid's faces: one entry per face, its id the face index the other face calls take, its box holding the face — the box the boolean's broad phase pairs faces by (an analytic face's exact bound, another face's boolean mesh padded), grown by a thousandth of the solid's extent. Ask it which faces a box meets, which a ray passes, or which are near a point, then test those faces themselves. A solid with no faces gives an empty tree; a face that cannot be boxed throws BuildError.

Naming

Solid.named()

named(name: string): Solid

This solid, named name. The name rides through an operation with exactly one source solid (place, translate, rotate, mirror, scaled, coloured, edges_coloured, fillet, chamfer, shell, thicken, face_sheet, drop_faces, lump, trim, split_by_plane, split_by_profile, push_pull, and so on) and is dropped by one with two or more sources (join, cut, common, split_sheet, split) and by a fresh primitive or sweep. It is what Assembly.place() defaults a placement's own name to, and the product name a lone named solid gets written into STEP (Solid.step()/Solid.stepText() — SAT and OCCT .brep have no product name to set). An empty name throws BuildError.

Solid.name

readonly name: string | null

This solid's name, or none, as Solid.named() set it, kept or dropped by whatever built this solid.

Material and outside style

Solid.withMaterial()

withMaterial(material: string): Solid

This solid made of material — a name, written into STEP as the product's MATERIAL_DESIGNATION. Kept by every operation as the solid's colour is: a move keeps it, and a boolean's result is made of its first solid's. Writing it moves Solid.step()'s default schema to AP242; a named schema without the entity writes the solid without it, as it does a colour. A reader takes it back as the node's Material property. A blank material throws BuildError.

Solid.material

readonly material: string | null

What this solid is made of, or none, as Solid.withMaterial() set it.

Solid.style()

style(location?: string | null, identification?: string | null): Solid

This solid drawn in a style defined outside the file: identification the style's name in the library at location — a MaterialX or MDL file and a material in it, say. Either may be left out, not both. Written into STEP as an EXTERNALLY_DEFINED_STYLE beside the solid's colour, which a reader without the library draws instead (AP242 or AP214: the default schema moves to AP242); a reader takes it back as the node's ExternalStyle.Location and ExternalStyle.Identification properties. Kept by operations as Solid.withMaterial()'s material is. A style naming neither throws BuildError.

Solid.styleLocation

readonly styleLocation: string | null

Where this solid's outside style lives (Solid.style()'s location), or none.

Solid.styleIdentification

readonly styleIdentification: string | null

This solid's outside style's name in its library (Solid.style()'s identification), or none.

Ids and history

Solid.track()

track(): Solid

This solid tracked: its faces numbered 1 to n in face order and its edges 1 to m in Solid.edges()' order, each its own origin. Tracking rides on from here: a verb on a tracked solid gives a tracked result, each face keeping the id of the input face it lies on and naming that face as its origin. Tracking is opt-in because it is not free: after every verb the result's faces are matched to the inputs' faces, which measured on some 2,400 real bodies costs 47% (a split) to 287% (a fillet) of the verb's own time at the median. An untracked solid pays nothing. A tracked solid comes back as it is.

Solid.isTracked

readonly isTracked: boolean

Whether this solid carries face and edge ids: it was Solid.track(), made from a tracked solid, or given an attribute.

Solid.faceId()

faceId(face: number): number | null

Face face's id, null where this solid is untracked. An id stays with its face through every verb that keeps the face — a move, a boolean, a fillet of another edge — so it names "the same face, through my edits" within a session. A piece split off, a later operand's face whose id an earlier one already has, and a face on no input get fresh ids, the same run after run.

Ids and references answer different questions. Ids are not written to files and mean nothing on a model built again from scratch or read back: there, find a face by what it is with Solid.faceRef() and Solid.findFace() (an edge with Solid.edgeRef(), a vertex with Solid.vertexRef()). A face the solid does not have throws BuildError.

A number, null where untracked, over the native library and the wasm alike: ids count up from 1 per solid, far below 2**53.

Solid.faceWithId()

faceWithId(id: number | bigint): number | null

The face whose id is id, null where no face has it — an untracked solid, or a face a verb deleted.

Takes a number or a bigint.

Solid.faceOrigins()

faceOrigins(face: number): Origin[]

The input faces face face came from, as (operand, id) pairs: the operand the input's index in the verb's operand order (a boolean's target 0, its tool 1), the id that input face's Solid.faceId(). The face it lies on most comes first. Empty for a face the verb generated (a fillet's round, the faces a split cuts) and on an untracked solid; more than one for a face merged from several (a join with merge). A face the solid does not have throws BuildError.

An array of frozen [operand, id] pairs (Origin).

Solid.edgeId()

edgeId(edge: number): number | null

Edge edge's id (an index into Solid.edges()), as Solid.faceId().

Solid.edgeWithId()

edgeWithId(id: number | bigint): number | null

The edge whose id is id, null where no edge has it.

Solid.edgeOrigins()

edgeOrigins(edge: number): Origin[]

The input edge edge edge lies on, as Solid.faceOrigins(): one (operand, id), or none for a new edge. Edges merged from several are not seen.

Solid.history()

history(...inputs: Solid[]): History

What the verb that made this solid did to the faces of inputs, passed in its operand order (a.cut(b).history(a, b)), as a History: which input faces were kept, modified (split, merged or renumbered), or deleted, and which faces were generated. Read off this solid's ids and origins alone, so it costs no geometry. An untracked solid or input, or an origin naming an operand past the inputs, throws BuildError.

Solid.edgeHistory()

edgeHistory(...inputs: Solid[]): History

Solid.history() for the edges, by edge id.

Attributes

Solid.attributes

readonly attributes: ReadonlyMap<string, string>

This solid's attributes: text keys and values, read-only, in key order. A solid's attributes go with it through every verb (a verb's result takes its first operand's), and they are the only attributes written to files: Solid.step() writes them as STEP user-defined attributes. Face attributes stay in memory.

A frozen ReadonlyMap<string, string> in key order, built once per solid: set, delete and clear throw.

Solid.attribute()

attribute(key: string): string | null

Attribute key, null where this solid has none.

Solid.withAttribute()

withAttribute(key: string, value: string): Solid

This solid with attribute key set to value, over any it had: a new solid, tracked if this one was not. Keys and values are text with no NUL; an empty key throws BuildError.

Solid.withAttributes()

withAttributes(attributes: Attributes): Solid

This solid with every attribute given set, in key order.

Takes a Map, [key, value] pairs or a plain object.

Solid.withoutAttribute()

withoutAttribute(key: string): Solid

This solid without attribute key: a new solid, equal to this one where it had none.

Solid.faceAttributes()

faceAttributes(face: number): ReadonlyMap<string, string>

Face face's attributes, read-only, in key order. A face's attributes follow its id: kept through a verb, and copied to every face that names it as an origin, so each piece of a split face has its parent's. They stay in memory: no file carries them. A face the solid does not have throws BuildError.

Solid.faceAttribute()

faceAttribute(face: number, key: string): string | null

Face face's attribute key, null where it has none.

Solid.withFaceAttribute()

withFaceAttribute(face: number, key: string, value: string): Solid

This solid with face face's attribute key set to value: a new solid, tracked if this one was not. Refused as Solid.withAttribute() is, and for a face the solid does not have.

Solid.withFaceAttributes()

withFaceAttributes(face: number, attributes: Attributes): Solid

This solid with every attribute given set on face face, in key order.

Solid.withoutFaceAttribute()

withoutFaceAttribute(face: number, key: string): Solid

This solid without face face's attribute key: a new solid, equal to this one where the face had none.

Edge and vertex references

Solid.edgeRef()

edgeRef(edge: number): number[]

Edge edge (an index into Solid.edges()) by what it is, fifteen numbers: its kind (line 0, circle 1, ellipse 2, B-spline 3, other 4), its midpoint (x, y, z), its unit tangent there (x, y, z), its length, the outward normals there of the two faces meeting on it (x, y, z each; an open sheet's rim gives its one face's twice), and its span — how far from the midpoint Solid.findEdge() may look on a resized solid. Solid.faceRef()'s twin, for a feature made on an edge: unlike an id it survives a rebuild. An edge past the table, or one with no length, throws BuildError.

Solid.findEdge()

findEdge(edgeRef: Iterable<number>, tolerance?: number | null): number | null

The edge a reference from Solid.edgeRef() refers to: of the edges of that kind passing within tolerance of its midpoint and running the same way, the one of nearest length; where none does (the solid was resized), the edge of that kind running the same way between faces facing the same two ways — the only one, or the one clearly nearest, no farther than the span. null where the edge is gone. A malformed reference, or a tolerance not positive, throws BuildError.

Solid.vertexCount

readonly vertexCount: number

How many vertices this solid has: its edges' ends, welded, in the order Solid.vertexRef() and Solid.findVertex() index.

Solid.vertexRef()

vertexRef(vertex: number): number[]

Vertex vertex by where it is: (x, y, z). A vertex the solid does not have throws BuildError.

Solid.findVertex()

findVertex(vertexRef: Iterable<number>, tolerance?: number | null): number | null

The vertex nearest vertex_ref — a Solid.vertexRef(), or any point picked — within tolerance; null where no vertex is that near. A point that is not three finite numbers, or a tolerance not positive, throws BuildError.

Colour

Solid.coloured()

coloured(colour: string | Iterable<number>, face?: number | null): Solid

A new solid coloured (r, g, b), each 0..1, "#rgb", "#rrggbb" or a CSS colour name — or, given a face (Go: ColouredFace), just that face, whose colour then wins over the solid's. What is made from a coloured solid inherits: a move keeps every colour; a boolean, fillet, chamfer or shell gives each face the colour of the input face it lies on (a cut's bore takes the tool's), and a new face — a round, a shell's inner wall — the solid's. Solid.step() and blacksmith.writeStep() write the colours as STEP styling (AP242; a named schema that lacks styling writes the solids bare), and a solid's colour reads back as Node.color.

Solid.colour

readonly colour: [number, number, number] | null

The solid's own colour as (r, g, b), or none.

Solid.faceColour()

faceColour(face: number): [number, number, number] | null

A face's colour as drawn: its own, else the solid's, else none.

Solid.edgesColoured()

edgesColoured(colour: string | Iterable<number>, edges?: Iterable<Edge | number> | null): Solid

A new solid with its edges coloured (r, g, b), "#rgb", "#rrggbb" or a CSS colour name: every edge, or, given edges (as Solid.fillet() takes them: Edge records or indices), just those, whose colour then wins over the all-edges one — an empty list colours none. Inherited as face colours are: a move keeps every edge colour; a boolean, fillet, chamfer or shell gives each edge the colour of the input edge it lies on, and a new edge (a cut's rim, a round's edges) the all-edges colour. Solid.step() and blacksmith.writeStep() write them as STEP CURVE_STYLE styling, which the reader reads back as Node.edgeColours().

Solid.edgeColour()

edgeColour(edge: Edge | number): [number, number, number] | null

An edge's colour as drawn: its own, else the solid's edge colour, else none.

Solid.brep()

brep(path: string): void

Write this solid as an OCCT .brep file; see blacksmith.writeBrep().

Solid.documentBody()

documentBody(): { [key: string]: any }

This solid as a Document's solid.body node holds it: the kernel's own B-rep as a record of its tables (surfaces, curves, trims, loops, faces), every number as it is, and its colours (the solid's, each face's and each edge's), so the node gives back exactly this solid, drawn as it was. What Document.addSolid() puts in a document.

Solid.brepText()

brepText(): string

The same .brep file as text.

From files

Solid.open()

static open(path: string, body?: number | null): Solid

The body a CAD file holds, as a solid: STEP (AP203/214/242), ACIS .sat, Rhino .3dm, OCCT .brep, IGES, IFC or OpenSCAD (an exact B-rep where the reader carries the kernel), read where it draws, in the file's own units and axes. A file drawing several bodies needs body (0-based, in drawing order) or Solid.openAll(). What such a solid can do is what its geometry allows: fillet and chamfer want line and circle edges; booleans take any surface, but new edges traced on a free-form face are not always writable back to STEP; and every verb meshes its operands first, so its cost grows with the body's face count. Reads through the reader library, which must be from the same release.

Solid.openAll()

static openAll(path: string): Solid[]

Every body a CAD file draws, as solids placed where it draws them: one per placement, so a part placed twice is two solids.

Solid.fromNode()

static fromNode(scene: Scene, node: Node | number, placed?: boolean): Solid

The body a reader Node draws, as a solid — sharing the reader's brep (Node.brep), not copying it; the scene can be closed first. placed (the default) puts it where the node's transform does, where its mesh draws; otherwise it keeps the node's own frame. The two modules' layouts (blacksmith.brepLayoutId()) must agree, or it throws CadaclysmError.

Solid.fromMesh()

static fromMesh(positions: Iterable<Point3> | Iterable<number> | Float64Array, indices: Iterable<[number, number, number] | number[]> | Iterable<number> | Uint32Array, options?: FromMeshOptions): { solid: Solid; report: FromMeshReport }

A triangle mesh — positions (three numbers a vertex) and indices (three a triangle) — as a solid and a FromMeshReport: OCCT's BRepBuilderAPI_MakeShapeOnMesh, Rhino's Brep.CreateFromMesh, Fusion's faceted MeshConvertFeatures. Vertices within weld_tolerance are welded (default 1e-6 times the bounding-box diagonal) and every triangle edge two triangles share becomes one B-rep edge. A watertight, orientable mesh comes back as a closed solid: stray triangles reoriented to agree with their neighbours, each shell turned outward (or inward, where it lies inside another: a void), so the volume is positive. Anything else comes back as an open shell, the report saying why — its holes, boundary edges and edges three or more triangles share — rather than guessing. With merge_planes (the default) neighbouring triangles whose normals agree within angle_tolerance (radians, default 1 degree) and that lie on one plane within distance_tolerance (default 1e-5 times the diagonal) become one planar face, with inner loops for holes and straight runs of its outline as single line edges, its vertices snapped onto the planes they lie on: a box's mesh is 6 faces and 12 edges. Curved regions stay faceted. merge_planes off gives one face per triangle, as OCCT. No triangles, an index out of range, a coordinate that is not finite or a negative tolerance throws BuildError.

Solid.fromMeshNode()

static fromMeshNode(node: Node, options?: FromMeshOptions): { solid: Solid; report: FromMeshReport }

Solid.fromMesh() on a reader Node's triangles — a loaded STL or OBJ, or any node with a mesh — in the node's own frame, not placed. Its double-precision mesh (Node.mesh64()) is copied out first; the scene can be closed afterwards.

Output

Solid.mesh()

mesh(tolerance?: number | null): SolidMesh

Triangles at tolerance: positions, normals (three floats a vertex) and indices. In every wrapper that lends a view, views owned by a held tessellation — valid for as long as you keep the view, whatever happens to the solid: meshed again at any tolerance, closed. Rust borrows the solid for the view's lifetime instead; Node and Godot copy. A raw span, slice or buffer taken out of a view does not keep the view itself reachable in a collected language: hold the view while you read one, and copy what must outlive it. The same rule as a FEM mesh's views, for the same reason. A view pins its whole tessellation — positions, normals, indices, edges, face counts, in both precisions — until the view itself is freed or collected, whichever the language uses; for data that must outlive the view, copy() it and drop the view.

Solid.mesh64()

mesh64(tolerance?: number | null): SolidMesh64

Solid.mesh() in double precision: the same tessellation at tolerance, unnarrowed — positions and normals exact far from the origin, where Solid.mesh()'s float32 positions are not. A view owned by a held tessellation, like Solid.mesh(): valid whatever happens to the solid, in every wrapper that lends a view — Node and Godot copying instead.

Copied out at call time, as mesh's float arrays are — this wrapper hands out no views at all — so both survive meshing again at another tolerance and the solid's close.

Solid.femMesh()

femMesh(tolerance?: number, maxSize?: number, placement?: FrameLike | null, progress?: Progress | null): FemMesh

This solid meshed for a solver, as a FemMesh: nodes welded by bits — two mesh points are one node only where their coordinates are the same doubles, so no tolerance ever merges two distinct points and a crack stays a crack — triangles wound outward, and every node tagged with the lowest-dimension B-rep entity it lies on.

tolerance is the chordal tolerance in model units, and it alone governs how closely the mesh follows the geometry. max_size is a size ceiling, 0 for none (curvature alone): it splits boundary segments to at most that length and lays interior stations max_size / √2 apart as a target, and it adds nodes without refining the boundary geometry — a caller that wants the rim nearer its curve lowers the tolerance, where max_size only makes the elements smaller. FemMesh.longestEdge is what the mesh actually came to, and the figure to check.

placement is a Frame or twelve numbers — origin, x, y, z — as every frame here, and left out for the identity, a solid meshed in its own coordinates being the common case. The reader's Node.femMesh() takes sixteen, column-major, so a caller moving between the two reformats the placement.

A cracked solid is not a failure: it comes back with FemMesh.watertight false and its cracks in FemMesh.openEdges() and FemMesh.foldedEdges(), and nothing is welded shut to make it look sound. It throws BuildError for a tolerance or size the mesher refuses, a placement that is not twelve finite and invertible numbers, a closed solid this library cannot mesh, and a solid that meshes to no triangles at all.

No unlicensed notice here: FemMesh.mshText() and FemMesh.saveMsh() print it, this library noticing on its writers rather than on its builders — where the reader library notices in its own constructor and on neither .msh call.

Solid.faceTriangles

How many triangles each face meshed to at tolerance, one count per face in face order: the triangles of Solid.mesh() at the same tolerance run face by face, so face f's are the counts[f] after the first counts[:f].sum(), and the counts sum to the mesh's triangle count. What a viewer colours a face by. A view, like Solid.mesh() — a copy in Node and Godot.

Declared; the method comes with the viewers.

Solid.edgePolylines()

edgePolylines(tolerance?: number | null): Float32Array[]

The feature edges as polylines at tolerance, one run of points per edge. Views, like Solid.mesh() — copies in Node and Godot.

Solid.edgePolylineColours()

edgePolylineColours(tolerance?: number | null): Array<[number, number, number] | null>

A colour per polyline of Solid.edgePolylines() at the same tolerance, as drawn: (r, g, b), or none for a polyline on no coloured edge; an empty list where the solid has no edge paint at all — what a viewer colours the edge lines by. Copied out, unlike the polylines.

Solid.show()

show(options?: ShowOptions): void

Draw the solid with the viewer in use — in a terminal, the picture is left in the scrollback. Each face keeps its own colour (Solid.faceColour(): a colour of its own, else the solid's). Keywords: view= (front, back, left, right, top, bottom, iso), az=, el=, zoom=, up=, edges=, width=, height=, hint=, tolerance=. With the GPU library (import cadaclysm.view.wgpu) the drawing replaces what one shared window shows and stays live — at the REPL, in IPython and in Jupyter by themselves, in a script until it exits; cadaclysm.view.View draws several items or several windows.

Takes an options object: view, azimuth, elevation, zoom, up, edges, width, height, title, tolerance, rgb. On the wgpu library (require('cadaclysm/view').useWgpu()) it replaces what one shared window shows and returns; a 16 ms timer keeps the window live and holds the process until it is closed. On the terminal it prints a still.

Solid.view()

view(options?: ShowOptions): Camera

Orbit the solid with the viewer in use until it is closed; returns the camera where it was left — a dict of eye, target, up, orthographic, azimuth and elevation — and pick, what was last clicked (item, node, face) or None. Keywords as Solid.show(). A fresh window, run until closed, with the GPU library.

Takes the options show does; returns a Camera object with these fields.

Solid.step()

step(path: string, schema?: string | null, unit?: Unit): void

Write this solid as a STEP file (AP203, or AP242 when coloured); see blacksmith.writeStep() for schema and unit.

Solid.stepText()

stepText(schema?: string | null, unit?: Unit): string

The same STEP file as text.

Solid.sat()

sat(path: string, unit?: Unit): void

Write this solid as an ACIS SAT file; see blacksmith.writeSat() for unit.

Solid.satText()

satText(unit?: Unit): string

The same SAT file as text.

Solid.write3dm()

write3dm(path: string, unit?: Unit): void

Write this solid as a Rhino .3dm; see blacksmith.write3dm() for what it carries and unit.

Solid.rhino3dmBytes()

rhino3dmBytes(unit?: Unit): Buffer

The same .3dm file as bytes.

Solid.svg()

svg(path: string, options?: SvgOptions): void

This solid's wireframe as SVG, from a camera the keywords describe — blacksmith.writeSvg()'s own words, read by the library itself rather than a viewer. With path, writes the file and returns null; without, returns the SVG text. throws BuildError on a refused option or a failed write.

Solid.silhouetteBeziers()

silhouetteBeziers(options?: SvgOptions): SilhouetteCurves

This solid's silhouette — the curves where its surfaces turn away from the eye, which no edge of it lies on, so a sphere has an outline here that its wireframe has none of — as rational cubic Béziers in double precision, from the camera the options describe: Solid.svg()'s own words, so the words that draw a picture ask about the same eye. tolerance is read as a fraction of the page's width, and nothing else in the options changes the curves; the line-set flags are not read. Exact Béziers where the surface has a closed silhouette form — sphere, cylinder, cone, extrusion — and for every other surface, a torus and a NURBS patch included, a straight-chord polyline carried as degree-1 Béziers: there is no spline fitter here, so a sphere's rim arrives as arcs and a torus's as chords.

The curves are in memory of the wrapper's own: the library's buffer is copied out and released before the call returns, so there is nothing to free and nothing that can dangle. A solid with no silhouette — one whose every face is planar, a cuboid's, since a plane has none from any eye — is an empty answer (count 0), not an error. The library clears its error slot as each call starts, so an empty answer leaves no message and a refusal leaves one; that is how the two are told apart, and why a failure from an earlier call cannot be mistaken for this call's empty answer. throws BuildError on a refusal — a refused option, say.

Takes the options object (width with tolerance). Returns { points, weights, count }, the arrays Float64Arrays of the call's own; the empty answer has count 0 and empty arrays.

Solid.silhouetteBeziersFree

Release silhouette Bézier data: the data from a silhouette_beziers call, passed with its matching count. null is a no-op. The count must be the value that same call wrote through its own out-parameter — the buffer carries no length of its own.

A managed wrapper never exposes a manual free — it releases the buffer itself. This documents the C function.

Solid.toScene()

toScene(schema?: string | null): Scene

This solid as a reader Scene, through STEP in memory: the door from the kernel to everything the reader does — its tree, meshes, glTF/OBJ/STL export. Needs the reader library as well.

Solid.close()

close(): void

Free the solid now. The garbage collector, or the language's scope, does it otherwise.

Async twins Node.js only

joinAsync(other: Solid, tolerance?: number | null, progress?: Progress | null): Promise<Solid>
cutAsync(other: Solid, tolerance?: number | null, progress?: Progress | null): Promise<Solid>
commonAsync(other: Solid, tolerance?: number | null, progress?: Progress | null): Promise<Solid>
filletAsync(edges: Iterable<Edge | number>, radius: number, tolerance?: number | null, progress?: Progress | null): Promise<Solid>
meshAsync(tolerance?: number | null): Promise<SolidMesh>
stepAsync(schema?: string | null, unit?: Unit): Promise<string>
satAsync(unit?: Unit): Promise<string>

The slow operations have promise-returning twins that run on a worker thread.

Assembly

class Assembly

A mutable tree of placements: a name, and zero or more solids or other assemblies placed in it at a frame. Unlike Solid, placing shares rather than copies — placing one assembly under another does not snapshot it, so a later placement on the shared one shows up wherever it already sits. Close it when done, or let the language's scope do it; see Lifetimes — closing an assembly does not free what was placed in it if that is still reachable from somewhere else.

Assembly.name

readonly name: string

This assembly's own name, given when it was made.

Assembly.place()

place(thing: Solid | Assembly, frame: FrameLike, name?: string | null): string

Place thing (a Solid or another Assembly) at frame in this assembly, called name — or, with name left out, thing's own name (Solid.name for a solid, "part" for an unnamed one, or the placed assembly's own name), numbered past any already taken here ("bolt", "bolt 2", ...). frame must be right-handed and orthonormal, or the call throws BuildError. An explicit name already taken here throws BuildError. Placing an assembly that is this one, or anywhere above this one in the tree already, throws BuildError naming the cycle, since writing that out would never terminate. Returns the placement's name.

Assembly.joint()

joint(name: string, start: string, end: string): void

Connect this assembly's links start and end, kept in that order, as a joint called name. An empty name, a name taken by another joint here, a link this assembly does not have, a link joined to itself or a (start, end) pair already joined throws BuildError; the reverse pair is a different joint.

Assembly.pair()

pair(joint: string, kind: string, frame: FrameLike, options?: PairOptions): void

Give joint joint its pair: kind (one of revolute, prismatic, cylindrical, screw, spherical, spherical_with_pin, planar, universal, homokinetic, fully_constrained or unconstrained), the contact frame at rest, an optional end_frame (the frame the pair reaches at its rest values; frame itself, i.e. all-zero rest values, when left out), ranges (one entry per freedom of kind, each unbounded or a lower/upper pair; left out entirely for a kind that allows none), and pitch (required and non-zero for screw, refused for any other kind). An unknown or already-paired joint, an unknown kind, a bad pitch, ranges given where none are allowed or of the wrong length, a non-finite or inverted range, or an end_frame this kind's motion cannot reach (or reaches only outside a given range) throws BuildError, and the assembly is left as it was.

Assembly.pairWith()

pairWith(joint: string, kind: string, frame: FrameLike, options?: PairWithOptions): void

Assembly.pair() with the kind's own numbers, params, in place of the pitch — for the coupled pairs: kind any kind pair takes, or gear or rack_and_pinion; params [pitch] for screw, [pinion_radius] for rack_and_pinion, [radius_first, radius_second, ratio] or those plus [bevel, helical_angle] (radians) for gear — the ratio the second link's rotation over the first's, signed, so two meshing external gears have a negative one — and none for any other kind. Written as AP242's screw_pair, rack_and_pinion_pair and gear_pair (whose gear_ratio is the ratio negated); a reader Scene gives them back as Pair.kindName and Pair.parameters, and posing turns a coupled joint from its driver. A wrong number of parameters, a non-finite one, a zero pitch, radius or ratio, or anything pair refuses throws BuildError, and the assembly is left as it was.

Assembly.state()

state(name: string, rows: Map<string, Iterable<number>> | Iterable<[string, Iterable<number>]>): void

Add a named state: the rows (Python: a mapping, or an iterable of (joint, values) pairs) set each named joint to its values, in that joint's pair's freedom order. An empty or duplicate name, no rows, an unknown joint, a joint set twice, a joint with no pair or none of its pair's freedoms, a row of the wrong length, or a non-finite or out-of-range value throws BuildError, and the assembly is left as it was.

Assembly.sequence()

sequence(name: string, segments: Iterable<[string, number, 'undefined' | 'discontinuous' | 'synchronous' | 'linear']>, seconds?: boolean): void

Add a named motion sequence over this assembly's states: segments are (state name, parameter, interpolation) rows, the interpolation one of "undefined", "discontinuous", "synchronous" or "linear", and seconds writes the parameter's unit as the second. Closed or open is the last segment's interpolation: closed unless it is "discontinuous". An empty or duplicate name, fewer than two segments, an unknown state, a non-finite or decreasing parameter, or an unknown interpolation throws BuildError, and the assembly is left as it was.

Assembly.base()

base(link: string): void

Declare this assembly's base link. link naming no link of this assembly, or a base already declared, throws BuildError naming the link already there.

Assembly.pose()

pose(values?: PosedValues | null, options?: PosedOptions): Assembly

This assembly with its mechanism posed, as a new assembly; this one is left as it was. Each joint is named by its path — the placement names down the tree, then the joint's name, joined by / ("drive FL/spin"), a / or \ inside a name escaped with \ — or by its bare name, which means a joint of this assembly by that name, else the only joint of that name anywhere under it; each copy of a sub-assembly placed more than once poses on its own. Values are absolute, one per freedom of the joint's pair, radians for rotations and the assembly's units for translations. A state's path is applied first and overridden joint by joint; ground names one of this assembly's links to hold fixed (default: its base, else its busiest link). A sub-assembly no key reaches is shared with this one. An unknown or ambiguous key, a joint given twice, one without a pair, the wrong number of values, a value that is not finite or is outside its range, an unknown state or link, or a loop the pose leaves open throws BuildError. Whether the parts meet on the way from one pose to the next is Assembly.sweptClash()'s question.

Assembly.parts()

parts(): string[]

The placement path of every solid under this assembly, at any depth: depth first, placements in order, the placement names down the tree joined by /, a / or \ inside a name escaped with \, as Assembly.pose()'s keys are ("a\/b/x" for part x of a sub-assembly placed as a/b). The index Assembly.sweptClash()'s rows use. Empty for an assembly that places no solid.

Assembly.sweptClash()

sweptClash(keyframes: Iterable<PosedValues>, options?: AssemblySweptClashOptions): SweptClash[]

Every pair of this assembly's solids, indexed as Assembly.parts() lists them, that penetrates, touches or comes within clearance of the other anywhere while this assembly's own mechanism moves through keyframes, as SweptClash rows in pair order. Each keyframe maps joint keys to values as Assembly.pose()'s values do, and every keyframe names the same joints with the same number of values each (the first keyframe fixes their order); time runs in keyframe units, keyframe k at time k.

Between two keyframes each joint value moves linearly and each link is posed from those values, as Assembly.pose() poses it: a link swinging about a joint goes round its arc, not along its chord, and a coupled joint turns from its driver. Only this assembly's own joints move: a key into a sub-assembly is refused, and a sub-assembly rides the link its placement is in. ground names one of this assembly's links to hold fixed (default: its base, else its busiest link); solids in no link stay still too. Pairs on the two links a joint joins are not tested unless joined; allowed pairs of part indices are never tested. tolerance (0.05 by default) meshes the parts; the guarantee, resolution and max_steps are Collider.sweptClash()'s, and each row's first is the Clash at the posed frames, so its Clash.solid() rebuilds the contact.

Fewer than two keyframes, keyframes naming different joints or a different number of values for one, a joint given twice, a key into a sub-assembly, anything Assembly.pose() refuses of a key or its values, an unknown ground, a loop the motion leaves open, an allowed pair that is not two indices or one out of range, a part that is not a closed solid, or a bad tolerance, clearance, resolution or max_steps throws BuildError; the kernel's own words are prefixed swept_clash:.

Assembly.stepText()

stepText(schema?: string | null, unit?: Unit): string

This assembly, and everything placed under it, as one STEP file: this assembly the root product, each sub-assembly and each distinct part (the same solid with the same paint and name) written once, each placement an occurrence named as it was placed. schema and unit as blacksmith.writeStep(). An assembly reachable from this one, this one included, that places nothing throws BuildError — a reader would never show it.

Assembly.step()

step(path: string, schema?: string | null, unit?: Unit): void

Assembly.stepText() written to a file.

Assembly.rhino3dmBytes()

rhino3dmBytes(unit?: Unit): Buffer

This assembly, and everything placed under it, as one Rhino .3dm: each distinct part (as Assembly.stepText() counts them) a block holding its body, each sub-assembly a block of references to what it places — so nested assemblies are nested blocks — and this assembly's own placements references at the top of the file, on a layer named after it. Each reference is named as its placement was; block names are the parts' and assemblies' names made ones Rhino takes and numbered past any already taken, whatever their case. Bodies, colours and unit as blacksmith.write3dm(). An assembly reachable from this one, this one included, that places nothing throws BuildError.

Assembly.write3dm()

write3dm(path: string, unit?: Unit): void

Assembly.rhino3dmBytes() written to a file by the library itself.

Assembly.toScene()

toScene(schema?: string | null): Scene

This assembly as a reader Scene, through STEP in memory; see Solid.toScene().

Assembly.close()

close(): void

Free this handle now. The garbage collector, or the language's scope, does it otherwise.

History

class History

What a verb did to its inputs' faces (or edges) — what Solid.history() and Solid.edgeHistory() return, read off the result's ids and origins alone. An input face is named (operand, id): the operand its input's index in the verb's operand order (a boolean's target 0, its tool 1), the id its Solid.faceId(). Each list is in (operand, id) order, generated in id order.

History.kept

readonly kept: readonly (readonly [Origin, number])[]

The inputs that became exactly one output and kept their id, each as (input, output id).

History.modified

readonly modified: readonly (readonly [Origin, readonly number[]])[]

The inputs split (several outputs name them), merged (their output has other origins too) or renumbered (a cut's bore, a later operand's clashing id), each as (input, [output ids]); a split's first piece, which keeps the id, comes first.

History.generated

readonly generated: readonly number[]

The outputs with no origin: a fillet's round, the faces a split cuts.

History.deleted

readonly deleted: readonly Origin[]

The inputs no output names, such as the caps of a cut's tool.

Edge

class Edge

One edge of a solid as plain data, copied out of it: what Solid.edges() lists and Solid.fillet() takes.

A method that takes edges — Solid.fillet(), Solid.chamfer(), Solid.edgesColoured() — takes a list of them, Edge values or their indices, and refuses a single one: one edge is a list of one. So do the face and corner lists of Solid.dropFaces(), Solid.shell() and Profile.round(); Solid.pushPull() takes one face on its own or a list.

Edge.index

index: number

Its index — what Solid.fillet() and Solid.chamfer() take.

Edge.kind

kind: string

The curve: line, circle, ellipse, parabola, hyperbola, nurbs or other.

Edge.faces

faces: number[]

The faces meeting on it, as face indices.

Edge.segments

segments: [number[], number[]][]

The two ends of each piece of the edge.

Edge.curve

curve: Curve | null

The edge's exact curve, as a Curve — null for an edge with no exact curve (kind other). Filled when the edges are listed, so the edge stays plain data.

Edge.isLine

readonly isLine: boolean

Whether the edge is straight.

Edge.direction

readonly direction: number[] | null

The unit direction of a straight edge, or null for a curved one. Picking the vertical edges of a plate is a filter on this.

Curve

class Curve

One edge's, or one intersection chain's, exact curve as plain data, copied out: what Edge.curve or Chain.curve holds. kind is line, circle, ellipse, parabola, hyperbola or nurbs.

t0..t1 is the edge's (or the chain's) parameter range on its own curve: a line's fraction (0..1 over origin -> origin + x, where x is the full to - from, NOT unit — so point(t) = origin + x*t); a circle's or ellipse's angle in radians about origin in the x, y plane (point(t) = origin + x*radius*cos(t) + y*radius2*sin(t), radius2 = radius for a circle); a parabola's own parameter with radius its focal length F (point(t) = origin + x*F*t*t + y*2*F*t, radius2 0); a hyperbola's with radius, radius2 its semi-axes a, b (point(t) = origin + x*a*cosh(t) + y*b*sinh(t)); a NURBS's knot parameter (knots[degree] <= t0 < t1 <= knots[n]). Frame vectors x, y, z are unit for conics; for a line x is the direction with length = the line's length and y, z are zero. Always t0 < t1: an edge whose segments run against its curve's own parameter reports the same range — read the direction from Edge.segments, not from the range. A chain's Chain.points always run WITH the curve's own parameter instead: point(t0) is the chain's first point and point(t1) its last for an open chain (a closed chain simply goes once round, t0..t1 its whole domain).

For a NURBS the frame is zero and so are the radii; for a conic or a line degree is 0 and knots, poles are empty. Evaluating point(t) is left to the caller for now.

Curve.kind

kind: string

The curve: line, circle, ellipse, parabola, hyperbola or nurbs. Never other: a curve of that kind is null instead.

Curve.origin

origin: number[]

The frame's origin, three numbers: a circle's or ellipse's centre, a parabola's vertex, a hyperbola's centre, a line's start. Zero for a NURBS.

Curve.x

x: number[]

The frame's first axis: a conic's unit direction at angle 0 (a parabola's or hyperbola's axis); for a line the whole to - from, so origin + x is its far end. Zero for a NURBS.

Curve.y

y: number[]

The frame's second axis: a conic's unit direction at a quarter turn. Zero for a line or a NURBS.

Curve.z

z: number[]

The frame's normal, x cross y, unit for a conic. Zero for a line or a NURBS.

Curve.radius

radius: number

A circle's radius, an ellipse's along x, a parabola's focal length, a hyperbola's semi-axis along x; 0 for a line or a NURBS.

Curve.radius2

radius2: number

An ellipse's radius along y, a hyperbola's semi-axis along y; equal to radius for a circle; 0 for a parabola, a line or a NURBS.

Curve.t0

t0: number

Where the edge starts on the curve, in the range convention above.

Curve.t1

t1: number

Where it ends: greater than t0. A whole circle is one edge, t1 - t0 a full turn. On a conic t1 may exceed 2pi when the arc crosses angle 0 (say t0 5.6, t1 7.0): keep the angles as reported and never normalise them into 0..2pi, or the arc is drawn the long way round.

Curve.degree

degree: number

A NURBS's degree; 0 for a conic or a line.

Curve.knots

knots: number[]

A NURBS's knot vector, poles + degree + 1 long; empty for a conic or a line.

Curve.poles

poles: number[][]

A NURBS's control points, three numbers each; empty for a conic or a line.

Curve.value

readonly value: CurveValue | null

This curve as a value: a line a Line from origin to origin + x; a circle a Circle over a full turn, else the Arc over t0..t1; an ellipse its whole Ellipse (the range stays here: there is no elliptical-arc value); any other kind null.

Curve.weights

weights: number[] | null

One weight per pole for a rational NURBS; null for a plain (non-rational) B-spline, a conic or a line.

Intersection

class Intersection

What Solid.intersect() found, copied out: chains, one Chain per face pair per branch of the crossing, and overlaps, one Overlap per coincident face pair sharing a region. Both empty where the solids do not meet.

Intersection.chains

chains: Chain[]

Every crossing found, as Chain values.

Intersection.overlaps

overlaps: Overlap[]

Every coincident face pair sharing a region, as Overlap values.

Chain

class Chain

One branch of one face pair's crossing, as plain data: one of Intersection.chains. Every point is within tolerance of both faces' exact surfaces. There is one chain per face pair per branch — a chain does not cross a face boundary or a closed curve's own seam, so a crossing that runs past either comes back as more than one chain, and a caller joins them by matching ends. closed when the chain's own ends meet.

Chain.points

points: number[][]

The points along the crossing, in walk order; a closed chain does not repeat its first point.

Chain.closed

closed: boolean

Whether the chain's own ends meet.

Chain.faces

faces: [number, number]

The two faces that cross: the index in the first solid Solid.intersect() was called on, then the index in the second.

Chain.tangent

tangent: boolean

Whether the two surfaces are near-tangent along the chain, or the snap did not settle within tolerance — the points are then the best estimate found, not exact to the tolerance everywhere. A closed chain that does not go once round its own curve (a sliver of mesh noise where two surfaces barely cross) is reported with no curve at all, tangent still true.

Chain.curve

curve: Curve | null

The crossing's exact curve, as a Curve over the chain's own t0..t1 — null where no curve fits every point of the chain within tolerance (tangent noise, or a crossing with no closed form).

Overlap

class Overlap

A face of the first solid and a face of the second that coincide — lie on one surface and share a region — as plain data: one of Intersection.overlaps. A face pair sharing only an edge or a rim (no shared region: two pipes end to end, two boxes flush on a side) is silent — neither an overlap nor a chain. Two coincident planes give their exact common region — two offset boxes the rectangle they share, an L under a box the L. On a curved surface loops are the rings of either outline lying wholly inside the other face, and may come back empty where the two outlines cross: a valid answer, not an error.

Overlap.faces

faces: [number, number]

The two coincident faces: the index in the first solid Solid.intersect() was called on, then the index in the second.

Overlap.loops

loops: number[][][]

The shared region's boundary: closed rings of points on the surface, outer loop before holes, each ring's first point not repeated.

Finding

class Finding

One thing wrong with one argument of Solid.check(), as plain data. index, other and size are what its kind gives, and null, null and 0 where it gives none.

Finding.kind

kind: FindingKind

What is wrong: no_faces; open (index the edge — null for a side naming none — other its face, size its length); region_wall; non_manifold; face_kind (index the face); short_edge (index the edge, size its length); collapsed_edge (index the trim); sliver_face (index the face, size its width); tiny_face (index the face, size its area); tiny_body (size its diagonal); small_hole (index the loop, size its area or width); loose_edge (index the edge, size how far its sides part); curve_on_surface (index the edge — a trim's index for a trim naming none — other the face, size the largest deviation); c0_inside (inside a face: index the face, other null; along an edge's curve: index the edge, other the lowest-numbered face it bounds; size the angle, in radians); self_intersection (index and other the two faces — one face twice for a fold — size the crossing's length); self_overlap (index and other the two faces); unmeshable; and on the pair, argument 0 with index in the solid checked and other in other: merge_vertex (the two vertices, size their distance), merge_edge (the two edges, size the largest gap), merge_face (the two faces, size the largest separation), tangent_face (the two faces, size the tangent stretch's length).

Finding.argument

argument: number

Which argument: 0 the solid Solid.check() was called on, 1 other; 0 for the four kinds on the pair.

Finding.index

index: number | null

The vertex, edge, face, trim or loop the kind names; null where it names none.

Finding.other

other: number | null

The second index the kind gives (an open edge's face, the face an edge leaves or creases on, the second face of a self-intersection, other's vertex, edge or face for a kind on the pair); null where it gives none.

Finding.size

size: number

The length, width, area, gap or angle the kind gives; 0 where it gives none.

Mass

interface Mass

What a body measures, per unit density: what Solid.mass() returns. Every figure carries a bound on its own error, because a measurement without one cannot be compared with anybody else's — including another kernel's. Measured on the exact surfaces where a face has one and on a mesh where it has not, which Mass.fromMesh reports.

Mass.closed

closed: boolean

The body is topologically closed. Only then do the volume, the centroid and the inertia mean anything; they are not numbers at all otherwise.

Mass.inverted

inverted: boolean

Every face pointed inward. The figures are given as if they had not.

Mass.accuracyMet

accuracyMet: boolean

Every error came under the accuracy asked for. false where the refinement gave up first — the values and their errors are still honest, simply less certain.

Mass.fromMesh

fromMesh: boolean

Measured on a mesh rather than on exact surfaces: exact for that mesh, and its errors are then the rounding floor rather than a statement about the surface.

Mass.of

Measure solid at accuracy, which is the same call as Solid.mass() written the other way round: Mass.of(solid) where the body reads better as the object of the sentence.

Not in Node: solid.mass() is the only spelling.

Mass.weight()

weight(density: number): number

density * volume, in whatever units the model and the density agree on. Per unit density is what everything here is, because an assembly of two materials would have to undo a density applied on its behalf — so Mass.of(part).mass(7850) is a steel part in kilograms where the model is in metres, and the inertia scales the same way.

Spelled weight: see the C++ note.

Mass.area

area: number

The surface area.

Mass.areaError

areaError: number

A bound on area's own error.

Mass.volume

volume: number

The volume enclosed, where Mass.closed.

Mass.volumeError

volumeError: number

A bound on volume's own error.

Mass.centroid

centroid: number[]

The volume's centroid, where Mass.closed.

Mass.centroidError

centroidError: number

A bound on the distance from centroid to the true centroid.

Mass.inertia

inertia: number[][]

The inertia tensor about the centroid, row-major and symmetric, products of inertia negated (inertia[0][1] is minus the integral of (x - gx)(y - gy)).

Mass.inertiaError

inertiaError: number

A bound on every entry of inertia.

Mass.principalMoments

principalMoments: number[]

The tensor's eigenvalues, ascending.

Mass.principalAxes

principalAxes: number[][]

Their axes, one unit vector each, in the same order.

OrientedBox

interface OrientedBox

What Solid.orientedBox() returns: a closed solid's box on its principal axes. Not the minimal box in general, and with equal moments the axes are a free choice; see Solid.orientedBox().

OrientedBox.centre

readonly centre: number[]

The box's middle, not the body's centroid.

OrientedBox.axes

readonly axes: number[][]

The three unit axes, one row each: orthonormal and right-handed.

OrientedBox.half

readonly half: number[]

The half-extent along each axis, grown by the tolerance the measurement settled on.

Length

interface Length

A measured length — what Solid.edgeLength() and Profile.length() return — beside an estimate of its error. The error is an estimate of the distance from the true length, not a proof.

Length.length

readonly length: number

The length.

Length.error

readonly error: number

An estimate of how far length is from the true length.

Length.accuracyMet

readonly accuracyMet: boolean

The error came under the accuracy asked for. false where the refinement stopped at its depth limit first: the figure is then less certain than was asked, and error says by how much.

Length.fromPolyline

readonly fromPolyline: boolean

The curve was a sampled polyline: exact for its points and not for whatever they were sampled from.

LengthMass

interface LengthMass

A curve's length mass properties per unit length density — what NurbsCurve.mass() returns, as Rhino's LengthMassProperties — each figure beside an estimate of its own error. Where two principal moments agree within inertia_error, any orthonormal pair spanning their plane is as right as another.

LengthMass.length

readonly length: number

The length.

LengthMass.lengthError

readonly lengthError: number

An estimate of length's own error.

LengthMass.centroid

readonly centroid: number[]

The centroid of the curve's length.

LengthMass.centroidError

readonly centroidError: number

An estimate of the distance from centroid to the true centroid.

LengthMass.inertia

readonly inertia: number[][]

The inertia tensor about the centroid, three rows of three, symmetric, products of inertia negated.

LengthMass.inertiaError

readonly inertiaError: number

An estimate of every entry of inertia's error.

LengthMass.principalMoments

readonly principalMoments: number[]

The tensor's eigenvalues, ascending.

LengthMass.principalAxes

readonly principalAxes: number[][]

Their axes, unit and right-handed, row i the axis of moment i.

LengthMass.radii

readonly radii: number[]

The radius of gyration about each principal axis, sqrt(principal_moments[i] / length).

LengthMass.accuracyMet

readonly accuracyMet: boolean

Every error is within the accuracy asked of its scale.

LengthMass.fromPolyline

readonly fromPolyline: boolean

The curve was a sampled polyline: exact for its points and not for whatever they were sampled from.

SectionCurve

class SectionCurve

One curve of Solid.sectionCurves() or Solid.contourCurves().

SectionCurve.curve

readonly curve: NurbsCurve

The curve, a NurbsCurve; its NurbsCurve.fitError is error.

SectionCurve.plane

readonly plane: number

The contour plane it lies in, by index; 0 for a single section.

SectionCurve.closed

readonly closed: boolean

It comes back to its start.

SectionCurve.exact

readonly exact: boolean

Every piece of it was an exact curve: a line, circle, ellipse or NURBS crossing, or a face's own edge.

SectionCurve.error

readonly error: number

Its fit error; 0 where exact.

NurbsCurve

class NurbsCurve

A curve in space to model with — always a NURBS, so a line, an arc or a conic is an exact rational one. NurbsCurve(points, degree=3, weights=None, knots=None) builds one from its control points (degree 1 to 7; weights positive, one per point; the full knot vector, non-decreasing, or None for clamped and uniform); NurbsCurve.through(), NurbsCurve.fit(), NurbsCurve.fromEdge(), NurbsCurve.isocurve() and NurbsCurve.blend() build the rest. Immutable: every edit returns a new curve. Not Curve, the plain data an edge's curve is copied out as.

A face is its whole surface here: projecting onto, pulling to and crossing a face ignore its trims, so a curve projected past a face's edge lands on the surface's continuation. A curve projected or pulled onto a face is a 3D curve fitted through points on the surface, within the tolerance asked (NurbsCurve.fitError says how close it came), not a curve in the face's parameters. Every refusal names the C call, e.g. nurbs_curve_trimmed: ....

NurbsCurve.through()

static through(points: Iterable<Point3>, degree?: number, closed?: boolean, startTangent?: Point3 | null, endTangent?: Point3 | null): NurbsCurve

The curve of degree through points in order, chord-length parametrised. closed=True closes it back to the first point, smooth across the seam (C^(degree-1)); an open curve may leave along start_tangent and arrive along end_tangent (directions; their length does not matter). Too few points for the degree, a point repeating the one before it, or a closed curve given end tangents, throws BuildError.

NurbsCurve.fit()

static fit(points: Iterable<Point3>, degree?: number, tolerance?: number | null): NurbsCurve

A curve of degree within tolerance of every point, through the first and the last (least squares, growing its control points until the tolerance is met); its NurbsCurve.fitError is the largest distance from a point to it. A tolerance not positive throws BuildError.

NurbsCurve.fair()

static fair(points: Iterable<Point3>, degree?: number, tolerance?: number | null, noInflection?: NoInflection): NurbsCurve

The smoothest curve of degree (3 to 7) within tolerance of every point, through the first and the last: least squares plus the curvature's derivative squared, weighed as heavily as the tolerance allows. Where NurbsCurve.fit() follows the points' noise, this spends the tolerance on a calm curvature comb (NurbsCurve.comb()) — a design line traced off a drawing comes back fair. no_inflection=True keeps the curvature from turning over anywhere; a pair of point indices (i, j) (fractions between points, None an open end) only between those points. Its NurbsCurve.fitError is the largest distance from a point to it. A degree outside 3 to 7, or a hold no curve within the tolerance can keep, throws BuildError.

NurbsCurve.faired()

faired(degree?: number, tolerance?: number | null, noInflection?: NoInflection): NurbsCurve

This curve faired: the smoothest curve of degree within tolerance of it, from its start to its end, as NurbsCurve.fair() makes one from points; the no_inflection pair is this curve's own parameters here. Its NurbsCurve.fitError is the largest distance found between the two.

NurbsCurve.fromEdge()

static fromEdge(solid: Solid, edge: Edge | number): NurbsCurve

Edge edge of solid (an Edge or its index) as an exact NURBS over the edge's own span of its curve, running the way the edge runs. An edge with no exact curve throws BuildError.

NurbsCurve.isocurve()

static isocurve(solid: Solid, face: number, alongU: boolean, at: number): NurbsCurve

The isocurve of face face of solid's surface: along u at v = at when along_u, else along v at u = at. NURBS faces only: a plane or a quadric face throws BuildError, as does an at outside the surface's domain.

NurbsCurve.faceIsocurves()

static faceIsocurves(solid: Solid, face: number, alongU: boolean, at: number, tolerance?: number | null): NurbsCurve[]

The pieces of face face's isocurve of solid that lie inside its trims, as Rhino's TrimAwareIsoCurve, in order along it: along u at v = at when along_u, else along v at u = at. Exact on every surface kind (a sampled profile's falls back to a fit at tolerance, 0 or null the solid's own); each piece's ends are polished onto the edges they meet, and its NurbsCurve.fitError is the larger of its fit error and those ends' distance from their edges. A periodic seam is crossed in one piece; an at the face never reaches gives an empty list. Solid.faceIsoIntervals() gives the same pieces as parameter intervals.

NurbsCurve.spiral()

static spiral(axis: ArrayLike<number> | [Point3, Point3], start: Point3, pitch: number, turns: number, endRadius?: number | null): NurbsCurve

A helix or spiral as a curve, as Rhino's NurbsCurve.CreateSpiral: about axis (a point on it and its direction, which need not be unit) from start, turning the right-hand way about the direction and climbing pitch along it each turn (negative climbs the other way, 0 is flat) for turns turns, its radius running linearly with the angle from start's distance from the axis to end_radius (null: the same, a helix). A start on the axis takes revolve's reference direction. A C2 quintic, 16 spans a turn, through the exact spiral at every span end; its NurbsCurve.fitError is its largest distance from the exact spiral. An axis direction zero or not finite, turns not positive and finite, pitch not finite, or both radii zero, throws BuildError.

NurbsCurve.blend()

static blend(a: NurbsCurve, aEnd: boolean, b: NurbsCurve, bEnd: boolean, continuity?: number, bulge?: number): NurbsCurve

The curve bridging a (at its end when a_end, else its start) to b (at its end when b_end, else its start), leaving a and arriving at b along their tangents: continuity 1 matches position and tangent (a cubic), 2 also the curvature (a quintic). bulge (positive, 1 usual) scales how far the tangents reach. Two ends at the same point throws BuildError.

NurbsCurve.join()

static join(curves: Iterable<NurbsCurve>, tolerance?: number): NurbsCurve

curves joined end to end into one curve, as Rhino's JoinCurves: in the order given, each turned where needed so its start meets the previous one's end (the first one too, when only its start meets the second), within tolerance, and the joint placed at the midpoint of the two ends. All are raised to the highest degree among them and each runs over k..k + 1 of the result, joined C0 — a corner stays a corner; a rational curve (an arc) keeps its points exactly. One curve gives a copy. No curves, or two ends further apart than tolerance, throws BuildError, naming the two curves and the gap.

NurbsCurve.closestPoint()

closestPoint(p: Point3): CurveFoot
closestPoint(p: Point3, maxDistance: number | null | undefined): CurveFoot | null

The CurveFoot nearest p over the curve's whole domain: its parameter t, the point, and unique — false where another point of the curve is as near (a point on a circle's axis) and point is a pick among them. Exact. null where it lies beyond max_distance (none, NaN or infinite: no limit, the same answer as with none). A point not finite or a negative max_distance throws BuildError.

NurbsCurve.closestPoints()

closestPoints(other: NurbsCurve, maxDistance?: number | null): CurvePair | null

The nearest points of this curve and other, as a CurvePair — side a this curve, distance 0 where they cross, and among equal distances the smallest t_a, then t_b — or null where they lie farther apart than max_distance (none, NaN or infinite: no limit). Exact. A negative max_distance throws BuildError.

NurbsCurve.closestObject()

closestObject(items: Iterable<Solid | NurbsCurve | Projector | TriangleMesh | NurbsSurface | Point3>, maxDistance?: number | null, tolerance?: number | null): NearestObject | null

The item of items nearest to this curve, as a NearestObject, or null where none lies within max_distance (none, NaN or infinite: no limit) or items is empty. Each item is a Solid, a NurbsCurve, a Projector, a TriangleMesh or a NurbsSurface (both answered exactly) or a point. Items are asked in order, each with the best distance so far as its limit, and once one touches the curve no later one is asked; equal distances go to the earlier item. tolerance (none, 0 or NaN: each solid's effective tolerance) sizes each solid's search; a projector keeps its own, and its lock is held for the whole curve query, so other threads asking it wait. An item of none of those kinds or a point not finite (each naming item <i>), a negative max_distance, a negative or infinite tolerance, or a body's own refusal throws BuildError.

NurbsCurve.tween()

tween(other: NurbsCurve, count: number, method?: TweenMethod, samples?: number | null, align?: boolean, tolerance?: number | null): NurbsCurve[]

count curves blending evenly from this curve to other, as Rhino's CreateTweenCurves family: the i-th at the fraction (i + 1) / (count + 1). method says how the two are brought to one structure first. "plain" blends control point by control point and weight by weight, so the curves must already share degree, control-point count and knots (throws BuildError otherwise; Rhino answers with a curve that is not a blend). "matching" makes them compatible exactly, by degree elevation and knot merging, and blends in homogeneous coordinates: rational curves stay rational, and two non-rational curves blend point for point along their parameters. "sampling" divides both into samples equal pieces by arc length, blends the samples and fits a cubic through them — the robust choice for curves of very different shape; closed curves give a periodic tween. With align (the default) other is first lined up with this curve: turned to run the same way and, for closed curves, its seam moved round to match this one's start, so the tweens do not twist. Rhino's calls leave that to the caller; align=False does the same. tolerance (None: the curves' effective tolerance) decides whether a curve is closed and how closely the samples sit at their arc lengths. One curve open and the other closed throws BuildError.

NurbsCurve.projectToPlane()

projectToPlane(origin: Point3, normal: Point3, direction?: Point3 | null): NurbsCurve

This curve projected onto the plane through origin with normal, along direction (None: the normal). Exact — the control points move, the weights stay. A direction lying in the plane throws BuildError.

NurbsCurve.projectToFace()

projectToFace(solid: Solid, face: number, direction: Point3, tolerance?: number | null): NurbsCurve

This curve projected along direction onto face face of solid (its whole surface): sampled, each sample carried along the direction to the surface, fitted within tolerance. A sample whose ray misses the surface, or a result straying past the tolerance, throws BuildError.

NurbsCurve.pullToFace()

pullToFace(solid: Solid, face: number, tolerance?: number | null): NurbsCurve

This curve pulled onto face face of solid (its whole surface): each sample moved to its nearest surface point, fitted within tolerance.

NurbsCurve.offsetOnSheet()

offsetOnSheet(solid: Solid, distance: number, tolerance?: number | null): NurbsCurve

This curve, lying on the sheet solid (any of its faces, within ten times tolerance), offset distance along it: each sample walked that far across the sheet, square to the curve — left of its run seen from the outward side for a positive distance — over the seams of a joined sheet and onto the surface continued past its edge, and fitted within tolerance, each side of a crease apart. fit_error is the larger of the fit's error and the distance off the sheet. A curve that does not lie on the sheet throws BuildError.

NurbsCurve.offset()

offset(distance: number, direction: Point3, tolerance?: number | null): NurbsCurve

This curve moved distance in space, square to its tangent and to direction, as Rhino's Curve.Offset: to the right of its run seen from the tip of direction for a positive distance, to the left for a negative one. A line, or a circular arc in a plane square to direction, offsets exactly (fit_error 0); anything else is fitted within tolerance (none: the effective tolerance), fit_error bounding the distance from the exact offset. A closed smooth curve offsets to a closed curve; a distance of 0 is a copy. A zero direction, a distance that is not finite, a corner (a kink the offset would tear at: offset a Profile for corner styles), a curve running along direction, or an offset that folds over (an arc's radius used up, a turn tighter than distance) throws BuildError.

NurbsCurve.offsetNormalToSheet()

offsetNormalToSheet(solid: Solid, distance: number, tolerance?: number | null): NurbsCurve

This curve, lying on the sheet solid (within ten times tolerance), moved distance along the sheet's normal at each of its points — off the sheet the way its faces face for a positive distance — as Rhino's OffsetNormalToSurface, and fitted within tolerance (none: the inputs' effective tolerance); fit_error bounds the distance from the exact offset. A curve off the sheet, one crossing a crease (faces whose normals differ by more than a degree), a distance that is not finite, or an offset that folds over throws BuildError.

NurbsCurve.offsetTangentToSheet()

offsetTangentToSheet(solid: Solid, distance: number, tolerance?: number | null): NurbsCurve

This curve, lying on the sheet solid (within ten times tolerance), moved distance in the sheet's tangent plane, square to the curve — along the sheet's normal crossed with the curve's tangent for a positive distance, straight rather than walked across the sheet as NurbsCurve.offsetOnSheet() does — as Rhino's OffsetTangentToSurface. Fitted within tolerance (none: the inputs' effective tolerance); fit_error bounds the distance from the exact offset. A curve off the sheet, one crossing a crease, a distance that is not finite, or an offset that folds over throws BuildError, as for NurbsCurve.offsetNormalToSheet().

NurbsCurve.pullBack()

pullBack(solid: Solid, face: number, tolerance?: number | null): NurbsCurve

This curve, lying on face face of solid within tolerance, read back into the face's surface parameters, as Rhino's Pullback: a uv curve — a curve in the z = 0 plane whose x is u and y is v — over this curve's own domain, its point at t paired with this curve's at t. The face is its whole surface; its trims are not read. Exact where the curve runs along a parameter line and in a plane, fitted elsewhere. Across a periodic surface's seam the uv curve runs on rather than jumping a period; where the curve ends at a pole (a sphere's, a cone's apex) it meets the pole line square, and where it passes over one it gains a run along the pole line, so past that point its parameter no longer pairs with this curve's. fit_error is the deviation reached. A curve standing off the surface past the tolerance throws BuildError, naming where and how far.

NurbsCurve.pushUp()

pushUp(solid: Solid, face: number, tolerance?: number | null): NurbsCurve

This uv curve (z = 0: x is u, y is v) carried out through face face's surface of solid, as Rhino's Pushup: a curve in space over the same domain within tolerance of the surface's points along it — exact on a plane and along a parameter line (the surface's own circle, ruling or isocurve). fit_error is the deviation reached. A curve off the z = 0 plane, or one leaving a patch's domain on a side that does not wrap, throws BuildError.

NurbsCurve.fitToFace()

fitToFace(solid: Solid, face: number, direction?: Point3 | null, knots?: Iterable<number>, tolerance?: number | null): NurbsCurve

This curve carried onto face face of solid and fitted to the face's surface parameter it crosses, as Rhino's FitCurveToSurface. It is projected onto the surface along direction, or pulled (each point to its nearest) where there is none; the trace must cross the face's parameter rectangle — the box its trims span in its surface's parameters — from one side to the opposite one. The result is parametrised by the parameter it crosses: at t it is over u = t (or v = t), running with it rising, over the face's range, on the surface's own knots in that direction plus knots, at the surface's degree there (at least 3) — knot-compatible with the surface's isocurves. Where it is farther than tolerance from the trace, knots are added halfway along the spans still off; fit_error bounds the distance from the exact trace. A trace that does not cross, one that turns back, or a knot outside the range throws BuildError.

NurbsCurve.throughOnFace()

static throughOnFace(solid: Solid, face: number, points: Iterable<Point3>, closed?: boolean, tolerance?: number | null): NurbsCurve

A smooth curve through points lying on face face of solid, as Rhino's InterpolatedCurveOnSurface: each point's nearest foot on the face's surface, interpolated in its parameters (cubic, chord-length) and carried out through it within tolerance. Feet either side of a seam are joined the short way. closed runs back to the first point, smooth across the join; a ring round a cylinder closes. A point farther than tolerance from the surface throws BuildError, naming its index.

NurbsCurve.throughUvOnFace()

static throughUvOnFace(solid: Solid, face: number, uvs: Iterable<[number, number]>, closed?: boolean, tolerance?: number | null): NurbsCurve

A smooth curve through the surface parameters uvs ((u, v) pairs) of face face of solid, as Rhino's InterpolatedCurveOnSurfaceUV: interpolated in the parameters (cubic, chord-length) and carried out through the surface within tolerance. closed runs back to the first point; a ring whose last point is a whole period short of the first winds round a periodic surface and closes. A ring winding both parameters at once, or fewer points than the curve needs, throws BuildError.

NurbsCurve.shortPath()

static shortPath(solid: Solid, face: number, a: [number, number], b: [number, number], tolerance?: number | null): NurbsCurve

The shortest path on face face's surface of solid from the surface parameters a to b ((u, v) pairs), as Rhino's ShortPath, within tolerance: a geodesic — the straight run between them in the parameters relaxed until its length settles, tried a period either way round a periodic surface and the shortest kept. It is the shortest among those starts: the quadrics' and a gentle patch's shortest path, while a hill between the points may hide a shorter way round. The face's trims are not read. fit_error is the deviation reached. Two equal points throws BuildError.

NurbsCurve.isIsoparametric()

isIsoparametric(solid: Solid, face: number, tolerance?: number | null): ['u' | 'v', number] | null

Whether this curve runs along one of face face's isocurves of solid, as Rhino's IsIsoparametric: ("u", v) along u with v held, ("v", u) along v with u held, or null — neither, or not on the face. Read back into the face's parameters at tolerance (0 or null the solid's own), it is an isocurve where its parameter spread across the held direction is within tolerance in space.

NurbsCurve.reverse()

reverse(): NurbsCurve

The same curve run the other way over the same domain.

NurbsCurve.trim()

trim(t0: number, t1: number): NurbsCurve

The part from t0 to t1 (t0 < t1, both inside the domain), over t0..t1.

NurbsCurve.extend()

extend(length: number, atStart?: boolean): NurbsCurve

This curve continued length past its end (or its start, at_start=True) along its own end polynomial: position, tangent and curvature there unchanged, and every old parameter still names its old point — the domain grows on that side only.

NurbsCurve.elevate()

elevate(by?: number): NurbsCurve

The same curve at degree degree + by (the result at most 12).

NurbsCurve.insertKnot()

insertKnot(t: number, times?: number): NurbsCurve

The same curve, exactly, with the knot t (strictly inside the domain) inserted times times (Boehm insertion; Rhino's Knots.InsertKnot): more control points, every point of the curve kept. A t outside the domain, a times of 0, or a multiplicity there past the degree, throws BuildError.

NurbsCurve.refineKnots()

refineKnots(knots: Iterable<number>): NurbsCurve

The same curve, exactly, with every knot of knots inserted (non-decreasing, each strictly inside the domain, no multiplicity past the degree).

NurbsCurve.removeKnot()

removeKnot(t: number, times?: number, tolerance?: number | null): { curve: NurbsCurve; removed: number }

Up to times copies of the inner knot t removed (Rhino's Knots.RemoveKnots), each only while the curve stays within tolerance of itself (none, 0 or NaN: the curve's effective tolerance): the curve and how many went — 0, and an unchanged copy, where none could (a knot holding a corner). A t that is not an inner knot, or a negative tolerance, throws BuildError.

Answers { curve, removed } on a curve and { surface, removed } on a surface.

NurbsCurve.makeCompatible()

static makeCompatible(curves: Iterable<NurbsCurve>): NurbsCurve[]

curves made compatible (Rhino's MakeCompatible): each reparametrised to [0, 1], raised to the highest degree among them and refined with every other's knots, so all share one degree, one knot vector and one control-point count — each the same point set it was, rational curves exactly. The ground NurbsCurve.tween()'s "matching" and a loft stand on. No curves throws BuildError.

NurbsCurve.reparametrize()

reparametrize(lo: number, hi: number): NurbsCurve

The same curve over the domain [lo, hi] (lo < hi), the parameter mapped affinely (Rhino's Reparameterize).

NurbsCurve.makeUniform()

makeUniform(): NurbsCurve

The control points and weights over evenly spaced knots on the domain (Rhino's MakeUniform): clamped where it was clamped. The shape moves unless the knots were uniform already.

NurbsCurve.nonRational()

nonRational(): NurbsCurve

Every weight 1, the control points where they were (Rhino's MakeNonRational): exact where the weights were all equal, otherwise the plain B-spline of the same polygon.

NurbsCurve.grevilleParameters()

grevilleParameters(): number[]

The Greville abscissae, one per control point: each the mean of the degree knots after its first — where a control point pulls hardest, and the parameters to interpolate at.

NurbsCurve.grevillePoints()

grevillePoints(): number[][]

The curve's points at its NurbsCurve.grevilleParameters(), one per control point.

NurbsCurve.periodic()

periodic(smooth?: boolean): NurbsCurve

A periodic curve (seamless, C^(degree-1) all round) of the same degree (Rhino's CreatePeriodicCurve); a closed curve's repeated last control point is dropped first. smooth false keeps the control points and weights and wraps the polygon over uniform knots on [0, m] for m points; true (the default) keeps close to the curve instead: a periodic curve through its Greville points on [0, 1]. Fewer than degree + 1 distinct control points throws BuildError.

NurbsCurve.mean()

mean(other: NurbsCurve, tolerance?: number | null): NurbsCurve

The curve halfway between this one and other (Rhino's CreateMeanCurve): other lined up with this one first (NurbsCurve.linedUpWith()), the two made compatible exactly and averaged — two arcs about one centre give the arc of the mean radius. tolerance (none, 0 or NaN: the curves' effective tolerance) decides whether each is closed. One curve closed and the other open throws BuildError.

NurbsCurve.linedUpWith()

linedUpWith(other: NurbsCurve, tolerance?: number | null): NurbsCurve

This curve turned to run with other — an open one reversed where its ends lie crosswise to other's, a closed one reversed where it goes round the other way and its seam moved to match — the same point set either way; unchanged where one is closed and the other open.

NurbsCurve.directionsMatch()

directionsMatch(other: NurbsCurve, tolerance?: number | null): boolean

Whether other runs the same way as this curve (Rhino's DoDirectionsMatch): two closed curves going round the same way, otherwise other's ends lying along this one's rather than crosswise. A closed curve with no area throws BuildError.

NurbsCurve.conicType()

conicType(tolerance?: number | null): ConicType | null

Which conic this curve is, read from its points within tolerance (none, 0 or NaN: its effective tolerance; Rhino's GetConicSectionType): "circle", "ellipse", "hyperbola" or "parabola", or null for a curve that is none (straight, not planar, off every conic). Any exact form reads the same: a circle raised to degree 5 is a circle. A negative tolerance throws BuildError.

NurbsCurve.transform()

transform(t: Transform | MatrixLike): NurbsCurve

This curve through the affine map t (a Transform or 16 numbers): its control points mapped, weights and knots kept — exact. A singular map, a projection, is allowed.

NurbsCurve.degree

readonly degree: number

The curve's degree.

NurbsCurve.controlPoints

readonly controlPoints: number[][]

The control points, as (x, y, z) triples.

NurbsCurve.weights

readonly weights: number[]

One weight per control point; all 1 for a plain B-spline.

NurbsCurve.knots

readonly knots: number[]

The full knot vector, len(control_points) + degree + 1 values.

NurbsCurve.domain

readonly domain: [number, number]

The parameter domain (lo, hi).

NurbsCurve.isRational

readonly isRational: boolean

Whether the weights differ: a true NURBS rather than a plain B-spline.

NurbsCurve.isClosed

readonly isClosed: boolean

Whether the curve ends where it starts (to 1e-10 of its size).

NurbsCurve.point()

point(t: number): number[]

The point at parameter t; a t outside the domain throws BuildError.

NurbsCurve.derivatives()

derivatives(t: number, order?: number): number[][]

The point and its derivatives at t up to order (at most 8): [C, C', C'', ...].

NurbsCurve.curvature()

curvature(t: number): Curvature

The Curvature and Frenet frame at t. A point where the curve has no tangent throws BuildError.

NurbsCurve.length()

length(accuracy?: number): Length

The curve's length as a Length, to the relative accuracy (0 asks for the default).

NurbsCurve.lengthBetween()

lengthBetween(t0: number, t1: number, accuracy?: number): Length

The length over [t0, t1] of the curve's parameter as a Length, as Rhino's GetLength(subdomain), to the relative accuracy (0 asks for the default). A range running backwards or outside the domain throws BuildError.

NurbsCurve.pointAtLength()

pointAtLength(s: number, accuracy?: number): At

The point at arc length s from the start, as an At (segment empty).

NurbsCurve.pointAtNormalizedLength()

pointAtNormalizedLength(f: number, accuracy?: number): At

The point at the fraction f of the curve's length, f in [0, 1], as an At, as Rhino's PointAtNormalizedLength (its parameter is NormalizedLengthParameter's answer). 0 is the start and 1 the end exactly.

NurbsCurve.pointsAtNormalizedLengths()

pointsAtNormalizedLengths(fs: Iterable<number>, accuracy?: number): At[]

The points at each fraction of fs of the curve's length, as At samples in the order given, over one measure of it, as Rhino's NormalizedLengthParameters.

NurbsCurve.divideByCount()

divideByCount(n: number, accuracy?: number): At[]

The curve in n pieces of equal arc length: n + 1 At samples, n for a closed curve (its start not repeated).

NurbsCurve.divideByLength()

divideByLength(step: number, accuracy?: number): At[]

Samples every step of arc length from the start; the last piece is whatever is left, and a closed curve never repeats its start.

NurbsCurve.divideEquidistant()

divideEquidistant(distance: number): At[]

Points along the curve each distance in a straight line from the one before, as Rhino's DivideEquidistant, each an At: the first the curve's start, each next the first point further on that is distance from the last, until none is; a closed curve does not wrap. Each point's error is how far its chord is from distance.

NurbsCurve.divideAsContour()

divideAsContour(start: Point3, end: Point3, interval: number): At[]

Where the curve crosses the planes square to end - start through start and every interval on towards end, as Rhino's DivideAsContour, each an At in the curve's parameter order; a plane the curve lies in gives none. Each point's error is its distance from its plane.

NurbsCurve.mass()

mass(accuracy?: number): LengthMass

The curve's length mass properties per unit length density as a LengthMass, as Rhino's LengthMassProperties, to the relative accuracy (0 asks for the default).

NurbsCurve.planeHits()

planeHits(origin: Point3, normal: Point3): At[]

Where the curve crosses the plane through origin with normal, in parameter order, each an At whose error is the point's distance from the plane. A curve lying in the plane throws BuildError; a touch that does not cross is not listed.

NurbsCurve.faceHits()

faceHits(solid: Solid, face: number, tolerance?: number | null): At[]

Where the curve crosses face face of solid (its whole surface), within tolerance of it, in parameter order, each an At whose error is the point's distance from the surface. A touch that does not cross is not listed.

NurbsCurve.comb()

comb(n?: number, scale?: number): [number[], number[]][]

A curvature comb to draw: at n + 1 even parameters, the curve point and that point moved by -scale * kappa * normal, out of the bend. Straight stretches give zero teeth.

NurbsCurve.inflections()

inflections(): At[]

Where the curvature turns from one side to the other, in parameter order, each an At (error zero): the comb flipping sides. Empty for a curve that bends one way only — what a test of a design line asks for.

NurbsCurve.knotContinuity()

knotContinuity(): KnotContinuity

How smoothly the curve runs through its own knots (a closed curve's seam among them), as a KnotContinuity: the largest turn of its tangent and the largest jump of its curvature.

HealthReport

class HealthReport

What is wrong with a body, as plain data: what Solid.health() returns. Nothing in it moves the body. It lists the free edges (the sides only one face bounds) and the wires they chain into, the features below the tolerance, the loose edges, what sewing would join and leave, and, if asked for, where the body's mesh cracks. The tolerance is an absolute length, as Rhino's model tolerance is; it is reported back as used.

HealthReport.tolerance

tolerance: number

The length below which a feature is small and a gap closes, as used: by default 1e-4 times the body's diagonal. A value that is not finite and positive (NaN, infinite, zero or negative) takes the default.

HealthReport.rounding

rounding: number

The rounding the body's vertices are merged at, as used.

HealthReport.extent

extent: number

The body's diagonal, the length the default tolerance is a fraction of.

HealthReport.freeEdges

freeEdges: FreeEdge[]

The free edges, as FreeEdge rows, each wire's edges together and in order.

HealthReport.wires

wires: FreeWire[]

The chains the free edges make end to end, as FreeWire rows.

HealthReport.small

small: SmallFeature[]

The features below the tolerance, as SmallFeature rows.

HealthReport.looseEdges

looseEdges: number

How many shared edges are loose: the two faces' sides along the edge lie further apart than the larger of the tolerance the body recorded for the edge and the one given.

HealthReport.worstLoose

worstLoose: number

The widest such gap; 0 when no edge is loose.

HealthReport.sewPairs

sewPairs: number

How many pairs of free edges Brep.sew() (or Solid.joinSheets()) would join: those with shared_ends 2.

HealthReport.sewRefused

sewRefused: number

How many groups of free edges it would leave free.

HealthReport.sewWorstGap

sewWorstGap: number

The widest gap it would sew.

HealthReport.cracks

cracks: Cracks | null

Where the body's mesh cracks, as a Cracks; null unless the call asked for the mesh. Cracks are only counted on a closed body: for an open one the census is empty by design, so watertight false beside no edges means "not asked", not "nothing found".

HealthReport.worstGap

worstGap: number

The widest gap between a free edge and its partner. A rim has no true partner, so it reads as a gap the size of the part.

HealthReport.wireEdges()

wireEdges(wire: number): FreeEdge[]

The free edges of one wire, by its number in wires, in order.

FreeEdge

class FreeEdge

One free edge: a side only one face bounds, with its nearest partner. The partner is the nearest free edge other than a neighbour on its own wire, so the rim of a sheet reads as a gap the size of the part rather than as a crack, and a real seam reads as a small gap. The partner is a row index into free_edges.

FreeEdge.trim

trim: number

The face's side this is.

FreeEdge.edge

edge: number | null

The edge it lies on; null for a side that has no edge.

FreeEdge.face

face: number

The face it bounds.

FreeEdge.wire

wire: number

The free wire it is on: a row of wires.

FreeEdge.partner

partner: number | null

The nearest free edge across the gap, as an index into free_edges; null if there is none.

FreeEdge.sharedEnds

sharedEnds: number

How many of its two ends it shares with the partner: 2 is what Brep.sew() joins.

FreeEdge.length

length: number

Its length.

FreeEdge.gap

gap: number

The distance to the partner; infinite without one.

FreeWire

class FreeWire

A chain of free edges end to end.

FreeWire.first

first: number

The row of free_edges it starts at: its edges are the rows first to first + count.

FreeWire.count

count: number

How many free edges it holds.

FreeWire.closed

closed: boolean

Whether it closes on itself.

FreeWire.length

length: number

Its total length.

FreeWire.widestGap

widestGap: number

The widest gap from any of its edges to a partner.

SmallFeature

class SmallFeature

Something below the tolerance.

SmallFeature.kind

kind: SmallFeatureKind

What it is: short_edge, collapsed_edge, sliver_face, tiny_face, tiny_body or small_hole (an inner loop whose edges are all free, below the tolerance in area or width: a pinhole in an open sheet; a hole with walls is not one).

SmallFeature.index

index: number

Its edge, face or body number; a small hole's is its loop number.

SmallFeature.size

size: number

How small it is.

Cracks

class Cracks

What a mesh of the body shows, asked for with mesh=True: the call meshes the body. Only a closed body is counted: an open one's census is empty by design, as its rim is not a crack.

Cracks.watertight

watertight: boolean

Whether the mesh has no open or folded edge.

Cracks.open

open: number

How many mesh edges only one triangle uses.

Cracks.folded

folded: number

How many mesh edges more than two triangles use.

Cracks.crossings

crossings: number

How many pairs of triangles pass through each other.

Cracks.edges

edges: number[]

The body's edges the cracks lie along.

HealReport

class HealReport

What Solid.heal() did, as plain data: the fixes it made, the small features it left and why, and the body's health before and after at the tolerance it healed at. Indices are the input body's.

HealReport.tolerance

tolerance: number

The tolerance it healed at, as used: by default 1e-4 times the body's diagonal.

HealReport.moved

moved: number

The furthest any trim the result keeps moved, measured: the edited trims against the originals. Not the same measure as a HealFix's moved, which is how far that fix's merged vertices moved: a curve can move further than its ends, and the trims of a dropped edge are not measured at all, so either can be the larger.

HealReport.guarded

guarded: boolean

Whether the guard refused a fix: the full result was worse (less closed, more free or non-manifold edges, or no faces left), so the face pass's fixes were refused and the rest kept, or, if that was still worse, every fix was refused and the body came back as it was. Refused fixes are listed as body_guard.

HealReport.fixes

fixes: HealFix[]

What was done, as HealFix rows, in the order it was done. A short edge removed as part of a face is that face's fix and is not listed again.

HealReport.refused

refused: HealRefusal[]

What health listed as small and was left, as HealRefusal rows.

HealReport.smallBefore

smallBefore: number

How many small features health listed on the input.

HealReport.smallAfter

smallAfter: number

How many it lists on the result.

HealReport.freeBefore

freeBefore: number

The input's free edges (sides only one face bounds).

HealReport.freeAfter

freeAfter: number

The result's free edges.

HealReport.closedBefore

closedBefore: boolean

Whether the input was closed.

HealReport.closedAfter

closedAfter: boolean

Whether the result is closed.

HealReport.nonmanifoldBefore

nonmanifoldBefore: number

The input's edges three or more faces share.

HealReport.nonmanifoldAfter

nonmanifoldAfter: number

The result's.

HealFix

class HealFix

One small feature removed.

HealFix.kind

kind: SmallFeatureKind

What it was, as SmallFeature's kind.

HealFix.index

index: number

Its edge, face or loop number in the input, as health gave it.

HealFix.size

size: number

How small it was.

HealFix.moved

moved: number

How far the vertices this fix merged moved. The report's own moved is a second measure, how far any surviving trim moved, measured; either can be the larger.

HealRefusal

class HealRefusal

One small feature left, and why.

HealRefusal.kind

kind: SmallFeatureKind

What it is, as SmallFeature's kind.

HealRefusal.index

index: number

Its edge, face or loop number in the input.

HealRefusal.why

why: HealWhy

would_empty_loop (removing the edge would leave a loop with no trims: the face pass's case), closed (both ends already one vertex: a tiny closed curve), seam (one face uses the edge twice), chain (the vertices to merge span more than the tolerance), neighbours_part (a sliver's two long sides part by more than the tolerance), uneven (a sliver's long edges are not two, one per side), non_manifold (a sliver side three or more trims share), has_holes (the sliver or tiny face has inner loops), body_guard (the guard refused the fix), toggled (its kind switched off) or unsupported (a tiny body, which healing never removes).

HealRefusal.figure

figure: number

The width of a chain, the gap of neighbours_part; 0 otherwise.

RecognizeReport

class RecognizeReport

What Solid.recognize() did, as plain data: the faces and edges given an analytic kind, the faces left free-form and why, and the tolerance it fitted to. Faces and edges are numbered as in the body, before and after alike.

RecognizeReport.tolerance

tolerance: number

The tolerance it fitted to, as used: by default 1e-6 of the body's extent.

RecognizeReport.faces

faces: RecognizedFace[]

The faces given an analytic kind, as RecognizedFace rows.

RecognizeReport.refused

refused: RecognizeRefusal[]

The free-form faces left, as RecognizeRefusal rows.

RecognizeReport.edges

edges: RecognizedEdge[]

The edges whose curve was given an analytic kind, as RecognizedEdge rows, in edge order.

RecognizeReport.edgesLeft

edgesLeft: number

How many edges were left on a free-form curve.

RecognizeReport.worstFace

worstFace: number

The furthest any face taken lies from its analytic surface; 0 when none was taken.

RecognizeReport.worstEdge

worstEdge: number

The furthest any edge taken lies from its analytic curve; 0 when none was taken.

RecognizedFace

class RecognizedFace

One face given an analytic kind.

RecognizedFace.face

face: number

Its face number, the same before and after.

RecognizedFace.kind

kind: RecognizedFaceKind

plane, cylinder, cone, sphere or torus.

RecognizedFace.deviation

deviation: number

The furthest any sample of the face or point of its edges lies from the analytic surface.

RecognizeRefusal

class RecognizeRefusal

One face left free-form, and why.

RecognizeRefusal.face

face: number

Its face number.

RecognizeRefusal.why

why: RecognizeWhy

no_kind (no kind fits within the tolerance), mixed_normals (its normals point both ways), parameter_trims (a trim in its surface's parameters could not be lifted to space) or too_few_samples.

RecognizeRefusal.closest

closest: number | null

For no_kind, the deviation of the kind that came closest; null otherwise.

RecognizedEdge

class RecognizedEdge

One edge whose curve was given an analytic kind.

RecognizedEdge.edge

edge: number

Its brep edge id, as edge_tolerance takes one.

RecognizedEdge.kind

kind: RecognizedEdgeKind

line, circle or ellipse.

RecognizedEdge.deviation

deviation: number

The furthest any point of the curve or the edge lies from the analytic curve.

JoinReport

class JoinReport

What Solid.joinSheets() did.

JoinReport.sewn

readonly sewn: number

Edges sewn: each is two naked edges become one shared edge.

JoinReport.worstGap

readonly worstGap: number

The widest gap between two sewn edges; 0 where every edge met exactly.

JoinReport.nakedBefore

readonly nakedBefore: number

Edges bordered by one face before the sewing.

JoinReport.nakedAfter

readonly nakedAfter: number

Edges bordered by one face after it: 0 for a closed result.

JoinReport.refused

readonly refused: number

Groups of naked edges sharing both ends that were left apart: too far apart, or three or more.

JoinReport.turned

readonly turned: number

Faces whose sense the join turned.

JoinReport.closed

readonly closed: boolean

Whether the result is closed — every edge bordered twice — and so a solid.

SymmetryReport

class SymmetryReport

What Solid.mirrorJoin() did, and how well the seam on the plane meets. The curvature is the largest difference of the two sides' normal curvatures in any one direction: across a mirror the curvature square to the seam is always equal, and what can differ is the twist along it.

SymmetryReport.seams

readonly seams: number

Edges on the plane, each one face of the half and one of its mirror.

SymmetryReport.squared

readonly squared: number

Faces of the half squared to the plane.

SymmetryReport.moved

readonly moved: number

The furthest any control point moved squaring them.

SymmetryReport.gap

readonly gap: number

The seam's largest gap between the two sides (G0).

SymmetryReport.angle

readonly angle: number

The seam's largest angle between the two sides' normals, in radians (G1).

SymmetryReport.curvature

readonly curvature: number

The seam's largest difference of normal curvature in any one direction (G2).

SymmetryReport.naked

readonly naked: number

Naked edges left on the body: the half's own boundary off the plane, and any edge on it with no mirror to sew to.

PatternReport

class PatternReport

What Solid.pattern() or Solid.patternFeature() did.

PatternReport.instances

readonly instances: number

Instances placed, after the skips.

PatternReport.booleans

readonly booleans: number

Booleans run: copies apart from each other share one.

PatternReport.missed

readonly missed: number

Copies of a feature's tool sharing no volume with the body: dropped for a cut, kept as a body of their own for a join.

HoleReport

class HoleReport

What Solid.hole() did.

HoleReport.holes

readonly holes: number

Holes drilled, one a point.

HoleReport.bottoms

readonly bottoms: readonly number[]

Per hole, the distance along the axis from the point to where the bore ends, the drill point excluded: depth for a blind hole; for the others the deepest point of the material it passes, rim included.

HoleReport.facesAdded

readonly facesAdded: number

Faces of the result on no surface of the body.

HoleReport.threadDepths

readonly threadDepths: readonly number[]

Per hole, a tapped thread's length from where it starts; empty without a thread.

ThreadSize

class ThreadSize

One row of the thread size table (blacksmith.threadSizes(), blacksmith.threadSize()): ISO metric coarse M1 .. M64, ISO metric fine M8x1 .. M64x4, UNC #1 .. 1-1/2" and UNF #0 .. 1-1/2" (ASME B1.1). Every length in millimetres; the derived figures are the basic ISO 68-1 profile's. Frozen.

ThreadSize.family

readonly family: ThreadFamily

"iso_metric_coarse", "iso_metric_fine", "unc" or "unf".

ThreadSize.designation

readonly designation: string

"M10", "M10x1.25", "1/4-20 UNC", "#10-32 UNF".

ThreadSize.size

readonly size: string

"M10", "1/4", "#10".

ThreadSize.major

readonly major: number

The major (nominal) diameter.

ThreadSize.pitch

readonly pitch: number

The pitch (25.4 / TPI for a UN row).

ThreadSize.minor

readonly minor: number

The basic minor diameter D - 1.082532 P: the internal thread's crest.

ThreadSize.pitchDiameter

readonly pitchDiameter: number

The basic pitch diameter D - 0.649519 P.

ThreadSize.tapDrill

readonly tapDrill: number

D - P: the ~75 % engagement rule, not a drill chart (M6 5.0, M10 8.5).

ThreadSize.clearance

readonly clearance: Readonly<{ fine?: number; medium?: number; coarse?: number }>

ISO 273's clearance holes by fit, {"fine": .., "medium": .., "coarse": ..}; empty for a UN row or a size ISO 273 has no row for.

ThreadReport

class ThreadReport

What Solid.thread() did.

ThreadReport.internal

readonly internal: boolean

True for a bore's thread, false for a rod's.

ThreadReport.major

readonly major: number

The major diameter.

ThreadReport.minor

readonly minor: number

The basic minor diameter.

ThreadReport.pitch

readonly pitch: number

The pitch.

ThreadReport.start

readonly start: readonly [number, number, number]

The point on the axis where the span begins.

ThreadReport.direction

readonly direction: readonly [number, number, number]

The unit direction along the axis into the span.

ThreadReport.length

readonly length: number

The span's length.

ThreadReport.turns

readonly turns: number

The coil's turns, its run past an open end included.

ThreadReport.facesAdded

readonly facesAdded: number

Faces of the result on no surface of the body.

ThreadRecord

class ThreadRecord

A cosmetic thread as a face carries it (Solid.cosmeticThread(), or a tapped hole not modelled).

ThreadRecord.designation

readonly designation: string

The table row's designation; "" for an explicit form.

ThreadRecord.major

readonly major: number

The major diameter.

ThreadRecord.pitch

readonly pitch: number

The pitch.

ThreadRecord.length

readonly length: number

The span's length.

ThreadRecord.offset

readonly offset: number

How far from the start end the span begins.

ThreadRecord.internal

readonly internal: boolean

True for a bore's thread.

ThreadRecord.leftHanded

readonly leftHanded: boolean

True for a left-handed thread.

ThreadRecord.reverse

readonly reverse: boolean

True where the span starts from the face's other end.

Pattern

class Pattern

Placements for Solid.pattern() and Solid.patternFeature(): lists of rigid Transforms, instance 0 the identity (the original). skip leaves instances out by index (Fusion's suppressed instances), 0 included. Angles are radians. A count of 0, a spacing not finite, a zero direction or axis, a skip past the count, or every instance skipped throws BuildError.

Pattern.rectangular()

static rectangular(direction1: Point3, count1: number, spacing1: number, direction2?: Point3 | null, count2?: number, spacing2?: number, symmetric?: boolean, skip?: Iterable<number>): Transform[]

count1 instances spacing1 apart along direction1, times count2 spacing2 apart along direction2 (null: one row); row-major, direction 1 fastest. symmetric puts count on each side of the original along each direction (2 count - 1, at offsets 0, +s, -s, +2s, ...).

Pattern.circular()

static circular(axisPoint: Point3, axisDirection: Point3, count: number, angle?: number, symmetric?: boolean, skip?: Iterable<number>): Transform[]

count instances about the line through axis_point along axis_direction: a full turn (angle 2 pi, the default) spaces them evenly; less spreads them over angle with both ends occupied. symmetric spreads count over angle on each side; with a full turn, which has no sides, it throws BuildError. Right-handed about the direction.

Pattern.along()

static along(curve: NurbsCurve, count: number, spacing?: number | null, orient?: PatternOrient, skip?: Iterable<number>): Transform[]

count instances along a NurbsCurve by arc length from its start, spacing apart, or spread over its whole length with both ends occupied (spacing null). orient "fixed" translates each copy; "path" also turns it by the curve's rotation-minimising frame from the first instance's.

Continuity

class Continuity

How well two faces meet along their sides — what Solid.continuity() returns. The angle ignores which way each face points; the curvature is the normal curvature square to the edge, about the first face's normal.

Continuity.gap

readonly gap: number

The largest distance between the two sides (G0).

Continuity.gapAt

readonly gapAt: number[]

Where on the first side it is.

Continuity.angle

readonly angle: number

The largest angle between the faces' normals, in radians (G1).

Continuity.angleAt

readonly angleAt: number[]

Where on the first side it is.

Continuity.curvature

readonly curvature: number

The largest difference of normal curvature across the edge (G2).

Continuity.curvatureAt

readonly curvatureAt: number[]

Where on the first side it is.

Continuity.samples

readonly samples: number

How many points along the first side were asked.

KnotContinuity

class KnotContinuity

How smoothly a curve runs through its own knots — what NurbsCurve.knotContinuity() returns. A curve with no inner knot, and not closed, reads zero at its start.

KnotContinuity.angle

readonly angle: number

The largest turn of the tangent at a knot, in radians (G1).

KnotContinuity.angleParameter

readonly angleParameter: number

The knot it is at.

KnotContinuity.angleAt

readonly angleAt: number[]

The point there.

KnotContinuity.curvature

readonly curvature: number

The largest jump of the curvature vector kappa * normal at a knot (G2).

KnotContinuity.curvatureParameter

readonly curvatureParameter: number

The knot it is at.

KnotContinuity.curvatureAt

readonly curvatureAt: number[]

The point there.

CurvatureTurns

class CurvatureTurns

Where a face's curvatures change sign — what Solid.curvatureTurns() returns. A sample within a millionth of the face's size of flat is neither sign: a cylinder's patch reads no Gaussian area.

CurvatureTurns.gaussianPositive

readonly gaussianPositive: number

How many separate areas of the sample grid have a positive Gaussian curvature (a dome's).

CurvatureTurns.gaussianNegative

readonly gaussianNegative: number

How many have a negative one (a saddle's).

CurvatureTurns.gaussianTurns

readonly gaussianTurns: At[]

The points between opposite Gaussian signs, each an At: tangent the face's unit normal there, parameter its u.

CurvatureTurns.meanPositive

readonly meanPositive: number

How many separate areas have a positive mean curvature, about the face's outward normal.

CurvatureTurns.meanNegative

readonly meanNegative: number

How many have a negative one.

CurvatureTurns.meanTurns

readonly meanTurns: At[]

The points between opposite mean signs, as gaussian_turns.

CurvatureTurns.samples

readonly samples: number

The grid's steps each way.

HighlightKink

class HighlightKink

The worst kink of the highlight lines crossing an edge — what Solid.highlightKink() returns.

HighlightKink.angle

readonly angle: number

The angle in radians, 0 to pi/2, between a highlight line on one face and the same line on the other.

HighlightKink.at

readonly at: number[]

The point along the edge it is at.

HighlightKink.lightPoint

readonly lightPoint: number[]

A point on the straight light tube that shows it.

HighlightKink.lightDirection

readonly lightDirection: number[]

The tube's unit direction.

HighlightKink.samples

readonly samples: number

How many points along the edge were read.

DraftPoint

class DraftPoint

A point of a face and the draft angle there — what Solid.draftAngleAt() returns.

DraftPoint.point

readonly point: number[]

The point on the face.

DraftPoint.uv

readonly uv: number[] | null

The surface parameters the normal was read at; none where there are none.

DraftPoint.normal

readonly normal: number[]

The face's outward unit normal there.

DraftPoint.angle

readonly angle: number

asin(normal . d) in radians, d the unit pull: positive where the face looks partly along the pull.

FaceDraft

class FaceDraft

One face's draft over a body — what Solid.draftAnalysis() returns, one per face. Angles in radians, areas the face's measuring mesh's.

FaceDraft.face

readonly face: number

The face's index.

FaceDraft.min

readonly min: number

The least draft angle over the face's samples (its triangles' centres and corners).

FaceDraft.max

readonly max: number

The greatest.

FaceDraft.area

readonly area: number

The face's whole area; 0 for a sliver narrower than the mesh.

FaceDraft.positive

readonly positive: number

The area whose angle is at least +threshold.

FaceDraft.negative

readonly negative: number

The area whose angle is at most -threshold.

FaceDraft.vertical

readonly vertical: number

The area within threshold of 0 either way: it needs draft.

FaceDraft.undercut

readonly undercut: number

The area whose release ray meets the body.

FaceDraft.kind

readonly kind: DraftKind

"undercut" where any area is undercut, else "positive", "negative" or "vertical" where that band holds the whole face, else "mixed".

SheetRule

class SheetRule

How a sheet-metal part is made — what every sheet verb takes. Lengths in model units, the bend's neutral layer k_factor * thickness past its inner face.

SheetRule.thickness

readonly thickness: number

The sheet's thickness, positive.

SheetRule.bendRadius

readonly bendRadius: number | null

The bends' inner radius; none: the thickness, 0: a hundredth of it.

SheetRule.kFactor

readonly kFactor: number

Where the neutral layer lies, in [0, 1]; 0.44 by default.

SheetRule.relief

readonly relief: SheetRelief

The bend relief cut where a flange is shorter than its edge: none, rectangular (default), round or tear.

SheetRule.reliefWidth

readonly reliefWidth: number

Its width; 0: the thickness.

SheetRule.reliefDepth

readonly reliefDepth: number

Its depth past the bend; 0: half the thickness.

SheetRule.corner

readonly corner: SheetCorner

The corner relief where two bends meet: none, square, round (default) or tear.

SheetRule.cornerSize

readonly cornerSize: number

Its size; 0: twice the thickness.

SheetRule.miterGap

readonly miterGap: number

The gap between two flanges meeting at a corner; 0: a tenth of the thickness.

SheetInfo

class SheetInfo

A body read as sheet metal — what Solid.sheetInfo() returns.

SheetInfo.thickness

readonly thickness: number

The sheet's thickness.

SheetInfo.fixedFace

readonly fixedFace: number

The flat broad face the reading is laid from.

SheetInfo.bends

readonly bends: readonly BendInfo[]

Every bend, as a BendInfo.

BendInfo

class BendInfo

One bend of a sheet body, in model space.

BendInfo.aFace

readonly aFace: number

The bend's face on the fixed face's side.

BendInfo.bFace

readonly bFace: number

Its partner across the thickness.

BendInfo.radius

readonly radius: number

The inner radius.

BendInfo.angle

readonly angle: number

The signed angle in radians: positive up from the fixed side.

BendInfo.axis

readonly axis: [number[], number[]]

The bend's axis: a point and a unit direction.

BendInfo.line

readonly line: [number[], number[]]

The bend's line on the mid-thickness surface: two points.

FlatPattern

class FlatPattern

A sheet body laid flat — what Solid.flatPattern() returns. It holds a handle of the library's, freed as Lifetimes describes.

FlatPattern.body

readonly body: Solid

The flat body: the outline extruded the thickness down from the frame.

FlatPattern.profile

readonly profile: Profile

The flat's outline, a Profile in the frame's plane.

FlatPattern.frame

readonly frame: number[]

The frame the flat lies in: the fixed face's, its top the frame's plane.

FlatPattern.bends

readonly bends: FlatBend[]

Every bend zone as drawn, a FlatBend each.

FlatPattern.foldBends

readonly foldBends: Bend[]

The part's bends as Solid.foldFlat() takes them back, a Bend each.

FlatPattern.dxf()

dxf(units?: keyof typeof PAGE_UNITS, extents?: boolean, table?: boolean, labels?: boolean, notes?: boolean, dimensions?: boolean, folded?: boolean): string

The flat pattern alone as DXF R2000 text for a cutter: the outline on layer OUTLINE, each bend line on BEND_UP (green) or BEND_DOWN (red), centre-lined; extents adds the zones' edges on BEND_EXTENT, table a ruled table of the bends on BEND_TABLE, labels a label on each line (B1 UP 90), and, as Page.addFlatPattern() draws them, notes, dimensions and folded.

FlatPattern.close()

close(): void

Free the handle now. Leaving a with block or the garbage collector does the same.

FlatBend

class FlatBend

One bend zone of a FlatPattern, in the flat's own plane.

FlatBend.centre

readonly centre: [number[], number[]]

The zone's centre line: two points.

FlatBend.start

readonly start: [number[], number[]]

The zone's first edge: two points.

FlatBend.end

readonly end: [number[], number[]]

Its other edge: two points.

FlatBend.angle

readonly angle: number

The signed bend angle in radians.

FlatBend.radius

readonly radius: number

The inner radius.

FlatBend.kFactor

readonly kFactor: number

The neutral layer's K.

FlatBend.up

readonly up: boolean

Whether it bends up, seen from the flat's top.

FlatBend.allowance

readonly allowance: number

The zone's width: |angle| (R + K T).

FlatBend.deduction

readonly deduction: number

The bend deduction: twice the outside setback less the allowance.

Bend

class Bend

A bend to fold — what Solid.foldFlat() takes, and FlatPattern.foldBends gives.

Bend.line

readonly line: [number[], number[]]

The bend's line across the flat: two points.

Bend.angle

readonly angle: number

The signed angle in radians: positive up.

Bend.radius

readonly radius: number

The inner radius.

Bend.kFactor

readonly kFactor: number

The neutral layer's K.

Unrolled

class Unrolled

Faces of a solid laid flat — what Solid.unroll() returns, read at once.

Unrolled.sheet

readonly sheet: Solid

The flat faces as one open Solid in the xy plane.

Unrolled.faces

readonly faces: number[]

Each flat face's source face.

Unrolled.curves

readonly curves: NurbsCurve[][]

Each curve given, as its pieces on the flat (NurbsCurve values).

Unrolled.points

readonly points: (number[] | null)[]

Each point given at its spot on the flat; none where it lies on no face laid flat.

Unrolled.notDevelopable

readonly notDevelopable: number[]

The faces left out because they are not developable.

Unrolled.cuts

readonly cuts: [number, number][]

The shared edges cut, as pairs of source faces.

FromMeshReport

interface FromMeshReport

What Solid.fromMesh() made of a mesh, as plain data.

FromMeshReport.closed

readonly closed: boolean

Whether the result is a closed solid: every edge shared by two triangles, every shell orientable. Otherwise it is an open shell.

FromMeshReport.faces

readonly faces: number

The result's faces.

FromMeshReport.edges

readonly edges: number

The result's edges.

FromMeshReport.vertices

readonly vertices: number

The result's vertices, after welding.

FromMeshReport.holes

readonly holes: number

Holes in the mesh: connected runs of boundary edges.

FromMeshReport.boundaryEdges

readonly boundaryEdges: number

Triangle edges only one triangle has.

FromMeshReport.nonManifoldEdges

readonly nonManifoldEdges: number

Triangle edges three or more triangles share; never repaired.

FromMeshReport.flipped

readonly flipped: number

Triangles whose winding the result reverses: to agree with their neighbours, or with a whole shell turned outward (or inward, for a void).

FromMeshReport.dropped

readonly dropped: number

Triangles dropped as degenerate after welding (a repeated corner, no area).

Squished

class Squished

Faces of a solid squished flat — what Solid.squish() returns, read at once.

Squished.sheet

readonly sheet: Solid

The flat faces as one open Solid in the xy plane.

Squished.faces

readonly faces: number[]

Each flat face's source face.

Squished.distortion

readonly distortion: SquishDistortion[]

Each flat face's distortion, flat over 3D: its area ratio per mesh triangle and its length ratio per mesh edge, each as min, max and mean (weighted by the 3D area or length). A face laid exactly has lengths 1.

Squished.exact

readonly exact: number[]

The source faces laid exactly, as Solid.unroll() lays them.

Squished.curves

readonly curves: NurbsCurve[][]

Each curve given, as its pieces on the flat (NurbsCurve values).

Squished.points

readonly points: (number[] | null)[]

Each point given at its spot on the flat; none where it lies on no face squished.

FacePoint

class FacePoint

Where a point lies against a face — what Solid.facePoint() and Solid.faceInnerPoint() return.

FacePoint.point

readonly point: number[]

The nearest point of the face, inside its trims or on their boundary.

FacePoint.uv

readonly uv: number[]

That point's parameters on the face's surface.

FacePoint.distance

readonly distance: number

From the asked point to it.

FacePoint.where

readonly where: FaceRelation

Inside, on the boundary or off.

EdgePoint

class EdgePoint

The nearest point of an edge's curve — what Solid.edgePoint() and Solid.edgeInnerPoint() return.

EdgePoint.point

readonly point: number[]

The nearest point of the edge's curve over its range.

EdgePoint.t

readonly t: number

The curve's parameter there.

EdgePoint.distance

readonly distance: number

From the asked point to it.

EdgePoint.on

readonly on: boolean

Whether that is within the tolerance.

EdgeConvexity

class EdgeConvexity

How an edge's two faces meet — what Solid.edgeConvexity() returns.

EdgeConvexity.kind

readonly kind: Convexity

Smooth, convex, concave, mixed or open.

EdgeConvexity.angleMin

readonly angleMin: number

The smallest signed turn between the faces' outward normals, in radians (negative concave).

EdgeConvexity.angleMax

readonly angleMax: number

The largest (positive convex).

EdgeConvexity.atMin

readonly atMin: number[]

Where the smallest is.

EdgeConvexity.atMax

readonly atMax: number[]

Where the largest is.

EdgeConvexity.samples

readonly samples: number

The points asked along the edge (0 for an open edge or a closed surface's seam).

Angle

class Angle

The angle between two faces or edges — what Solid.angleTo() returns.

Angle.angle

readonly angle: number

In radians.

Angle.atA

readonly atA: number[]

Where it is read on the first entity: its inner point, or for an axis the axis point nearest it.

Angle.atB

readonly atB: number[]

The same on the second.

Angle.kind

readonly kind: 'planes' | 'lines' | 'line_plane'

What the two were read as: two planes, two lines, or a line and a plane.

MinimumRadius

class MinimumRadius

A face's smallest radius of curvature — what Solid.faceMinimumRadius() returns.

MinimumRadius.radius

readonly radius: number

1 / max(|k1|, |k2|); infinite for a plane.

MinimumRadius.curvature

readonly curvature: number

That principal curvature, signed about the face's outward normal: positive where the face bends away from it (a boss), negative toward it (a bore).

MinimumRadius.at

readonly at: number[]

Where.

MinimumRadius.uv

readonly uv: number[]

Its parameters on the face's surface.

MinimumRadius.direction

readonly direction: number[]

The curvature's unit principal direction.

MinimumRadius.samples

readonly samples: number

The grid stations read inside the trims (0 where a closed form answered).

GearProfile

class GearProfile

A gear's profile and its report — what Profile.gearInvolute(), Profile.gearWheelCycloidal() and Profile.gearPinionCycloidal() return. Frozen.

GearProfile.profile

readonly profile: Profile

The gear's closed outline, a Profile.

GearProfile.pitchRadius

readonly pitchRadius: number

The pitch radius, module teeth / 2.

GearProfile.baseRadius

readonly baseRadius: number | null

The involute's base circle, pitch_radius cos(pressure_angle); null for cycloidal gearing.

GearProfile.tipRadius

readonly tipRadius: number

The largest radius on the profile.

GearProfile.rootRadius

readonly rootRadius: number

The smallest radius on the profile.

GearProfile.thickness

readonly thickness: number

The tooth (leaf) thickness on the pitch circle, as an arc length.

GearProfile.undercut

readonly undercut: boolean

Involute only: whether the gear's cutter would undercut it. The undercut is not drawn: the flank starts on the base or root circle.

AreaProperties

class AreaProperties

A profile's area properties in its own plane — what Profile.areaProperties() returns.

AreaProperties.area

readonly area: number

The region's area: the outer loop less its holes.

AreaProperties.areaError

readonly areaError: number

The integration's bound on it.

AreaProperties.perimeter

readonly perimeter: number

Every loop's length, holes included.

AreaProperties.centroid

readonly centroid: number[]

In the profile's coordinates.

AreaProperties.centroidError

readonly centroidError: number

The bound on it.

AreaProperties.secondMoments

readonly secondMoments: number[]

(Ixx, Iyy, Ixy) about the centroid: Ixx about the axis parallel to x, Ixy the product itself, not negated (unlike a solid's inertia).

AreaProperties.momentsError

readonly momentsError: number

The bound on them.

AreaProperties.principalMoments

readonly principalMoments: number[]

Ascending.

AreaProperties.principalAxes

readonly principalAxes: number[][]

Their two unit axes, the second the first turned a right angle.

AreaProperties.accuracyMet

readonly accuracyMet: boolean

Whether every bound is within the accuracy asked.

Deviation

class Deviation

How far apart two profiles' outlines run, as a named tuple: what Profile.deviation() returns. max_distance is the largest distance from a point of either outline to the other, reached between max_a on the profile asked and max_b on the other; min_distance the smallest (0 where they meet), between min_a and min_b. Points are (x, y); every figure within the tolerance asked of the true one.

SketchPolygon

interface SketchPolygon

A regular polygon added to a sketch, as Sketch.addPolygon() returns it: plain data. centre is the centre point's id, circumcircle and incircle the two construction circles', corners the corner points' ids and sides the side lines' ids (side k runs corner k to corner k + 1).

SketchChamfer

interface SketchChamfer

What Sketch.chamfer() and Sketch.chamferAngle() added, as plain data: line the new line's id, points the ids of its two ends (on a, then on b), corner the old corner point, kept as the virtual sharp, and dimensions the two driving dimensions (along a, then along b or the angle).

SketchPattern

interface SketchPattern

What Sketch.patternRectangular() and Sketch.patternCircular() added, as plain data: copies one list of entity ids per copy (the source excluded, each in the order of the source entities; rectangular copies row by row, the first direction fastest), steps the construction lines of a circular pattern (two, none for a rectangular one) and dimensions the driving dimensions (rectangular: the first step's horizontal and vertical distances, then the second's where it is used; circular: the step angle).

PatchReport

class PatchReport

How well an N-sided patch meets — Solid.patchReport, measured with Solid.continuity() on every neighbour and every spoke.

PatchReport.faces

readonly faces: number

How many faces: one per side of the hole.

PatchReport.boundary

readonly boundary: Continuity

The worst Continuity against the neighbours: the gap over every side, the angle over those met at G1 or G2, the curvature over those met at G2.

PatchReport.internal

readonly internal: Continuity

The worst Continuity across the patch's own spokes.

PatchReport.cornerAngle

readonly cornerAngle: number

The largest angle, in radians, between a boundary's tangent at a corner of the hole and the neighbour before it's tangent plane: what no patch can meet there, 0 where the neighbours meet each other at G1.

Curvature

class Curvature

A curve's bending at a parameter — what NurbsCurve.curvature() returns.

Curvature.kappa

readonly kappa: number

The curvature, 1 / radius; 0 on a straight piece.

Curvature.tangent

readonly tangent: number[]

The unit tangent, along increasing parameter.

Curvature.normal

readonly normal: number[]

The unit normal toward the centre of curvature; zero on a straight piece.

Curvature.binormal

readonly binormal: number[]

tangent x normal; zero on a straight piece.

Curvature.centre

readonly centre: number[] | null

The centre of the osculating circle, or null on a straight piece.

At

interface At

A point at arc length — what Solid.edgePointAtLength() and Profile.pointAtLength() return, and each sample of the divides — beside an estimate of how far its arc length can be trusted.

At.point

readonly point: number[]

The point.

At.tangent

readonly tangent: number[]

The unit tangent there, along the edge or loop; zero where the curve stops.

At.parameter

readonly parameter: number

The curve's own parameter at the point: on an edge, its curve's (a circle's angle, a line's fraction); on a profile, its side's (a line's 0 to 1, an arc's angle about its centre — a clockwise arc's decreasing along it — a spline's parameter).

At.segment

readonly segment: number | null

On a profile, the side the point lies on: its segment's index, or the segment count for the implicit closing side. Empty on an edge (None in Python, CADACLYSM_BLACKSMITH_NONE in C).

At.error

readonly error: number

An estimate of how far the true arc length to the point is from the s asked for: the length's error up to it plus the inversion's own residual.

At.fromPolyline

readonly fromPolyline: boolean

The curve was a sampled polyline: exact for its points and not for whatever they were sampled from.

Classifier

class Classifier

A closed solid meshed once and asked where point after point lies: what Solid.classifier() returns. It keeps its own reference to the body. Calls on one classifier take turns (a lock inside the library), so build one per thread to classify in parallel.

Classifier.contains()

contains(point: Point3): Containment

Where point is: inside, outside, or on within the tolerance of the boundary. A point not finite throws BuildError.

Classifier.close()

close(): void

Free the handle. Leaving a with block or the garbage collector does the same.

Projector

class Projector

A solid meshed once and asked for its nearest point to point after point: what Solid.projector() returns. It keeps the mesh, its search tree and each face's trim judge between queries, and its own reference to the body. Calls on one projector take turns (a lock inside the library), so build one per thread to ask in parallel.

Projector.closestPoint()

closestPoint(p: Point3, maxDistance?: number | null): PointFoot | null

The nearest point of the body's boundary to p, as a PointFoot, or null beyond max_distance — Solid.closestPoint()'s answer, at the projector's tolerance. A point not finite or a negative max_distance throws BuildError.

Projector.curveClosestPoints()

curveClosestPoints(curve: NurbsCurve, maxDistance?: number | null): CurveBodyFoot | null

The nearest points of curve and the body's boundary, as a CurveBodyFoot, or null beyond max_distance — Solid.curveClosestPoints()'s answer, at the projector's tolerance. The projector's lock is held for the whole curve query: other threads asking this projector, for points or curves, wait for it. A negative max_distance or a curve too long for the tolerance throws BuildError.

Projector.close()

close(): void

Free the handle. Leaving a with block or the garbage collector does the same.

PointFoot

class PointFoot

The nearest point of a solid, or of one face, to a query point, as a named tuple: what Solid.closestPoint(), Projector.closestPoint() and Solid.faceClosestPoint() return. point lies on the boundary and distance is from the query point to it. What the point lies on is named as Closest names each side: kind is "face", "edge" or "vertex", index the kernel's id for it, and edge the index Solid.edges() uses for an edge foot — what Solid.edgeLength(), Solid.fillet() and Solid.edgeClosestPoint() take, so read edge, not index, for the public edge number — none for a face, a vertex, and an edge the fillet table does not hold. uv is the face parameter of a foot inside a face, none for an edge or a vertex foot. normal is unit: a face foot's outward normal; an edge or vertex foot's direction from the foot to the query point; on the body (distance 0) the mean of the adjacent faces' outward normals. refined is true when the foot was refined onto the exact geometry: distance is then never below the true minimum and within the tolerance of it; false is the mesh's answer, within [d - 2/3 tolerance, d + tolerance] of the true minimum d.

CurvePair

class CurvePair

The nearest points of two curves, as a named tuple: what NurbsCurve.closestPoints() returns, and a NearestObject's answer for a curve. point_a lies on the curve asked at its parameter t_a, point_b on the other at t_b, distance apart (0 where they cross). Exact.

CurveBodyFoot

class CurveBodyFoot

The nearest points of a curve and a solid's boundary, as a named tuple: what Solid.curveClosestPoints() and Projector.curveClosestPoints() return, and a NearestObject's answer for a solid or a projector. point_on_curve lies on the curve at its parameter t, point_on_body on the boundary, distance apart. crossing is true where the curve passes through the boundary: distance is then exactly 0 and the earliest crossing in t answers. The body's side is the point query's foot at point_on_curve, named as PointFoot names it: kind, index the kernel's id, and edge the index Solid.edges() uses for an edge foot (read edge, not index, for the public edge number; none otherwise), uv none off a face, normal unit. refined false is the mesh's answer, within [d - 2/3 tolerance, d + tolerance] of the true minimum d.

NearestObject

class NearestObject

The nearest of a list of things to a curve, as a named tuple: what NurbsCurve.closestObject() returns. which is the item's index in the list, distance from point_on_curve (at the curve's parameter t) to point_on_item. answer is the item's own answer: a CurveBodyFoot for a solid or a projector, a CurvePair (side a the curve asked) for a curve, a CurveMeshFoot for a TriangleMesh, a CurveSurfaceFoot for a NurbsSurface, none for a point.

TriangleMesh

class TriangleMesh

A triangle mesh and its search tree, built once and immutable: nearest points and nearest points to a curve are answered exactly against it — no tolerance, no refined figure. TriangleMesh(positions, indices) takes the vertices and the triangles (three vertex indices each, any winding), each as a sequence of triples, one flat sequence, or an array; both are copied. A zero-area triangle is accepted and answers as its longest edge. Solid.triangleMesh() gives a solid's own. No triangles, an index past the vertex count, or a coordinate that is not finite throws BuildError. Nothing in it changes after it is built, so calls on one mesh from several threads at once are safe and do not take turns. Close it when done, or let the language's scope do it; see Lifetimes.

TriangleMesh.vertexCount

readonly vertexCount: number

How many vertices the mesh holds.

TriangleMesh.triangleCount

readonly triangleCount: number

How many triangles the mesh holds.

TriangleMesh.bounds

readonly bounds: [number[], number[]]

The box of every vertex, as (min, max).

TriangleMesh.closestPoint()

closestPoint(p: Point3, maxDistance?: number | null): MeshPoint | null

The nearest point of the mesh to p, as a MeshPoint — exact, the lower triangle where several share the point — or null where it lies beyond max_distance (none, NaN or infinite: no limit; a point on the mesh is within 0). A point not finite or a negative max_distance throws BuildError.

TriangleMesh.curveClosestPoints()

curveClosestPoints(curve: NurbsCurve, maxDistance?: number | null): CurveMeshFoot | null

The nearest points of curve and the mesh, as a CurveMeshFoot, or null where the mesh lies farther than max_distance (none, NaN or infinite: no limit). Exact. Where the curve passes through a triangle the answer is a crossing, distance exactly 0, at the earliest crossing in t; among equal distances the lower triangle, then the lower t, answers. A mesh has no inside: a curve within a closed mesh answers its distance to the triangles. A curve that is not valid or a negative max_distance throws BuildError.

TriangleMesh.close()

close(): void

Free this handle now. Leaving a with block or the garbage collector does the same.

MeshPoint

class MeshPoint

The nearest point of a TriangleMesh to a query point: what TriangleMesh.closestPoint() returns. Exact.

MeshPoint.point

readonly point: number[]

The point on the mesh.

MeshPoint.distance

readonly distance: number

The distance from the query point to point.

MeshPoint.triangle

readonly triangle: number

The lowest-numbered triangle holding the point: on an edge or a vertex several triangles share, the lower triangle answers.

MeshPoint.barycentric

readonly barycentric: number[]

The point's three weights on triangle's corners, in index order, summing to 1.

MeshPoint.kind

readonly kind: 'face' | 'edge' | 'vertex'

What the point lies on: "face" (inside triangle), "edge" or "vertex".

MeshPoint.vertices

readonly vertices: number[]

What kind names: an edge's two vertex indices ascending, a vertex's one, none for a face.

CurveMeshFoot

class CurveMeshFoot

The nearest points of a curve and a TriangleMesh: what TriangleMesh.curveClosestPoints() returns, and a NearestObject's answer for a mesh. Exact. The mesh's side is named as MeshPoint names it, flat.

CurveMeshFoot.distance

readonly distance: number

The distance from point_on_curve to point_on_mesh.

CurveMeshFoot.t

readonly t: number

The curve's parameter at point_on_curve.

CurveMeshFoot.pointOnCurve

readonly pointOnCurve: number[]

The point on the curve.

CurveMeshFoot.pointOnMesh

readonly pointOnMesh: number[]

The point on the mesh.

CurveMeshFoot.triangle

readonly triangle: number

The lowest-numbered triangle holding point_on_mesh.

CurveMeshFoot.barycentric

readonly barycentric: number[]

point_on_mesh's three weights on triangle's corners, in index order, summing to 1.

CurveMeshFoot.kind

readonly kind: 'face' | 'edge' | 'vertex'

What point_on_mesh lies on: "face", "edge" or "vertex".

CurveMeshFoot.vertices

readonly vertices: number[]

What kind names: an edge's two vertex indices ascending, a vertex's one, none for a face.

CurveMeshFoot.crossing

readonly crossing: boolean

true where the curve passes through a triangle: distance is then exactly 0, at the earliest crossing in t. A curve that touches without passing through is distance 0 and false.

NurbsSurface

class NurbsSurface

An untrimmed NURBS surface, immutable: nearest points and nearest points to a curve are answered exactly against it — no tolerance, no refined figure. NurbsSurface(points, counts, degree_u, degree_v, weights, knots_u, knots_v) takes the control net of counts = (n_u, n_v) points, rows along u (point i * n_v + j is row i, column j), as a sequence of triples, one flat sequence, or an array; degrees 1 to 7 (3 by default); weights one per point, positive and finite, or none for a plain B-spline; and the full clamped knot vectors (n + degree + 1 values each, non-decreasing, the first and the last degree + 1 equal), or none for clamped and uniform over [0, 1]. Everything is copied. Solid.faceSurface() gives a face's own. A degree out of range, too few points for a degree, a point that is not finite, a bad weight, or knots of the wrong count, decreasing or not clamped throws BuildError. Its Bézier patches are cut once, at the first query, and kept; nothing else in it changes, so calls on one surface from several threads at once are safe. Close it when done, or let the language's scope do it; see Lifetimes.

NurbsSurface.degreeU

readonly degreeU: number

The degree along u.

NurbsSurface.degreeV

readonly degreeV: number

The degree along v.

NurbsSurface.counts

readonly counts: [number, number]

The control net's size, (n_u, n_v).

NurbsSurface.domain

readonly domain: [[number, number], [number, number]]

The parameter domain, ((u0, u1), (v0, v1)).

NurbsSurface.pointAt()

pointAt(u: number, v: number): number[]

The point at (u, v). A parameter outside the domain or not finite throws BuildError.

NurbsSurface.normalAt()

normalAt(u: number, v: number): number[]

The unit normal at (u, v) (dS/du x dS/dv, normalised). A parameter outside the domain or not finite, or a place where the partials are parallel (a pole — exactly where a SurfacePoint's normal is zero), throws BuildError.

NurbsSurface.toSheet()

toSheet(): Solid

The whole surface as an open one-face sheet Solid. The sheet's face is this surface reparametrised over [0, 1] x [0, 1]: its Solid.faceSurface() has that domain, not this one's. A surface of no size throws BuildError.

NurbsSurface.closestPoint()

closestPoint(p: Point3, maxDistance?: number | null): SurfacePoint | null

The nearest point of the surface to p, as a SurfacePoint — exact, the lower u, then the lower v, among equal distances — or null where it lies beyond max_distance (none, NaN or infinite: no limit; a point on the surface is within 0). A point not finite or a negative max_distance throws BuildError.

NurbsSurface.curveClosestPoints()

curveClosestPoints(curve: NurbsCurve, maxDistance?: number | null): CurveSurfaceFoot | null

The nearest points of curve and the surface, as a CurveSurfaceFoot, or null where the surface lies farther than max_distance (none, NaN or infinite: no limit). Exact. Where the curve passes through the surface the answer is a crossing, distance exactly 0, at the earliest crossing in t; among equal distances the lower u, then v, then t, answers. A curve that is not valid or a negative max_distance throws BuildError.

NurbsSurface.controlPoints()

controlPoints(): number[][]

The control net, n_u * n_v points, row i (along u) point j at i * n_v + j — the order the constructor takes them in.

NurbsSurface.weights()

weights(): number[]

The weights, one per control point in the net's order (all 1 for a plain B-spline).

NurbsSurface.knots()

knots(direction: SurfaceDirection): number[]

The full knot vector along direction ("u" or "v"): n + degree + 1 values. Another direction throws BuildError.

NurbsSurface.elevate()

elevate(direction: SurfaceDirection, by?: number): NurbsSurface

The same surface, exactly, raised by degrees (1 by default) along direction (to at most 12; Rhino's IncreaseDegreeU/V).

NurbsSurface.insertKnot()

insertKnot(direction: SurfaceDirection, t: number, times?: number): NurbsSurface

The same surface, exactly, with the knot t (strictly inside the domain) inserted times times along direction: more control points, every point kept. A t outside the domain, a times of 0, or a multiplicity past the degree, throws BuildError.

NurbsSurface.refineKnots()

refineKnots(direction: SurfaceDirection, knots: Iterable<number>): NurbsSurface

The same surface, exactly, with every knot of knots (non-decreasing, each strictly inside the domain, no multiplicity past the degree) inserted along direction.

NurbsSurface.removeKnot()

removeKnot(direction: SurfaceDirection, t: number, times?: number, tolerance?: number | null): { surface: NurbsSurface; removed: number }

Up to times copies of the inner knot t along direction removed, each only while every row of the net stays within tolerance (an absolute length; none, 0 or NaN: the net's effective tolerance) of itself: the surface and how many went — 0, and an unchanged copy, where none could. A t that is not an inner knot, or a negative tolerance, throws BuildError.

Answers { curve, removed } on a curve and { surface, removed } on a surface.

NurbsSurface.extend()

extend(side: SurfaceSide, length: number): NurbsSurface

The surface continued length past side ("u_start", "u_end", "v_start" or "v_end"; Rhino's Surface.Extend) along its own end polynomials — curvature-continuous, every old (u, v) keeping its point, the domain grown on that side. Another side, or a length that is not positive and finite, throws BuildError.

NurbsSurface.offset()

offset(distance: number, tolerance?: number | null): NurbsSurface

This surface moved distance along its normal, as Rhino's Surface.Offset, over the same domain: its point at (u, v) within tolerance (none: the effective tolerance) of this one's point there moved distance along the normal. A plane offsets exactly (fit_error 0); any other surface is refitted, fit_error bounding the distance from the exact offset. The result holds the offset's values, not a reference back to this surface. A distance that is not finite, a surface with no normal somewhere, or an offset that folds over (a curvature radius used up) throws BuildError.

NurbsSurface.fitError

readonly fitError: number | null

On a surface from NurbsSurface.offset(), the largest distance found between it and the exact offset; null on any other.

NurbsSurface.secondDerivatives()

secondDerivatives(u: number, v: number): [number[], number[], number[], number[], number[], number[]]

The point and its partial derivatives to second order at (u, v): (S, Su, Sv, Suu, Suv, Svv) (Rhino's Surface.Evaluate to order 2). A parameter outside the domain or not finite throws BuildError.

NurbsSurface.curvature()

curvature(u: number, v: number): SurfaceCurvature

The principal, Gaussian and mean curvatures and the principal directions at (u, v), as a SurfaceCurvature (Rhino's Surface.CurvatureAt). A parameter outside the domain or not finite, or a pole (no normal), throws BuildError.

NurbsSurface.hermite()

static hermite(u: Iterable<number>, v: Iterable<number>, points: Iterable<Point3> | Iterable<number> | Float64Array, du: Iterable<Point3> | Iterable<number> | Float64Array, dv: Iterable<Point3> | Iterable<number> | Float64Array, twists: Iterable<Point3> | Iterable<number> | Float64Array): NurbsSurface

The bicubic Hermite surface through a grid (Rhino's HermiteSurface): u (at least 2) and v (at least 2) the grid's parameters, strictly rising; points, du, dv and twists a point for each node, node (i, j) at i * len(v) + j — its point, dS/du, dS/dv and d2S/dudv. Cubic both ways with a double knot at every inner grid parameter (C1 across), 2 len(u) x 2 len(v) control points, through every point with the given derivatives. A grid under 2 x 2, parameters not strictly rising, lists of the wrong length or numbers not finite throws BuildError.

NurbsSurface.close()

close(): void

Free this handle now. Leaving a with block or the garbage collector does the same.

SurfacePoint

class SurfacePoint

The nearest point of a NurbsSurface to a query point: what NurbsSurface.closestPoint() returns. Exact.

SurfacePoint.point

readonly point: number[]

The point on the surface.

SurfacePoint.distance

readonly distance: number

The distance from the query point to point.

SurfacePoint.u

readonly u: number

The surface's u parameter at point: among equal distances the lower u, then the lower v, answers.

SurfacePoint.v

readonly v: number

The surface's v parameter at point.

SurfacePoint.normal

readonly normal: number[]

The surface's unit normal at (u, v) (dS/du x dS/dv), or the zero vector where it has none: a pole, where the partials are parallel.

SurfacePoint.boundary

readonly boundary: boolean

true where point lies on an edge of the patch (u or v at an end of the domain) and the way to the query point is not along the normal: the edge, not the surface's interior, is what is nearest.

SurfaceCurvature

class SurfaceCurvature

How a NurbsSurface bends at a point: what NurbsSurface.curvature() returns, from its first and second fundamental forms. Every curvature is signed about normal: positive where the surface bends toward it. A cylinder of radius r reads one curvature 0 and the other -1/r or 1/r, by which way the normal points.

SurfaceCurvature.k1

readonly k1: number

The larger principal curvature (k1 >= k2).

SurfaceCurvature.k2

readonly k2: number

The smaller principal curvature.

SurfaceCurvature.dir1

readonly dir1: number[]

The unit tangent direction of k1; at an umbilic (k1 == k2) any orthonormal pair with dir2.

SurfaceCurvature.dir2

readonly dir2: number[]

The unit tangent direction of k2.

SurfaceCurvature.gaussian

readonly gaussian: number

The Gaussian curvature, k1 * k2.

SurfaceCurvature.mean

readonly mean: number

The mean curvature, (k1 + k2) / 2.

SurfaceCurvature.normal

readonly normal: number[]

The unit normal the signs are taken about, dS/du x dS/dv normalised.

CurveSurfaceFoot

class CurveSurfaceFoot

The nearest points of a curve and a NurbsSurface: what NurbsSurface.curveClosestPoints() returns, and a NearestObject's answer for a surface. Exact. The surface's side is named as SurfacePoint names it, flat.

CurveSurfaceFoot.distance

readonly distance: number

The distance from point_on_curve to point_on_surface.

CurveSurfaceFoot.t

readonly t: number

The curve's parameter at point_on_curve.

CurveSurfaceFoot.pointOnCurve

readonly pointOnCurve: number[]

The point on the curve.

CurveSurfaceFoot.pointOnSurface

readonly pointOnSurface: number[]

The point on the surface.

CurveSurfaceFoot.u

readonly u: number

The surface's u parameter at point_on_surface.

CurveSurfaceFoot.v

readonly v: number

The surface's v parameter at point_on_surface.

CurveSurfaceFoot.normal

readonly normal: number[]

The surface's unit normal at (u, v), or the zero vector at a pole.

CurveSurfaceFoot.boundary

readonly boundary: boolean

true where point_on_surface lies on an edge of the patch and the way to the curve is not along the normal.

CurveSurfaceFoot.crossing

readonly crossing: boolean

true where the curve passes through the surface: distance is then exactly 0, at the earliest meeting in t. A curve that touches without passing through is distance 0 and false.

Closest

interface Closest

The closest points between two solids' boundaries: what Solid.closest() returns, side a the solid asked and side b the other. Each side names the feature its point lies on.

Closest.distance

readonly distance: number

The distance between the two points.

Closest.onA

readonly onA: number[]

The point on side a.

Closest.onB

readonly onB: number[]

The point on side b.

Closest.kindA

readonly kindA: 'face' | 'edge' | 'vertex'

What side a's point lies on: "face", "edge" or "vertex".

Closest.indexA

readonly indexA: number

The kernel's id for side a's feature.

Closest.edgeA

readonly edgeA: number | null

Side a's edge as the index Solid.edges() uses; none for a face or a vertex, and for an edge the fillet table does not hold (a trim with no exact curve).

Closest.kindB

readonly kindB: 'face' | 'edge' | 'vertex'

What side b's point lies on: "face", "edge" or "vertex".

Closest.indexB

readonly indexB: number

The kernel's id for side b's feature.

Closest.edgeB

readonly edgeB: number | null

Side b's edge, as edge_a.

Closest.refined

readonly refined: boolean

A refined answer is never below the true minimum and within the tolerance of it wherever the face pair holding the minimum refines to its own nearest pair. Where a nearer candidate did not converge, or left its trims and its boundary search found nothing, the mesh's answer comes back instead with refined false: within [d - 2/3 tolerance, d + tolerance] of the true minimum d.

Beziers

What Solid.silhouetteBeziers() returns: curves as cubic Béziers in double precision, four control points and four weights a curve. Unlike the reader's Beziers, the arrays are the wrapper's own — the kernel hands its buffer over and the wrapper releases it before the call returns — so there is nothing to outlive; they are read-only views over one copy kept alive by the arrays themselves.

Solid.silhouetteBeziers returns a plain { points, weights, count } object.

Beziers.points

Four control points a curve, three doubles each: shape (count, 4, 3).

Solid.silhouetteBeziers returns a plain { points, weights, count } object.

Beziers.weights

A weight per control point, as doubles: shape (count, 4). All ones for a polynomial curve, and the weights that make a circular arc exact for a rational one.

Solid.silhouetteBeziers returns a plain { points, weights, count } object.

Beziers.count

How many curves. A Beziers is falsey when this is 0, the empty answer.

Solid.silhouetteBeziers returns a plain { points, weights, count } object.

Beziers.copy

The same arrays, writable and contiguous, in memory of your own.

Solid.silhouetteBeziers returns a plain { points, weights, count } object.

Hlr

class Hlr

A hidden-line view of solids or meshes: what blacksmith.hlr() and blacksmith.hlrMesh() return. Its lines, each seen or hidden, what the removal did, and the tolerance it worked at; placed on a drawing with Page.addView(). Immutable. It holds a handle of the library's, freed as Lifetimes describes.

Hlr.lines

readonly lines: readonly HlrLine[]

Every line, seen and hidden, as HlrLines.

Hlr.visible()

visible(): HlrLine[]

The lines seen.

Hlr.hidden()

hidden(): HlrLine[]

The lines hidden: a drawing's dashed ones.

Hlr.report

readonly report: HlrReport

What the removal did, as counts and lengths: candidates (curves considered), segments (the view-plane Béziers they projected to), crossings, pieces (pieces classified), degenerate (pieces shorter than the tolerance on the view plane, an edge seen end-on: not drawn), rays, mesh_hits, rejected, grazes, unsettled (pieces the evidence could not settle, decided by two more samples), mesh_only (hits taken on the mesh's word, a face with no readable trims), fallback_edges (edges with no exact curve, drawn from their polyline), failed_solids (solids that could not be placed or meshed, and so neither draw nor hide), candidate_length and degenerate_length (lengths in space). A dictionary in Python; the typed wrappers' report has the same fields in their own spelling.

Hlr.tolerance

readonly tolerance: number

The tolerance the view was worked at, in model units: the one asked for, or the effective tolerance it resolved to.

HlrLine

class HlrLine

One line of an Hlr, as a named tuple: kind ("sharp", "smooth", "outline", "iso" or "boundary"), visible, solid the index of the solid (or mesh) it belongs to in the list given, and source, what it is a span of — ("edge", id), ("face", index) for a silhouette or an isocurve, or ("mesh_edge", a, b), a mesh edge's two vertices. Its curve is beziers2d, rational cubic Béziers on the view plane (z 0), and beziers3d, the same spans in space, Bézier for Bézier, each a Beziers; length2d is its length on the view plane and length3d in space, in model units.

Page

class Page

A flat drawing page: hidden-line views, profiles, hatches and text placed on it, written as SVG or as DXF R2000 (AC1015) that CAD programs open. Page(units) makes an empty one in millimetres (the default), centimetres, metres, inches, feet or no unit, written into the DXF's header. Layers are made on first use: a view's own — visible (seen sharp and boundary edges, 0.5 mm), outline (seen silhouettes, 0.5 mm), smooth (0.25 mm, grey), iso (0.18 mm, grey) and hidden (every hidden line, dashed, 0.25 mm) — and any other name continuous, colour 7. Mutable: each add_* changes the page. It holds a handle of the library's, freed as Lifetimes describes.

Page.addView()

addView(view: Hlr, at?: [number, number], scale?: number): this

A view's lines (Hlr) on the page, a view point p landing at at + scale * p: each line as the entities that draw it best — lines, arcs, circles, elliptical arcs, splines — on the view's layers.

Page.addProfile()

addProfile(profile: Profile, at?: [number, number], layer?: string | null): this

A Profile's outline and holes on layer (null: 0), moved by at.

Page.addHatch()

addHatch(profile: Profile, pattern?: string, angle?: number, scale?: number, at?: [number, number], layer?: string | null): this

A Profile hatched, its holes left out, on layer (null: hatch), moved by at: pattern SOLID, ANSI31, ANSI37 or ANSI32 (also STEEL), any case, turned angle radians, its spacing times scale. Another pattern name throws BuildError.

Page.addText()

addText(text: string, at: [number, number], height: number, angle?: number, halign?: 'left' | 'center' | 'right', valign?: 'baseline' | 'bottom' | 'middle' | 'top', layer?: string | null): this

One line of text on layer (null: text) at at, height tall, turned angle radians; halign left (default), center or right, valign baseline (default), bottom, middle or top.

Page.addFlatPattern()

addFlatPattern(flat: FlatPattern, at?: [number, number], extents?: boolean, table?: boolean, labels?: boolean, notes?: boolean, dimensions?: boolean, folded?: boolean): this

A FlatPattern at at, 1:1: the outline on layer OUTLINE, each bend line on BEND_UP (green) or BEND_DOWN (red); extents adds the zones' edges on BEND_EXTENT, table a ruled table of the bends under the outline on BEND_TABLE (number, direction, angle, inner radius, K-factor, allowance, deduction), labels a label on each bend line, notes a bend note under each (UP 90° R1) on BEND_NOTE, dimensions the flat's overall width and height on DIMENSION (lines, arrowheads and text), and folded the folded part's front view right of the flat, at its scale, on FOLDED and FOLDED_HIDDEN.

Page.svg()

svg(): string

The page as an SVG document, one group per layer.

Page.dxf()

dxf(): string

The page as DXF R2000 (AC1015) text: the same text for the same page. blacksmith.dxfProfiles() reads its closed loops back.

Box

class Box

An axis-aligned box: lo and hi, three numbers each. The broad phase's own shape (Solid.boundsBox(), Collider's own boxes): cheap to move and to test against another before anything is meshed.

Box.lo

lo: [number, number, number]

The box's low corner.

Box.hi

hi: [number, number, number]

The box's high corner.

Box.move()

move(frame: FrameLike): Box

This box moved by frame (rigid), boxed again on the world axes — not this box's corners individually moved, which would not in general be a box at all: the *bounding* box of the moved corners. A frame not twelve finite numbers or not rigid throws BuildError.

Box.overlaps()

overlaps(other: Box): boolean

Whether this box and other share a point (touching counts).

Region

interface Region

One region of space a solid's faces bound, as Solid.regions() returns it: a value, equal by value, that does not change. Solid.regionSolid() takes a finite one as a solid of its own.

Region.index

readonly index: number

Its index in Solid.regions(): 0 for the infinite region.

Region.finite

readonly finite: boolean

false for region 0, the one reaching to infinity; true for every other.

Region.box

readonly box: Box

The Box round the faces bounding it.

Region.sides

readonly sides: readonly FaceSide[]

Every face side bounding it, as FaceSide values, ascending by face and then sense (-1 first).

Region.shells

readonly shells: number

How many connected boundaries it has: 1, plus one per void inside it.

FaceSide

interface FaceSide

One side of one face, as a Region lists its sides: a value, equal by value.

FaceSide.face

readonly face: number

The face's index in the solid.

FaceSide.sense

readonly sense: 1 | -1

+1 for the side the face's normal points to, -1 for the other. A solid's inside is behind its faces, at -1.

ColliderStats

interface ColliderStats

Counts of one Collider.check() call, as Collider.stats returns them (all zero before the first call): the candidate pairs considered, how many of them the world boxes and the oriented boxes cleared, how many the share left to another call, how the rest were answered (cached, closed_form, meshed), and how many were refused. confirmed is the subset of meshed that were thin mesh-path overlaps sent to Solid.common() itself for a final answer.

ColliderStats.considered

considered: number

The candidate pairs looked at: every pair of parts in different groups, less any in allowed or skipped_share.

ColliderStats.worldBoxes

worldBoxes: number

Of those, how many two world boxes (Box.overlaps()) cleared at once — decided apart with no oriented test.

ColliderStats.orientedBoxes

orientedBoxes: number

Of the rest, how many blacksmith.boxesApart() cleared — decided apart on the parts' own oriented boxes.

ColliderStats.skippedShare

skippedShare: number

Pairs this call's share left to another call, not decided here at all.

ColliderStats.cached

cached: number

Pairs answered from an earlier pose's cache rather than worked afresh.

ColliderStats.closedForm

closedForm: number

Pairs decided by an exact formula (both parts a shape the kernel has one for), no mesh built.

ColliderStats.meshed

meshed: number

Pairs that needed a mesh-against-mesh test to decide.

ColliderStats.refused

refused: number

Pairs that could not be decided at all — each a CollisionHit with kind "refused".

ColliderStats.confirmed

confirmed: number

Of meshed, how many thin mesh-path overlaps were sent on to Solid.common() itself for a final answer.

CollisionHit

class CollisionHit

One pair Collider.check() found overlapping (kind "overlap"), or could not decide (kind "refused", text says why), as plain data. positions/normals are world xyz triples, three per triangle (unwelded); indices indexes them — all empty for a refused pair. depth is the thinnest side of the overlap's world box, 0 for a refused pair.

CollisionHit.solid() rebuilds the exact overlap now, from the frames Collider.check() found it at; this keeps the check call's own answer alive behind every hit of it until the last one is let go, freeing it only then.

CollisionHit.a

a: number

The first part's index, as given to Collider.

CollisionHit.b

b: number

The second part's index.

CollisionHit.kind

kind: 'overlap' | 'refused'

"overlap" or "refused".

CollisionHit.overlap

The same answer as kind, as a plain bool.

Read kind === 'overlap' instead.

CollisionHit.depth

depth: number

The thinnest side of the overlap's world box; 0 for a refused pair.

CollisionHit.text

text: string

Why a refused pair could not be decided; empty for an overlap.

CollisionHit.positions

positions: Float64Array

The overlap solid's mesh positions, world xyz triples, three per triangle (unwelded); empty for a refused pair.

CollisionHit.normals

normals: Float64Array

The overlap solid's mesh normals, matching positions; empty for a refused pair.

CollisionHit.indices

indices: Uint32Array

Indices into positions/normals; empty for a refused pair.

CollisionHit.solid()

solid(): Solid

The exact overlap of this pair at the frames Collider.check() found it at, as a new Solid. throws BuildError for a refused pair (kind "refused") or a check answer already closed some other way.

Clash

class Clash

One pair blacksmith.clash() or Collider.clash() found, as plain data. kind is "penetrating" (the volumes overlap), "touching" (the boundaries are within the tolerance of each other), "too_close" (apart by more than the tolerance but less than the clearance) or "refused" (the pair could not be decided; text says why). The feature fields are Closest's, flat: what each point lies on, by the kernel's id and the Solid.edges() index; for a penetrating or refused pair there is no closest point, so kind_a and kind_b are "none" and index_* and edge_* are none.

Clash.solid() and Clash.intersect() are built on demand, from the placement the pair was found at; the answer of the call that found the rows is kept alive behind every row of it until the last one is let go, freeing it only then.

Clash.a

a: number

The first part's index: in the one set, or in the collider (then a < b); in clash with two sets, an index into parts.

Clash.b

b: number

The second part's index; with two sets, an index into others.

Clash.kind

kind: ClashKind

"penetrating", "touching", "too_close" or "refused".

Clash.distance

distance: number

The gap between the two boundaries; 0 for a penetrating or refused pair.

Clash.onA

onA: number[]

A world point on part a: the closest of the pair; for a penetrating pair the centre of the overlap's world box; the origin for a refused one.

Clash.onB

onB: number[]

The matching world point on part b, as on_a.

Clash.kindA

kindA: 'face' | 'edge' | 'vertex' | 'none'

What on_a lies on, as Closest.kindA: "face", "edge" or "vertex"; "none" for a penetrating or refused pair.

Clash.indexA

indexA: number | null

The kernel's id for part a's feature; none for a penetrating or refused pair.

Clash.edgeA

edgeA: number | null

Part a's edge as the index Solid.edges() uses, as Closest.edgeA; none for a face, a vertex, an edge the fillet table does not hold, and a penetrating or refused pair.

Clash.kindB

kindB: 'face' | 'edge' | 'vertex' | 'none'

What on_b lies on, as kind_a.

Clash.indexB

indexB: number | null

The kernel's id for part b's feature, as index_a.

Clash.edgeB

edgeB: number | null

Part b's edge, as edge_a.

Clash.refined

refined: boolean

Whether the distance was measured on the exact surfaces, as Closest.refined; false for a penetrating or refused pair.

Clash.depth

depth: number

The thinnest side of a penetrating pair's overlap box; 0 for any other.

Clash.text

text: string

Why a refused pair could not be decided; empty otherwise.

Clash.solid()

solid(): Solid

The exact shared volume of this penetrating pair, at the placement it was found at, as a new Solid. throws BuildError for a pair that is not penetrating.

Clash.intersect()

intersect(): Intersection

Where this pair's two parts cross or coincide at the placement it was found at, as Solid.intersect() reports it: a touching pair's shared face is an overlap region. throws BuildError for a refused pair.

SweptClash

class SweptClash

One pair blacksmith.sweptClash() or Collider.sweptClash() found to clash somewhere on the path, as plain data: when it first came within the clearance, the Clash there, and every time range it stays in clash. Times are in pose units: pose k is at time k, and a time between two poses is the fraction of the way from one to the next.

SweptClash.a

a: number

The first part's index: in the one set, or in the collider (then a < b); in swept_clash with two sets, an index into parts.

SweptClash.b

b: number

The second part's index; with two sets, an index into others.

SweptClash.firstTime

firstTime: number

The first time the pair came within the clearance, found to within the tolerance over the pair's speed; for a refused pair, the time it was refused at.

SweptClash.first

first: Clash

The Clash at first_time — its kind, distance, points, features and depth — at the frames the motion places the two parts at that time, so its Clash.solid() and Clash.intersect() rebuild the contact there. A pair refused on the way (a part that will not mesh closed, or more than max_steps tests) has a "refused" first, whose text says why.

SweptClash.intervals

intervals: [number, number][]

The time ranges the pair stays in clash, as (start, end) pairs, ascending and disjoint; the first starts at first_time. An end is found to within resolution while the parts share volume, and two ranges closer than that may be one; a range across a pose is one range. Empty for a refused pair.

Collider

class Collider

Parts meshed once, asked pose after pose which of them interfere: solids at rest, meshed at tolerance (0.05 by default); groups one group index per solid (null: each solid its own group — Collider.check() then takes one frame per solid, and refuses a groups of any other length); allowed pairs of part indices never tested (designed contacts, by part index, flat: (a0, b0, a1, b1, ...)). Close it when done, or let the language's scope do it; see Lifetimes.

Collider.groupCount

readonly groupCount: number

How many groups this collider has — the highest group index past the constructor, plus one.

Collider.stats

readonly stats: ColliderStats

Counts of the last Collider.check() call, as a ColliderStats (all zero before the first one).

Collider.check()

check(frames: FrameLike[], share?: [number, number] | null): CollisionHit[]

The pairs that interfere, or could not be decided, with each group placed at its matching frame in frames (one Frame, or twelve numbers, per group, in group order), as CollisionHit values. share: null, every pair past the box filters is decided now; (k, n), only those whose index is k modulo n — the shares of one pose are disjoint and cover it, so a caller splits one pose's work across n workers and puts the answers back together. Overlap is all check answers; the parts that touch or lie within a clearance of each other are Collider.clash()'s. frames not the collider's own Collider.groupCount, a frame that is not twelve finite numbers or not rigid, or a share with k >= n, throws BuildError.

Collider.clash()

clash(frames: FrameLike[], clearance?: number, share?: [number, number] | null): Clash[]

Every pair of parts that penetrates, touches or lies within clearance of the other, as Clash rows in pair order, with each group placed at its matching frame in frames (as Collider.check(), which answers overlap alone). The four kinds, their order of decision and the clearance are blacksmith.clash()'s; the tolerance is the one the collider was built with. share as for check: the rows of the shares of one pose are disjoint and cover it. A pair's distance is measured on a closest mesh of each part, built at a third of the tolerance the first time a pair needs it and kept for the collider's lifetime, so a later pose pays only the measuring. clearance negative or not finite, the wrong number of frames, a frame that is not twelve finite numbers or not rigid, or a share with k >= n throws BuildError. The motion between poses is Collider.sweptClash()'s question.

Collider.sweptClash()

sweptClash(poses: Iterable<Iterable<FrameLike>>, clearance?: number, resolution?: number, maxSteps?: number, share?: [number, number] | null): SweptClash[]

Every pair of parts that penetrates, touches or comes within clearance of the other anywhere on the path through poses — not only at the poses — as SweptClash rows in pair order, each with the first time it does and the time ranges it stays in clash. poses is two or more poses, each the frames Collider.clash() takes (one per group); time runs in pose units, pose k at time k.

Between two poses each group moves rigidly about a pivot, the centre of its rest box: the pivot on the straight line between its two places, the rotation turning at a steady rate the shorter way round, so at each pose a group is exactly where that pose puts it. A part swinging about a far hinge cuts the chord between two poses: add poses where the true path matters.

The answer is not sampled. Each pair is stepped by conservative advancement: the gap is measured, and the next step is as long as the gap allows at the fastest the two parts can close on each other, so the guarantee is that no moment where the true gap is below clearance less the tolerance (for clearance 0: no penetration deeper than the tolerance) falls between two steps, and the first time is found to within the tolerance over that speed. While the parts share volume, how deep they are bounds how long they must stay so. resolution (in (0, 1], a fraction of a segment, 1e-3 by default) is how closely an interval's end is found; max_steps (100,000 by default) the tests one pair may take over the whole path — a pair that needs more, typically a thin part grazing another at speed, is a "refused" row whose first.text says so; raise it or add poses.

Pairs come from the swept boxes first: each part's box over a segment, both poses' boxes joined and grown by how far its rotation can carry a point off the chord. A pair whose swept boxes never come within the clearance is not stepped at all. share as for Collider.check(), over the pairs whose swept boxes meet: the shares of one call are disjoint and cover it. The pose caches Collider.check() and Collider.clash() keep are neither read nor filled (each time on the path is a new placement); the parts' meshes are made as those calls make them, and kept.

Fewer than two poses, a pose with the wrong number of frames, a frame that is not twelve finite numbers or not rigid, clearance negative or not finite, resolution outside (0, 1], max_steps 0, or a share with k >= n throws BuildError.

Collider.close()

close(): void

Free this handle now. The garbage collector, or the language's scope, does it otherwise.

ThicknessGauge

class ThicknessGauge

Wall thickness over solids, measured against each other: each solid meshed once at tolerance — absolute, in model units (0.01 by default) — and indexed, then asked reading after reading. A reading's body is the solid's index in solids. The gauge keeps its own reference to the bodies, so it answers on after they are closed. Close it when done, or let the language's scope do it; see Lifetimes. A tolerance not positive and finite throws BuildError.

The rule reads the measuring mesh (ThicknessGauge.mesh()). From a point P the thickness is the distance to the nearest triangle that opposes P's own face (their normals more than 89 degrees apart) with P on or behind its plane — not a ray cast along the normal, so a box's corner reads the plate's thickness, not the diagonal. A triangle with a vertex exactly at P is skipped; where one of those meets P's own face at an interior angle under sharp_angle radians, P is a knife edge and reads 0. A point with no such triangle, or one further than maximum, gives no reading: readings are dropped, not clamped. Each reading then carries the opposite point refined onto its exact face (Thickness.exactThickness), and the diameter of the largest ball tangent at P that holds none of the surfaces (Thickness.sphere). The two differ on a tilted wall: the rule reads the perpendicular foot, so a right wedge reads 3.54 at a point where the ball that fits there is 4.14 across; the ball is the wall's inscribed thickness.

ThicknessGauge.tolerance

readonly tolerance: number

The tolerance the gauge meshed its bodies at.

ThicknessGauge.bodyCount

readonly bodyCount: number

How many bodies the gauge measures: the length of solids it was built from.

ThicknessGauge.thickness()

thickness(maximum: number, sharpAngle?: number): Thickness[]

One Thickness per measuring-mesh vertex that reads within maximum, by body then vertex; sharp_angle (radians, 0 by default) sets which vertices are knife edges. maximum not positive and finite, or sharp_angle negative or not finite, throws BuildError.

ThicknessGauge.thicknessAt()

thicknessAt(body: number, face: number, point: Point3, maximum: number, sharpAngle?: number): Thickness | null

The reading at point's foot on face face of body body, its vertex null: the foot read against the exact tangent plane there, so a wall is measured between the mesh's vertices too. null where the foot lies off the face, or the wall there is thicker than maximum. A body or a face past the end, a point not finite, or a bad maximum or sharp_angle throws BuildError.

ThicknessGauge.thicknessAtFace()

thicknessAtFace(body: number, face: number, options: ThicknessAtFaceOptions): FaceThickness | null

One figure for face face of body body, as a FaceThickness, the other bodies measured with it: at at's foot on the face, or with no at over the face's vertices. maximum has no default. null where nothing on the face reads within maximum, or at's foot lies off the face. A body or a face past the end, an at not finite, or maximum not positive and finite throws BuildError.

thicknessAtFace(body, face, { at, maximum }): one options object, since JavaScript has no required argument after an optional one. at defaults to null; a missing maximum throws BuildError (thickness_gauge_face: the maximum must be positive and finite).

ThicknessGauge.mesh()

mesh(body: number): ThicknessMesh

Body body's measuring mesh, as a ThicknessMesh: the mesh a reading's vertex indexes, copied out, so it outlives the gauge. A body past the end throws BuildError.

ThicknessGauge.close()

close(): void

Free this handle now. Leaving a with block or the garbage collector does the same.

Thickness

class Thickness

One wall-thickness reading on a solid, as plain data: what ThicknessGauge.thickness(), ThicknessGauge.thicknessAt() and blacksmith.thickness() return. Points are three numbers.

Thickness.body

body: number

The body read: its index among the gauge's solids.

Thickness.vertex

vertex: number | null

The vertex of that body's ThicknessGauge.mesh() the reading is at; null for a reading at a point (ThicknessGauge.thicknessAt()).

Thickness.face

face: number

The face of body that point lies on.

Thickness.point

point: number[]

Where the wall is read.

Thickness.thickness

thickness: number

The rule's figure on the measuring mesh: the distance from point to opposite; 0 on a knife edge.

Thickness.opposite

opposite: number[]

The nearest point on the opposing triangle; point itself on a knife edge.

Thickness.oppositeBody

oppositeBody: number

The body opposite lies on: the gauge's bodies are measured against each other.

Thickness.oppositeFace

oppositeFace: number

The face of opposite_body that opposite lies on.

Thickness.knife

knife: boolean

Whether point is a knife edge: thickness 0, opposite equal to point.

Thickness.exactThickness

exactThickness: number

The distance from point to exact_opposite: the figure to compare with a closed form.

Thickness.exactOpposite

exactOpposite: number[]

opposite moved onto its face's exact surface, where that foot lies within the tolerance of it and inside the face's trims; otherwise opposite itself.

Thickness.sphere

sphere: number | null

The diameter of the largest ball tangent at point that holds none of the surfaces — the wall's inscribed thickness, which on a tilted wall is more than thickness; null where no ball up to maximum is bounded, and 0 on a knife edge.

FaceThickness

class FaceThickness

One face's wall thickness, as plain data: what ThicknessGauge.thicknessAtFace() and Solid.thicknessAtFace() return when something on the face reads. Over the face's vertices, thickness is the median of their exact readings, each vertex counting once (by vertex count, not by area); at a point, thickness, min and max are the one reading. The figure is meant for plate-like faces: by the rule a solid cylinder's side face (radius 5) reads about 7.07, 5√2, the chord to the first opposing facet past a quarter turn — not its diameter, and not uniform.

FaceThickness.thickness

thickness: number

The median of the face's readings, or the reading at the point asked.

FaceThickness.min

min: number

The thinnest reading on the face.

FaceThickness.max

max: number

The thickest reading on the face.

FaceThickness.uniform

uniform: boolean

Whether max - min is within the gauge's tolerance; a very gentle taper reads as uniform.

ThicknessMesh

class ThicknessMesh

A body's measuring mesh, copied out of the gauge: what ThicknessGauge.mesh() returns. Its vertices are split per face — no vertex is shared between two faces — so each carries its own face's exact normal.

ThicknessMesh.positions

positions: number[][]

One point per vertex; a reading's vertex indexes them.

ThicknessMesh.normals

normals: number[][]

One unit outward normal per vertex, its face's exact surface normal.

ThicknessMesh.triangles

triangles: number[][]

Three vertex indices per triangle.

ThicknessMesh.faces

faces: number[]

The face of the body each triangle lies on.

MeshThickness

class MeshThickness

One reading on a plain mesh, as plain data: what blacksmith.meshThickness() returns. Points are three numbers.

MeshThickness.mesh

mesh: number

The mesh read: its index among the meshes passed.

MeshThickness.vertex

vertex: number

The vertex of that mesh the reading is at.

MeshThickness.thickness

thickness: number

The distance from point to opposite; 0 on a knife edge.

MeshThickness.point

point: number[]

The vertex's position.

MeshThickness.opposite

opposite: number[]

The nearest point on the opposing triangle; point itself on a knife edge.

MeshThickness.oppositeMesh

oppositeMesh: number

The mesh opposite lies on: the meshes are measured against each other.

MeshThickness.oppositeTriangle

oppositeTriangle: number

The triangle of opposite_mesh that opposite lies on.

MeshThickness.knife

knife: boolean

Whether the vertex is a knife edge: thickness 0, opposite equal to point.

RTree

class RTree

A spatial index over boxes with ids (an R\*-tree): which entries a box meets, which are within a distance of a point or nearest it, which a ray passes through, and which pairs of boxes meet, between two trees or within one. RTree() is an empty tree; RTree.fromBoxes(), RTree.fromPoints() and RTree.fromTriangles() pack a whole set at once, and Solid.faceTree() gives one over a solid's faces. The tree changes in place (RTree.insert(), RTree.remove()) and stays balanced; its length is how many entries it holds.

An entry is an id and a box. Ids are the caller's own and may repeat: two entries may share an id, or an id and a box, and the same (id, box) twice is two entries, found twice. A box is (min, max) — two (x, y, z) triples — a Box, or 6 numbers [minx, miny, minz, maxx, maxy, maxz]; a point stands for a zero box. A box with a NaN or infinite coordinate, or min above max on an axis, is not a box. Touching boxes meet, everywhere: a box's faces count.

Answers come in a fixed order, so the same entries give the same answer whatever order they arrived in and however the tree was built: RTree.search() ids ascending, RTree.within() and RTree.nearest() by distance then id, pairs ascending. Distances are Euclidean from the point to the box, 0 inside it. slack is the largest gap between two boxes that still pair: two boxes at most slack apart on every axis pair, so 0 is touching. Calls on one tree must not overlap from two threads. Close it when done, or let the language's scope do it; see Lifetimes.

RTree.fromBoxes()

static fromBoxes(entries: Iterable<[number, RTreeBox]>): RTree

A tree over (id, box) pairs at once, packed (sort-tile-recursive): fuller and faster to query than the same entries inserted one by one, and the same tree for any order of them. The first entry whose box is not a box throws BuildError, by index.

RTree.fromPoints()

static fromPoints(points: Iterable<Point3>): RTree

A tree over points, each a zero box whose id is its index. The first point with a NaN or infinite coordinate throws BuildError, by index.

RTree.fromTriangles()

static fromTriangles(positions: Iterable<Point3>, triangles: Iterable<ArrayLike<number>>): RTree

A tree over a mesh's triangles in one call: triangles an (m, 3) sequence of indices into positions (an (n, 3) sequence of points), one entry per triangle, its id the triangle's index and its box its three corners' box. The first corner past the points (triangle 1 names point 9 of 4) or at a point with a NaN or infinite coordinate throws BuildError, by triangle and point; points no triangle uses are not checked.

RTree.insert()

insert(id: number, box: RTreeBox): void

Add the entry (id, box), box a box or a point. A box that is not a box, or a point that is not finite, throws BuildError and leaves the tree as it was.

RTree.remove()

remove(id: number, box: RTreeBox): boolean

Take out one entry equal to (id, box) and say whether there was one. remove needs the box the entry was inserted with, compared coordinate by coordinate (a point's is its zero box): the id alone does not find it. None found is False, not an error; with duplicates one goes per call. A box that is not a box throws BuildError.

RTree.bounds

readonly bounds: [number[], number[]] | null

The union of every entry's box as (min, max), or null for an empty tree.

RTree.within()

within(point: Point3, r: number): RTreeHit[]

Every entry whose box is within r of point (0 inside the box; exactly r counts), as (id, distance) pairs by distance then id. A point not finite, or an r negative or NaN, throws BuildError.

RTree.nearest()

nearest(point: Point3, k: number): RTreeHit[]

The k entries whose boxes are nearest point, as (id, distance) pairs by distance then id — the smaller ids win a tie at the k-th place; every entry when k is over the count, none for k 0 or an empty tree. A point not finite, or a k above 1,000,000, throws BuildError.

RTree.ray()

ray(origin: Point3, direction: Point3, maxT?: number): RTreeHit[]

Every entry whose box the ray origin + t * direction, 0 <= t <= max_t, meets, as (id, t) pairs by t then id: t is where the ray enters the box, 0 when origin is inside it. Touching counts — a ray grazing a face or an edge, or running along one, meets the box. t is in units of direction's length, which is not normalised; max_t defaults to infinity. The boxes are what is tested: for a triangle or a face the caller tests the hits' own geometry. An origin or direction not finite, a zero direction, or a max_t negative or NaN throws BuildError.

RTree.overlaps()

overlaps(other: RTree, slack?: number): RTreePair[]

Every pair (a, b), a an entry of this tree and b one of other, whose boxes are at most slack apart on every axis (0 by default: touching), ascending. A slack negative or NaN throws BuildError.

RTree.selfOverlaps()

selfOverlaps(slack?: number): RTreePair[]

Every unordered pair of distinct entries at most slack apart on every axis, once each as (smaller id, larger id), ascending — an id pairs with itself only where two entries share it. A slack negative or NaN throws BuildError.

RTree.close()

close(): void

Free this handle now. Leaving a with block or the garbage collector does the same.

Interpolator

class Interpolator

A list of samples read at a fractional index, as Rhino's Interpolator: animation keys, a value along a pattern, a smoothed profile of measurements. Interpolator(samples, cyclic) takes numbers, or equal-length sequences of numbers — 2D or 3D points, or vectors of any dimension; samples of unequal lengths are refused before the call. Its length is how many samples it holds.

t is a fractional sample index: t = 2 is sample 2, t = 2.5 halfway between samples 2 and 3. An open list clamps t to [0, length - 1] and stops on its first and last samples, an end sample standing in for its missing neighbour; a cyclic list wraps t with period length (t = length is sample 0, t = -0.5 halfway between the last sample and the first).

The five modes are Paul Bourke's formulas, in the notation mu the fraction past sample i and y0 ... y3 the samples at i - 1 ... i + 2; every mode returns the sample itself at a whole t. A dimension-1 interpolator answers numbers, others tuples, each component read on its own (every mode is a fixed linear combination of at most four samples). A sample that is NaN or infinite, no samples at all, or a t that is NaN or infinite throws BuildError; a mode name not among the five is refused before the call. It never changes once made. Close it when done, or let the language's scope do it; see Lifetimes.

Interpolator.dimension

readonly dimension: number

How many numbers a sample holds: 1 answers numbers, more answers tuples.

Interpolator.cyclic

readonly cyclic: boolean

Whether t wraps round the list (true) or is clamped to its ends (false).

Interpolator.at()

at(t: number, mode?: InterpolatorMode): number | number[]

The value at the fractional index t by mode — "nearest", "linear" (the default), "cosine", "cubic" or "catmull_rom". A t that is NaN or infinite throws BuildError.

Interpolator.sample()

sample(ts: Iterable<number>, mode?: InterpolatorMode): (number | number[])[]

The values at every t of ts by mode, as Interpolator.at() reads each, in one call. A value of t that is NaN or infinite (by its index), or more than 1,000,000 of them, throws BuildError.

Interpolator.nearest()

nearest(t: number): number | number[]

The sample at floor(t + 1/2) — a half rounds up — after the clamp or wrap.

Interpolator.linear()

linear(t: number): number | number[]

Straight between the samples either side of t: y1 + (y2 - y1) mu.

Interpolator.cosine()

cosine(t: number): number | number[]

Linear at (1 - cos(pi mu)) / 2 instead of mu: an ease, flat at every sample.

Interpolator.cubic()

cubic(t: number): number | number[]

Bourke's cubic over the four samples about t: a0 mu^3 + a1 mu^2 + a2 mu + y1 with a0 = y3 - y2 - y0 + y1, a1 = y0 - y1 - a0, a2 = y2 - y0. Through every sample, but not C1, and it does not reproduce a straight ramp.

Interpolator.catmullRom()

catmullRom(t: number): number | number[]

The Catmull-Rom spline over the four samples about t: through every sample, C1, its tangent at each (y2 - y0) / 2. It reproduces straight ramps and parabolas sampled at whole t.

Interpolator.close()

close(): void

Free this handle now. Leaving a with block or the garbage collector does the same.

Animation

class Animation

Keyframe tracks over named targets: what moves, turns, scales, shows, tints or ghosts, and when. A host plays it by asking, at a time t in seconds, for each target's Animation.placementAt() (a 4x4 matrix) and each track's Animation.valueAt(). Animation() makes an empty one; tracks are added with Animation.addTrack() or one of the channel helpers.

A track drives one channel of one target — any non-empty name: a part, a node, a light — through keys, (time, value) pairs with times in seconds, strictly increasing. There are seven channels, each with its own kind of key value. A "translate" key carries an offset (x, y, z). A "rotate" key carries an angle in degrees about the track's axis through its pivot (right-handed; see Animation.setPivot()). A "scale" key carries factors (sx, sy, sz) about the track's pivot. A "visible" key carries a number, shown when above 0.5, and a "ghost" key one, ghosted when above 0.5; both always hold, as "nearest". A "colour" key carries (r, g, b). A "value" key carries any number, or a list of numbers of any length — a dial, a gauge, a host's own signal.

The mode reads between keys, as the Interpolator's five: "nearest" holds the latest key at or before t (a key at 2 takes effect at 2), "linear" (the default), "cosine" (linear on a cosine ease), "cubic" (Bourke's cubic on the four keys about t at the segment's fraction — the sampled-curve form; prefer Catmull-Rom for uneven keys) and "catmull_rom" (the non-uniform Hermite: C1, its tangents in value per second; evenly spaced keys equal the interpolator's). Before the first key a track reads its first value, after the last its last; one key is a constant. A track's duration is its last key time, and the animation's is the latest over all its tracks (0 with none).

A target's placement is its scales, then its rotates, then its translates, applied in that order, composed T_n ... T_1 * R_m ... R_1 * S_k ... S_1 (the first added of each kind applied first), a rotate as Tr(p) * Rot(axis, angle) * Tr(-p) and a scale as Tr(p) * diag(s) * Tr(-p) about its pivot p. A target with no placement track answers the identity. Targets are numbered in order of first appearance. The View plays an animation in a later release.

A track the kernel refuses — an empty target, no keys, a time that is negative, NaN or not increasing, a value that is NaN or infinite, a dimension the channel does not take, a value track of dimension 0, more than 1,000,000 keys — throws BuildError and leaves the animation unchanged. A channel or mode name not among those above, or keys whose values differ in length, throws TypeError before the call, and leaves it unchanged too. Close it when done, or let the language's scope do it; see Lifetimes.

Animation.addTrack()

addTrack(target: string, channel: AnimationChannel, keys: Iterable<AnimationKey>, mode?: InterpolatorMode): number

Add a track driving channel of target through keys by mode ("linear" by default) and return its index, counting from 0 in the order added. A value that is a number is dimension 1; the values of one track all have the same length. A refusal throws BuildError, with the call's name in front (animation_add_track: times must increase: key 2 at 1 after 1.5).

Keys are [time, value] arrays, the value a number or an array of numbers; channel and mode are the strings above. Returns the track index.

Animation.translate()

translate(target: string, keys: Iterable<AnimationKey>, mode?: InterpolatorMode): number

A translate track: keys (time, (x, y, z)), an offset in model units.

Animation.rotate()

rotate(target: string, keys: Iterable<AnimationKey>, options?: { pivot?: ArrayLike<number>; axis?: ArrayLike<number>; mode?: InterpolatorMode }): number

A rotate track: keys (time, degrees), about axis (+Z by default, any non-zero vector, taken as a direction) through pivot (the origin by default), right-handed. A pivot or axis that is not three numbers throws TypeError; one with an entry that is NaN or infinite, or an axis too short to point anywhere, throws BuildError. Either adds no track.

rotate(target, keys, { pivot, axis, mode }): keys are [time, degrees], the options object optional.

Animation.scale()

scale(target: string, keys: Iterable<AnimationKey>, options?: { pivot?: ArrayLike<number>; mode?: InterpolatorMode }): number

A scale track: keys (time, (sx, sy, sz)), about pivot (the origin by default). A pivot that is not three numbers throws TypeError; one with an entry that is NaN or infinite throws BuildError. Either adds no track.

scale(target, keys, { pivot, mode }): keys are [time, [sx, sy, sz]], the options object optional.

Animation.visible()

visible(target: string, keys: Iterable<AnimationKey>): number

A visibility track: keys (time, number), shown when above 0.5. Always read as "nearest".

Animation.colour()

colour(target: string, keys: Iterable<AnimationKey>, mode?: InterpolatorMode): number

A colour track: keys (time, (r, g, b)).

Animation.ghost()

ghost(target: string, keys: Iterable<AnimationKey>): number

A ghost track — a part shown faded, as a host draws one: keys (time, number), ghosted when above 0.5. Always read as "nearest".

Animation.value()

value(target: string, keys: Iterable<AnimationKey>, mode?: InterpolatorMode): number

A free value track: keys (time, number) or (time, numbers) of any length, the same for every key.

Animation.setPivot()

setPivot(track: number, pivot: ArrayLike<number>, axis?: ArrayLike<number>): void

Set the pivot and axis (three numbers each; the axis +Z unless given) of the rotate or scale track track. A pivot or axis that is not three numbers throws TypeError. Any other kind of track, an entry that is NaN or infinite, or a rotate axis too short to point anywhere, throws BuildError.

Animation.duration

readonly duration: number

The latest key time over all tracks, in seconds; 0 with no tracks.

Animation.targets

readonly targets: string[]

The target names, in order of first appearance. The index of a name is the index Animation.placementAt() takes.

A getter answering an array of names; the track count is the count getter.

Animation.track()

track(i: number): AnimationTrack

Track i, as it was added, as an AnimationTrack: its target, channel and mode names (the mode as asked, though visible and ghost evaluate as "nearest"), the key times, the key values (dimension numbers a key), the dimension, and the pivot and axis (the origin and +Z unless set). An i that is not below the track count throws BuildError.

Animation.valueAt()

valueAt(track: number, t: number): number | number[]

The value of track track at time t, by its mode: dimension numbers. A t that is NaN or infinite, or a track out of range, throws BuildError.

Animation.valuesAt()

valuesAt(t: number): (number | number[])[]

The value of every track at time t, in track order, each shaped as Animation.valueAt()'s; an empty list with no tracks. A t that is NaN or infinite throws BuildError.

Animation.placementAt()

placementAt(target: string | number, t: number): number[][]

The placement of target — its name, or its index in Animation.targets — at time t, as a 4x4 matrix in the View's set_placement layout: four columns of four numbers, m[col][row], the translation in the fourth column. A name that is not a target throws TypeError; an index out of range, or a t that is NaN or infinite, throws BuildError.

Answers 4 columns of 4 as an array of arrays, m[col][row], as Python does. placementAt(target, t) takes a name or an index.

Animation.clone()

clone(): Animation

An independent copy: tracks added to either never reach the other.

Animation.close()

close(): void

Free this handle now. A second call does nothing; any other call after it throws BuildError. Leaving the scope that owns it does the same.

AnimationTrack

class AnimationTrack

One track of an Animation, read back as it was given by Animation.track(): a plain record, equal to another by value, that holds no handle and needs no closing.

AnimationTrack.target

readonly target: string

The name of the target it drives.

AnimationTrack.channel

readonly channel: AnimationChannel

The channel's name: "translate", "rotate", "scale", "visible", "colour", "ghost" or "value".

AnimationTrack.mode

readonly mode: InterpolatorMode

The mode's name, as it was asked. A visible or ghost track reads as "nearest" whatever it says.

AnimationTrack.times

readonly times: readonly number[]

The key times, in seconds, increasing.

AnimationTrack.values

readonly values: readonly number[] | readonly (readonly number[])[]

The key values: numbers at dimension 1, dimension numbers a key.

AnimationTrack.dimension

readonly dimension: number

How many numbers a key's value holds.

AnimationTrack.pivot

readonly pivot: readonly number[]

The pivot a rotate or scale works about: the origin unless set. Any track has one.

AnimationTrack.axis

readonly axis: readonly number[]

The axis a rotate turns about: +Z unless set. Any track has one.

Document

class Document

A model as data: a graph of nodes (profile.rect, solid.extrude, measure.mass, ...), each a blacksmith verb reading other nodes by id, with named parameters that any number can be an "=expression" of, evaluated incrementally, and edited by ops that are undoable and branch. The whole thing — nodes, parameters, history, branches — saves as JSON text (the cadaclysm-blacksmith format, version 1) and loads back to the same document.

A node has a kind, which names the verb and its inputs, and fields: a number, an "=expression" over the parameters and other nodes' values, or the id of another node to read. An expression holds numbers with units (3 mm, 45 deg), lists ([1, 2, 3 mm], range(0, 360, 60), item, slice, merge, flatten, reverse, len, polar, zip), comparisons, and, or, not and if(c, a, b); arithmetic maps over lists item by item, the shorter padded with its last item. A node given a list where a field takes one number runs once per item and gives the list of its results ("lacing": "cross" takes every combination); a value node holds one expression for others to read by its id ("=v1"). Every edit is an op — add, set, remove, rename or param — and one op is one commit. A refused op throws BuildError with the reason, and the document is unchanged.

The nodes are brought up to date when you read one: only the nodes an edit made stale are evaluated again, and a node that fails is reported by errors while the nodes that do not read it still answer. A node's result comes out as the language's own type: a Solid, a Profile, a NurbsCurve, a Subd, or a plain value.

The web build's history. The kernel wasm module carries the same document, and also a JavaScript-only history binding, cadaclysm_blacksmith_history_*, over the same commits and branches for a page that shows a timeline. It is not part of this page's wrapper surface: for now the Python members below are the history surface.

Close it when done, or let the language's scope do it; see Lifetimes. One thread at a time.

Document.load()

static load(text: string): Document

The document that save wrote as text: its nodes, parameters, history and branches.

Document.open()

static open(path: string): Document

The document saved in the file at a path.

Document.kinds()

static kinds(): NodeKind[]

Every node kind the library knows, one record a kind: its name, inputs, output, cost and help. Needs no document.

Document.newBim()

static newBim(units?: string): Document

An empty building document: the blacksmith kinds and the bim.* ones (levels, layered walls and their joins, doors, windows, floors), holding a bim.project node whose random guid seeds every IFC GlobalId it exports.

Document.loadBim()

static loadBim(text: string): Document

A building document that save wrote as text, opened with the bim.* kinds.

Document.openBim()

static openBim(path: string): Document

The building document saved in the file at a path.

Document.bimKinds()

static bimKinds(): NodeKind[]

Every node kind a building document knows, the blacksmith's and the bim.* ones, as kinds lists them. Needs no document.

Document.partsCatalog

Loads the parts catalogue (a directory of family files and their index) that parts.catalog nodes build their parts from: servos, bars, brackets, bearings, pulleys. Replaces the one loaded before.

Not in Node: the bench documents are Python's only.

Document.newParts

An empty bench document, in millimetres: the blacksmith kinds, the assembly.* ones among them, and parts.catalog, a catalogue part by its entry and parameters.

Not in Node: the bench documents are Python's only.

Document.loadParts

A bench document that save wrote as text (the robot bench's file), opened with the parts.* kinds. A file that is not a document throws BuildError saying so.

Not in Node: the bench documents are Python's only.

Document.openParts

The bench document saved in the file at a path.

Not in Node: the bench documents are Python's only.

Document.partsKinds

Every node kind a bench document knows, the blacksmith's and the parts.* ones, as kinds lists them. Needs no document.

Not in Node: the bench documents are Python's only.

Document.exportIfc()

exportIfc(path?: string | null, options?: { schema?: string; geometry?: string; timestamp?: number | null; name?: string }): string

The building as IFC text, IFC4 or IFC2x3, its geometry parametric (the design intent: extruded outlines, openings voiding their walls) or exact (the evaluated bodies, openings already cut); with a path, also written to that file. The time stamp defaults to now. A document that cannot be written in full throws BuildError with every reason at once, one a line, each on its node, and nothing is written.

exportIfc(path?, {schema, geometry, timestamp, name}); a refusal's BuildError carries refusals, [node | null, reason] pairs.

Document.sheetSvg

A sheet (a bim.sheet node, by id) as SVG text sized in paper millimetres — its frame, title block, and the plans, sections, elevations, schedules and 3D views placed on it (a 3D view is drawn as its visible lines; a picture-style one, which only the web editor renders, as a box reading "3D view not rendered") — evaluating the document first; with a path, also written to that file. A node that is not a sheet throws BuildError.

Not in this wrapper yet: Python and the C API have it.

Document.sheetPdf

A sheet (a bim.sheet node, by id) as a one-page PDF the size of its paper, with a bookmark naming it — its frame, title block, and the plans, sections, elevations, schedules and 3D views placed on it (a 3D view is drawn as its visible lines; a picture-style one, which only the web editor renders, as a box reading "3D view not rendered") — evaluating the document first; with a path, also written to that file. A node that is not a sheet throws BuildError.

Not in this wrapper yet: Python and the C API have it.

Document.sheetsPdf

Several sheets (ids) as one PDF: a page each in the order given, each its paper's size, a bookmark a page, a 3D view drawn as its visible lines (a picture-style one, which only the web editor renders, as a box reading "3D view not rendered"); with a path, also written to that file. An empty list, or a node that is not a sheet, throws BuildError.

Not in this wrapper yet: Python and the C API have it.

Document.save()

save(path?: string | null): string

The document as JSON text; with a path, also written to that file.

Document.apply()

apply(op: string | { [key: string]: any }, message?: string | null): ChangedSet

Applies one op, given as a JSON record or its text ({"op": "add", "node": {...}}, set, remove, rename, param), and records it as one commit with an optional message. Answers the changed set: the ids added, changed and removed, and the parameter names touched.

Document.add()

add(kind: string, fields?: NodeFields): string

A new node of a kind with its fields, one commit. Its id is made up unless the call gives one; the id is returned.

add(kind, fields): the fields as one object, id, name and message among them.

Document.addSolid()

addSolid(solid: Solid, fields?: NodeFields & { sheet?: boolean }): string

A node holding a solid the caller already has — made in code or read from a file — for other nodes to read like any built one: a solid.body node (a sheet.body one for a sheet) carrying the kernel's own B-rep (Solid.documentBody()), in the document's units, inside the saved file, which gives back exactly that body. Edges and faces are referenced on it as on any node, and replacing its body later finds them again by geometry. Its colours are kept — the solid's, each face's and each edge's — its name is not. The new id is returned.

addSolid(solid, {sheet, ...fields}).

Document.addProfile()

addProfile(profile: Profile, fields?: NodeFields): string

A profile.path node holding a Profile exactly (Profile.documentPath(): arcs and NURBS as they are, holes included, its colour kept), in the document's units. The new id is returned.

Document.set()

set(id: string, fields: NodeFields): ChangedSet

Sets fields of a node, one commit; answers the changed set.

set(id, fields): the fields as one object, message among them.

Document.remove()

remove(id: string, options?: { cascade?: boolean; message?: string | null }): ChangedSet

Removes a node. Refused while another node reads it, unless cascade takes those readers with it.

remove(id, {cascade, message}).

Document.rename()

rename(id: string, name: string | null, message?: string | null): ChangedSet

Gives a node a display name; none clears it.

Document.params

readonly params: DocumentParams

The parameters, name to value (a number, or an "=expression"), as a mutable mapping. Assigning one is a param op, one commit; deleting one removes it.

A small Map-like object: get, set (a param op), delete (false when there is none), has, keys(), size and toObject().

Document.batch()

batch(message: string | null | undefined, body: DocumentBody): any
batch(body: DocumentBody): any

Ops applied live inside the block are recorded as one commit with the block's message. An error inside rolls every op of the batch back and is passed on.

batch(message?, body): a synchronous callback, whose result is returned.

Document.preview()

preview(body: DocumentBody): any

Ops applied inside the block evaluate but are never recorded, and are taken back on leaving, normally or by an error: a drag, a what-if.

preview(body): a synchronous callback. Also the editor's drag: previewFrame(op) applies one frame, unrecorded, after taking back the last one, and endPreview() takes the drag back.

Document.undo()

undo(): boolean

Takes back the head commit. False when there was nothing to take back.

Document.redo()

redo(): boolean

Puts back the commit undo took back. False when there was nothing to put back.

Document.canUndo

readonly canUndo: boolean

Whether undo has a commit to take back.

Document.canRedo

readonly canRedo: boolean

Whether redo has a commit to put back.

Document.branch

readonly branch: string | null

The current branch's name, or none when the head is detached (switched to a commit id).

Document.branches

readonly branches: { [name: string]: string }

Every branch, name to the id of its tip commit.

A plain object, name to the tip's commit id.

Document.branchNew()

branchNew(name: string, at?: string | null): void

A new branch. Without a commit id it starts at the head and the document switches onto it; with one it starts there.

Document.switch()

switch(nameOrCommitId: string): void

Moves the head to the branch of that name, else to the commit of that id, which detaches the head. The nodes follow.

Document.branchRename()

branchRename(old: string, name: string): void

Renames a branch; refused when the old name is missing or the new one is taken.

Document.branchDelete()

branchDelete(name: string): void

Deletes a branch; the current branch is refused. Its commits stay, as tips.

Document.tips()

tips(): Commit[]

The tips of the lines no branch names — what an undo followed by an edit leaves behind — each as a whole Commit.

Document.log()

log(branch?: string | null): Commit[]

The commits of a branch's line, newest first, the root c0 last; with no branch, the line from the head back to the root.

Document.head

readonly head: Commit

The commit the document is at.

Document.evaluate()

evaluate(options?: { cheapOnly?: boolean }): NodeStatus[]

Evaluates the nodes that are stale (only the cheap kinds when asked) and answers the status of every node: ok, error, blocked or pending.

evaluate({cheapOnly}).

Document.evaluateWith()

evaluateWith(progress: DocumentProgress | null, options?: { cheapOnly?: boolean }): NodeStatus[]

evaluate, with every kernel call's progress heard by a callback as (node, phase, done, total): node the id of the node being built, phase a short name, done of total steps within it. Every heavy node reports start before it runs, so a progress bar knows what is building and a host that crashes knows which node to leave out next time. The statuses are the same as evaluate's; a cheap-only pass reports nothing. The callback runs on the calling thread, often, and must not touch the document.

evaluateWith(progress, {cheapOnly}); progress null is silent.

Document.errors()

errors(): NodeError[]

The nodes the evaluation left in error or blocked, each with its message.

Document.value()

value(id: string): any

A node's value: a number, a point or list, a record, or text. throws BuildError for a node with none (missing, or in error).

The value's JSON parsed: numbers, arrays, objects and text.

Document.result()

result(id: string): any

What a node evaluated to, by its kind: a Solid (solids and sheets), a Profile, a list of profiles, a NurbsCurve, a Subd, a list of these for a node run over a list (each item also read as id#i), or the value of a number, point, record, list and the like; none for no such node or one that failed. Each handle is the caller's own and outlives later edits.

Document.resultGarment

Node id's value as a Garment: a garment.garment node, or any node that evaluates to one. Its lengths are in the document's units (convert a non-millimetre garment to millimetres before Garment.toAama). A missing node, one that failed or one of another kind throws BuildError.

Not in this wrapper yet.

Document.revision

readonly revision: number

A counter that moves once with every change to the document's state — an apply, an undo or redo, a branch made, switched to or deleted, a preview frame, a batch's end — and never with an evaluation, a save or a read. A new or loaded document starts at 1. A page keys what it read on it and asks again only when it moved.

Document.nodes()

nodes(ids?: Iterable<string> | null): Array<Record<string, any>>

The nodes as the file holds them, all of them in document order or those a list of ids names, in that order; an open batch's or preview's edits are in it. An unknown id throws BuildError, naming it.

Document.inputs()

inputs(id: string, transitive?: boolean): string[]

The ids of the nodes a node reads, in document order: those its fields name, or with transitive everything those read too, however far, each once. Parameters are walked through, not listed. An unknown id throws BuildError.

Document.readers()

readers(id: string, transitive?: boolean): string[]

The mirror of Document.inputs(): the ids of the nodes that read a node, directly or with transitive however far — what removing it would break.

Document.probe()

probe(op: string | Record<string, unknown>, ids: Iterable<string>): { statuses: NodeStatus[]; end(): void }

An op tried on a scratch copy: only the nodes ids names and what they read are evaluated, and their statuses answered. Until the probe ends, those nodes' results are the probe's and every other node's the document's; the document's nodes, history and revision are untouched, and every call that would change it is refused. A snapping tool tries a placement this way. Refused while a batch, a preview or another probe is open, for an op the copy refuses, or for an unknown id.

probe(op, ids) answers {statuses, end()}; probe(op, ids, body) runs body(statuses) and ends the probe on leaving, normally or by an error.

Document.resultBeziers()

resultBeziers(id: string, frame?: ArrayLike<number> | null): Float64Array

A curve node, a profile, a list of profiles or a sketch as rational cubic Béziers, sixteen numbers each — x y z w per control point, as Profile.beziers() gives them: a curve on its own frame, a profile on the sketch plane, or either carried onto frame. An open probe's value is read for a node it evaluated. A node with none — a solid, a value — throws BuildError.

Document.meta()

meta(app: string): any

An app's own data about the document — what the last meta op set for it: a camera, a grid, a selection — undone and saved with the rest, never read by evaluation. None when the app keeps none.

Parsed.

Document.close()

close(): void

Free this handle now. Leaving a with block or the garbage collector does the same.

Leaving a using block or the garbage collector does the same.

Commit

class Commit

One commit of a Document's history, as plain data: what Document.log(), Document.tips() and Document.head return.

Commit.id

readonly id: string

The commit's id; c0 is the root.

Commit.parents

readonly parents: readonly string[]

The ids of the commits it follows.

Commit.message

readonly message: string | null

The message it was recorded with; none when not set.

Commit.author

readonly author: string | null

Who recorded it; none when not set.

Commit.time

readonly time: string | null

When it was recorded; none when not set.

Commit.ops

readonly ops: readonly { [key: string]: any }[]

The ops it applied, each as the record that was sent.

SubdMesh

class SubdMesh

One level of a cage's smooth surface, as Subd.smoothMesh() returns it: positions and normals (limit positions and unit outward limit normals, three numbers a vertex), indices (three vertex ids a triangle) and triangle_face (the face of the full cage each triangle lies on; on a mirrored half, face f of the half is f and its reflection f + len(faces)). Copied out of the cage, so it outlives it; the arrays are writable. At the C ABI the same arrays are views into the cage's handle, good until that handle is freed.

SubdMesh.positions

positions: Float64Array

The limit positions, an (n, 3) float64 array.

A Float64Array of 3n numbers.

SubdMesh.normals

normals: Float64Array

The unit outward limit normals, an (n, 3) float64 array matching positions.

A Float64Array of 3n numbers.

SubdMesh.indices

indices: Uint32Array

The triangles, an (m, 3) uint32 array of ids into positions.

A flat Uint32Array, three ids a triangle.

SubdMesh.triangleFace

triangleFace: Uint32Array

The cage face each triangle lies on, an (m,) uint32 array: the full cage's numbering (see above for a mirrored half).

A Uint32Array.

SubdReport

class SubdReport

What Subd.toSolid() did and how close it came, as plain data: how many patches were built exactly from their own net (regular) and how many from a refined neighbourhood (refined), the Catmull-Clark steps taken first, the deepest local refinement a patch needed (levels), and the two figures the options bound — the largest deviation from the limit surface and the largest tangent break g1_angle_deg across a side that is not creased — with the world points they were measured at.

SubdReport.regular

regular: number

Patches built exactly from their own net, with no refinement.

SubdReport.refined

refined: number

Patches built from a refined neighbourhood.

SubdReport.steps

steps: number

The Catmull-Clark steps taken before the patches were cut: 1 or 2.

SubdReport.levels

levels: number

The deepest local refinement a patch took; 0 when none was refined.

SubdReport.deviation

deviation: number

The largest deviation from the limit surface, as a fraction of the cage's bounding-box diagonal.

SubdReport.g1AngleDeg

g1AngleDeg: number

The largest tangent break across a side that is not creased, in degrees.

SubdReport.deviationAt

deviationAt: [number, number, number]

The world point deviation was measured at, three numbers.

An array of 3 numbers.

SubdReport.g1At

g1At: [number, number, number]

The world point g1_angle_deg was measured at, three numbers.

An array of 3 numbers.

Subd

class Subd

A Catmull-Clark control cage: positions, faces, creased edges, pinned vertices, an optional mirror plane, and the selection of the edit that made it. It is immutable — every edit returns a new Subd, whose selection names what that edit touched — and Subd.toSolid() turns it into an exact B-rep that every Solid call takes. Close it when done, or let the language's scope do it; see Lifetimes. A refusal throws BuildError with the kernel's own words.

What the conversion to a solid does and does not do: it cuts one NURBS face per quad after one Catmull-Clark step, or two when a quad of the first step has two extraordinary corners (every cylinder primitive; SubdReport.steps says which) — so a cage quad gives 4 faces after one step, an n-gon n, and the 6-sided plain cylinder gives 144 — with a tangent-continuous block at each extraordinary vertex. A smooth vertex of high valence (7 or more on these primitives) may be refused at the default tolerances, with the measured figures: a plain 7-sided cylinder is, while an 8-sided one with creased rims converts. A crease or boundary side with 4 or more faces on one side has no tangent plane there, so a conversion through one may be refused. Fillets along edges that are splines are not available yet. At the C ABI, the arrays Subd.positions and Subd.smoothMesh() give are views into the cage's handle, good until that handle is freed.

Subd.close()

close(): void

Free this handle now. The garbage collector, or the language's scope, does it otherwise.

Subd.cuboid()

static cuboid(size?: Point3, segments?: ArrayLike<number>): Subd

A box of size (x, y, z), centred on the origin, with segments quads along each axis (1 to 1024 each). Default: a 2 x 2 x 2 box of one quad a side.

size and segments are arrays of 3 ([2, 2, 2] and [1, 1, 1] by default).

Subd.cylinder()

static cylinder(radius?: number, height?: number, sides?: number, rings?: number, creasedRims?: boolean): Subd

A cylinder along +Z: one n-gon cap per end with sides sides and rings bands of quads between them. With creased_rims (the default in Python) the two rim loops are creased, so the caps stay flat; an uncreased cylinder of 7 or more sides is refused by Subd.toSolid() at the default tolerances.

Subd.sphere()

static sphere(radius?: number, segments?: number): Subd

A quad ball of radius: a cube grid with segments quads per edge (at most 1024), each vertex pushed out to the radius.

Subd.torus()

static torus(major?: number, minor?: number, around?: number, tube?: number): Subd

A torus around +Z, all quads: around steps about the axis at radius major, tube steps round the tube of radius minor.

Subd.fromParts()

static fromParts(positions: SubdPoints, faces: ArrayLike<number>[], creases?: SubdEdge[], pins?: ArrayLike<number>, symmetry?: SubdSymmetry | null): Subd

A cage from its parts, the lossless inverse of reading them back: positions (n, 3), faces lists of vertex ids, creases (a, b) pairs that are edges, pins vertex ids, and symmetry null or an axis ("x", "y" or "z") with a tolerance, for a mirrored half, as Subd.symmetry reports it. The new cage selects nothing. A malformed cage throws BuildError.

positions is a flat run of 3n numbers or an array of [x, y, z]; faces arrays of ids; creases [a, b] pairs; symmetry null or {axis, tolerance}, axis being 'x', 'y' or 'z'.

Subd.positions

readonly positions: Float64Array

The cage's vertices, an (n, 3) float64 array of your own: a copy.

A Float64Array of 3n numbers (x, y, z a vertex), a copy.

Subd.faces

readonly faces: number[][]

Each face's vertex ids, in loop order.

Subd.creases

readonly creases: SubdEdge[]

The creased edges, each as (smaller id, larger id), sorted.

An array of [a, b] pairs.

Subd.pins

readonly pins: number[]

The pinned vertices: they refine as corners and stay put.

Subd.symmetry

readonly symmetry: SubdSymmetry | null

null for an ordinary cage; for a mirrored half, the plane's axis ("x", "y" or "z") and how far from it a vertex counts as on it.

Null, or {axis, tolerance}.

Subd.selection

readonly selection: SubdSelection | null

What the edit that made this cage touched: "vertices" or "faces" with ids, or "edges" with (a, b) pairs; null for a cage no edit selected (a primitive, Subd.fromParts(), the mirror calls).

Null, or {kind, ids}: kind 'vertices', 'edges' or 'faces', and ids the ids, an edge selection's as [a, b] pairs.

Subd.transform()

transform(selection: SubdSelection, matrix: ArrayLike<number> | ArrayLike<number>[]): Subd

A new cage with the selected elements moved by matrix, and the same elements selected. selection is "vertices", "edges" or "faces" with ids (edges as (a, b) pairs); matrix is sixteen numbers column-major. A rotation about a point is baked into the matrix by the caller.

selection is {kind, ids}; matrix sixteen numbers column-major, or a 4x4 of rows (row-major).

Subd.crease()

crease(edges: SubdEdge[], on?: boolean): Subd

A new cage with edges ((a, b) pairs) creased, or un-creased when on is false; it selects them. A pair that is not an edge throws BuildError.

edges are [a, b] pairs.

Subd.pin()

pin(vertices: ArrayLike<number>, on?: boolean): Subd

A new cage with vertices pinned (they refine as corners and stay put), or released when on is false; it selects them.

Subd.extrude()

extrude(faces: ArrayLike<number>, distance: number): Subd

A new cage with faces pushed out by distance along each connected region's average normal, with a quad wall on each boundary edge. The moved faces keep their ids and the new cage selects them.

Subd.inset()

inset(faces: ArrayLike<number>, amount: number, individual?: boolean): Subd

A new cage with faces shrunk by amount, in (0, 1), within their surface, and a ring of quads round each region (round each face, with individual). The new cage selects the inner faces.

Subd.subdivide()

subdivide(faces?: ArrayLike<number>): Subd

A new cage with faces subdivided once by the Catmull-Clark rules (the whole cage when no faces are given): each face becomes quads round a new point, and an unpicked face beside them takes the new edge points as corners. The whole cage keeps its smooth surface exactly. The new cage selects the new faces.

faces defaults to [], the whole cage.

Subd.insertLoop()

insertLoop(edge: SubdEdge, at?: number): Subd

A new cage with a loop of edges cut across the ring of quads through edge (an (a, b) pair), at a + at * (b - a) with at in (0, 1). It selects the new loop.

edge is [a, b].

Subd.edgeLoop()

edgeLoop(edge: SubdEdge): SubdEdge[]

The loop of edges through edge, straight across each valence-four vertex, the picked edge first and each pair smaller id first; empty when edge is not an edge of the cage.

Takes [a, b] and returns an array of [a, b] pairs.

Subd.mirrorOn()

mirrorOn(axis: SubdAxis): Subd

The positive half of the cage across the plane perpendicular to axis ("x", "y" or "z"), as a mirrored cage: every later edit keeps it symmetric.

Subd.mirrorOff()

mirrorOff(): Subd

The mirror baked: the whole cage as an ordinary one, no longer mirrored.

Subd.full()

full(): Subd

The whole cage of a mirrored half — the half's vertices first, then the reflections of those off the plane — or a copy of an ordinary cage.

Subd.smoothMesh()

smoothMesh(levels?: number): SubdMesh

The smooth surface refined levels times (1 to 6, 3 by default), as a SubdMesh.

Subd.pick()

pick(point: Point3, kind: 'vertex' | 'face'): number | null
pick(point: Point3, kind: 'edge'): SubdEdge | null

The cage element of kind ("vertex", "edge" or "face") under point, a point on or near the smooth surface: a vertex or face id, or an edge as (a, b) with the smaller id first. null when nothing is within 0.05 of the cage's diagonal — not an error. A point that is not finite throws BuildError, which is not the same answer as nothing near.

Answers a number, an edge as [a, b], or null for nothing near.

Subd.toSolid()

toSolid(tolerance?: number, g1Angle?: number, maxLevels?: number): { solid: Solid; report: SubdReport }

The cage as an exact Solid, one NURBS face per patch (see above), and a SubdReport of what the conversion did. tolerance is the largest deviation from the limit surface as a fraction of the cage's diagonal (1e-4 by default), g1_angle the largest tangent break across an uncreased side in degrees (0.1), max_levels the deepest local refinement (2 to 6, 6). A tolerance or g1_angle of 0 or less, or a max_levels of 0, takes the default; any other max_levels outside 2 to 6 throws BuildError. A cage that cannot be held within them throws BuildError, with the figures it measured.

Returns {solid, report}.

Hit

class Hit

One place two curves meet, as plain data, copied out: what Profile.hits() lists. A point has run false and start equal to end; a run has the two curves coinciding from start to end. A point at the join of two segments is reported once, on either: as segment k at t 1 or as segment k + 1 at t 0.

Hit.run

run: boolean

Whether the curves coincide along a stretch rather than meeting at a point.

Hit.touch

touch: boolean

For a point: the curves are tangent there rather than crossing. Where a side ends there, true if the two continue each other smoothly; an end resting on the other at an angle, or a corner, is not a touch.

Hit.start

start: number[]

Where it starts, three numbers (z is 0 for two profiles).

Hit.end

end: number[]

Where it ends: start again for a point.

Hit.aStart

aStart: Spot

Where it starts on the first curve, as a Spot.

Hit.aEnd

aEnd: Spot

Where it ends on the first curve.

Hit.bStart

bStart: Spot

Where it starts on the second curve.

Hit.bEnd

bEnd: Spot

Where it ends on the second curve.

Spot

class Spot

Where a Hit lands on one side: a profile's loop, segment and position along it, or (from later calls) a solid's face and its surface parameters.

Spot.loopIndex

loopIndex: number

The loop: 0 the boundary or the open chain, then the holes in the order they were added. NONE on a face.

Spot.segment

segment: number

The segment of that loop, in drawing order. NONE on a face.

Spot.t

t: number

How far along the segment, 0 at its start to 1 at its end: by length on a line, by angle on an arc, by parameter on a spline.

Spot.face

face: number

The face, on a solid; NONE on a profile.

Spot.u

u: number

The face's first surface parameter; 0 on a profile.

Spot.v

v: number

The face's second surface parameter; 0 on a profile.

SolidHits

class SolidHits

What Solid.hits() found, copied out: hits, every place profile pierces or grazes this solid's faces, as Hit values (a the profile, b the face: face, u, v), ordered along the profile; pieces, the profile's loops cut at the hits, as Piece values — empty unless the solid is closed.

SolidHits.hits

hits: Hit[]

Every place profile meets a face, as Hit values.

SolidHits.pieces

pieces: Piece[]

The profile's loops cut at the hits, as Piece values; empty for an open solid.

Piece

class Piece

One stretch of Solid.hits()'s profile between two cuts, as plain data: one of SolidHits.pieces. A piece's spots follow the cut, not the hit that made it: a segment join reads as the next segment's start (k + 1, 0), not the hit's (k, 1), and a closed loop's closing join stays (0, 0); an open chain's end reads (n - 1, 1). A loop no hit cuts is one piece, geometrically closed, start and end both (0, 0).

Piece.inside

inside: boolean

Whether the piece is inside the solid, by its middle's winding number over the solid's mesh — a piece lying on the surface (a run, or a midpoint within tolerance of a face and inside it) counts as inside too, with no third state.

Piece.start

start: Spot

Where the piece starts, as a Spot.

Piece.end

end: Spot

Where the piece ends, as a Spot.

Piece.profile

profile: Profile

The piece on its own, as an open Profile — unless the piece is a whole uncut loop, which comes back closed.

Manifold

interface Manifold

What Solid.manifold returns: whether the solid's faces make a manifold, and whether it is closed, told from its topology rather than a mesh.

Manifold.faces

faces: number

How many faces.

Manifold.edges

edges: number

How many distinct edges: one shared by two faces counts once.

Manifold.vertices

vertices: number

How many distinct vertices.

Manifold.boundaryEdges

boundaryEdges: number

Edges only one face borders: a sheet's rim, a hole in a shell.

Manifold.nonManifoldEdges

nonManifoldEdges: number

Edges three or more faces border: a fin, or two solids meeting along a line.

Manifold.nonManifoldVertices

nonManifoldVertices: number

Vertices whose faces make more than one fan: two solids touching at a corner.

Manifold.isManifold

isManifold: boolean

No non-manifold edge or vertex: a manifold, possibly with a boundary.

Manifold.isClosed

isClosed: boolean

A manifold with no boundary edge either: it encloses a solid.

FemMesh

class FemMesh

One solid meshed for a solver: nodes welded by bits, triangles wound outward, every node tagged with the lowest-dimension B-rep entity it lies on, and every crack reported rather than closed. What Solid.femMesh() returns, and owned by you: free it, or let the language's scope do it (see Lifetimes).

A handle rather than a snapshot, as a Solid is. In every wrapper that can lend a view, the big arrays are read-only views into the library's own memory, as Solid.mesh()'s are — a solver mesh is megabytes. Node and Godot copy instead, having no borrowed-view machinery at all, so for those two the array is theirs and everything below about a stale view falls away. Either way the owner of the memory is this object rather than the solid: Solid.close() does not free a FEM mesh, and meshing the solid again at another tolerance does not touch it either — a FEM mesh and a held tessellation (Solid.mesh()'s own) are each their own handle, neither one the solid's cache that a re-mesh replaces. Only FemMesh.free() does, or the language's own scope or collector reclaiming the handle.

So keep the FEM mesh itself reachable for as long as you read a view of it, and copy anything that must outlive it. What refuses a stale read is a different mechanism in each language, so all ten are named here rather than a rule with an "otherwise" in it. Swift's view type carries its owner and asks it before every element, so the read itself is refused — it traps inside the subscript getter, measured in a release build. Rust settles it before the program runs: its free takes the mesh by value, so a slice can neither be asked for after it nor held across it. Godot and Node hand back copies, so there is nothing of the library's left to go stale. Python, C#, Java and C++ check the handle in the accessor, so a view asked for after the free is refused and one already in hand is a bare array, span or buffer that reads freed memory — measured in C#, where a span taken before the free read the body's own coordinates out of the freed block. Python's numpy array does hold the mesh, which keeps it reachable (below), but nothing asks the mesh when the array is read, so one kept past an explicit free() dangles as C#'s span does. Go's and LuaJIT's arrays are fields filled when the mesh was built rather than accessors, so neither moment is refused there; their methods are, and for those two this is documented rather than enforced, as their own module headers already do for the scene.

Staying reachable is a second question, and a narrower one. In C#, Java, Go and LuaJIT the view is the platform's own array type with nowhere to hold a reference back to the handle, so a program that keeps a view and lets go of the mesh can have the collector free the handle under it with nothing ever calling FemMesh.free() — measured in C#, Java and Go. C++ has no collector but the same shape at scope end: the mesh's destructor frees the handle when it goes out of scope, and a Span kept past that reads freed memory. A view type that carries its owner is safe from that (Python's, Swift's), and so is a language that rules the case out — Rust borrows the mesh for the view's lifetime, Godot and Node copy. The same rule as Solid.mesh()'s own views.

It is freed where a Solid is closed: the same word the reader library's FEM mesh uses, so one FEM mesh is released the same way on both sides of the ABI.

FemMesh.nodes()

nodes(): Float64Array

Every node's position, three doubles each: placed by Solid.femMesh()'s placement, in the solid's own coordinates otherwise.

The five arrays are methods here, and each one copies. nodes() decodes a fresh Float64Array out of the handle every time it is asked, and the four Uint32Arrays the same — this wrapper has no borrowed-view machinery at all, koffi.decode allocating a typed array of its own (measured: two asks give two buffers, and a write into one is invisible to the other). So the paragraph above does not apply to Node: an array in hand survives free(), the collector and the owner, with nothing of the library's left in it to go stale, which is also why there is no copy() to call. The price runs the other way — every ask copies again — so hold the array rather than calling nodes() inside a loop. FemEdge's nodes and runs are copies too, and chains() gives subarray views into them, not into the library.

FemMesh.triangles()

triangles(): Uint32Array

Three node indices a triangle, wound outward — a mirroring placement is wound back.

FemMesh.triangleFace()

triangleFace(): Uint32Array

Which face each triangle lies on, one per triangle: the same faces Solid.faceKind() names.

FemMesh.nodeKind()

nodeKind(): Uint32Array

What each node lies on — 0 a B-rep vertex, 1 an edge, 2 a face — one per node: the lowest-dimension entity it lies on, which is the .msh format's own classification rule. FemMesh.nodeEntity() says which entity of that kind.

FemMesh.nodeEntity()

nodeEntity(): Uint32Array

Which vertex, edge or face each node lies on, read by the matching FemMesh.nodeKind(): an index into FemMesh.vertices(), into FemMesh.edges(), or into the solid's faces.

FemMesh.faceCount

readonly faceCount: number

The solid's faces — the same faces Solid.faces counts.

FemMesh.edges()

edges(): FemEdge[]

One FemEdge per B-rep edge, in the order a FemMesh.nodeKind() of 1 indexes them. Not Solid.edges()' numbering: these are the manifold analysis's, ascending by edge id.

FemEdge

class FemEdge
id: number
nodes: Uint32Array
runs: Uint32Array
faces: [number, number]
ends: [number, number]
closed: boolean
seam: boolean
chains(): Uint32Array[]

One B-rep edge's chain of nodes, and where that chain breaks. nodes are this mesh's node indices in order along the edge, its end vertices included. runs says where the chain breaks: each entry is a start offset into nodes, and the nodes from one offset up to the next — the last offset running to the end — are a polyline of their own, with nothing joining across a boundary. The two ends either side of a boundary are two points of the edge with no mesh edge between them. (0,) is the ordinary answer, and a caller reading nodes as one polyline without looking here jumps the gap silently.

faces is (face_a, face_b) and ends is (end_a, end_b), the second of each a sentinel where there is none — an open sheet's rim, or both ends at one vertex. 0 is a real face and a real vertex, not a sentinel, and faces numbers the solid's faces as Solid.faceKind() does. closed where the nodes make one loop, never with more than one run; seam where one face bounds the edge twice, and both faces are then that same face.

id is the solid's own edge id, not this mesh's edge index: FemMesh.edges() is a densely renumbered subset of the solid's edges, with every edge collapsed to a point left out, so a sphere — whose two pole runs collapse — reports its seam as edge 0 with an id of 1. Everything else that names an edge means the index: a FemMesh.nodeKind() of 1 read through FemMesh.nodeEntity(), the third number of a FemMesh.openEdges() or FemMesh.foldedEdges() row, and the edge_<i> physical group of FemMesh.mshText(). It is not a row of Solid.edges() either, that table being the solid's edges grouped by geometry; the id names the topological edge, which is what the .msh entities and the censuses speak in.

FemMesh.vertices()

vertices(): FemVertex[]

One FemVertex per B-rep vertex, in the order a FemMesh.nodeKind() of 0 indexes them.

FemVertex

class FemVertex
node: number
point: Float64Array
hasPosition: boolean

One B-rep vertex: node is the mesh node there, a sentinel where the mesh has none, which is ordinary rather than a fault — the analysis rebuilds a vertex wherever two trims meet, so a sphere has 48 of them where the mesh has two points, and a caller walking these skips the sentinel instead of reading it as a gap.

point is where the topology says the vertex is, in the same space and under the same placement as FemMesh.nodes(). Meaningless unless has_position: it is all zeros then, a point no geometry has and one a solver would read as a node at the origin.

FemMesh.openEdges()

openEdges(): [number, number, number][]

Every crack, as (a, b, brep_edge): a directed mesh edge (a, b) with no (b, a), and the B-rep edge both nodes lie on where they share one.

Empty unless the solid's topology is closed, whose mesh is otherwise not asked about at all: an open sheet from Solid.face(), Solid.faceSheet(), Solid.dropFaces() or Solid.extrudeOpen() makes no claim to enclose anything, so its rim is not a crack. Such a solid reports FemMesh.watertight false with this and FemMesh.foldedEdges() both empty, and that trio of answers together is what says "not asked", not "nothing found".

That rule holds here without exception, where the reader library has one: every solid has a B-rep behind it, so this library has no mesh-only body whose census speaks from the triangles alone. See FemMesh.fromMesh.

FemMesh.foldedEdges()

foldedEdges(): [number, number, number][]

Every fold, as FemMesh.openEdges() reports a crack: a directed mesh edge used by more than one triangle, once.

A solid can be folded without being open — one no thicker than a line leaves no hole for an open edge to find — and the closure census's own known-bad bodies are folds rather than open cracks. A caller that checks FemMesh.openEdges() alone calls such a solid sound. Empty under the same rule as FemMesh.openEdges().

FemMesh.crossings()

crossings(): [number, number][]

Every pair of triangles that pass through each other, as (a, b) with a < b, sorted: an edge of one through the other's interior. Their B-rep faces are FemMesh.triangleFace() at a and b.

Computed for every solid, open or closed. FemMesh.watertight, FemMesh.openEdges() and FemMesh.foldedEdges() are topological and cannot see a surface passing through itself; a mesh is ready for a volume mesher when it is FemMesh.watertight and this is empty — Gmsh refuses one that crosses. A copy.

FemMesh.watertight

readonly watertight: boolean

The topology is closed and the welded mesh is too — every directed mesh edge paired with its reverse and none used twice. false for every solid whose topology is not closed; read FemMesh.openEdges() for what an empty census beside a false here does and does not mean.

Ready for a volume mesher means this and an empty FemMesh.crossings(): this census is topological and cannot see a surface passing through itself.

FemMesh.fromMesh

readonly fromMesh: boolean

Always false here, and kept so the two ABIs hand back one struct: a Solid always has a B-rep, so this library has no mesh-only body to report.

The reader's Node.femMesh() sets it for a node with no B-rep, where it also says which space the mesh is in — here there is only one space, the solid's own under the placement — and where a true means the crack census spoke from the triangles alone rather than from a topology. That second difference cannot arise on this side.

FemMesh.minAngle

readonly minAngle: number

The smallest interior angle of any triangle, in degrees. There is always one: a solid that meshed to no triangles is a refusal, not a mesh.

FemMesh.worstTriangle

readonly worstTriangle: number

The triangle with that angle, as an index into FemMesh.triangles().

FemMesh.longestEdge

readonly longestEdge: number

The longest triangle edge, placed. The figure to check against Solid.femMesh()'s max_size, and the only one that says what the mesh actually is. max_size bounds the boundary segments and merely targets the interior: measured at 1.03 x max_size on a face whose parameters run unevenly, where a full-size boundary piece met a much shorter one left by halving. One small enough beside the solid to reach the mesher's own piece and station ceilings is not honoured at all.

FemMesh.mshText()

mshText(): string

The mesh as Gmsh 4.1 ASCII .msh text: an entity per B-rep vertex, edge and face, a volume where the solid closes, and a physical group naming each.

Gmsh reads the file as written — measured with Gmsh 4.15: node and triangle counts equal to this mesh's, and a physical group per entity. To fill a closed solid with tetrahedra, give Gmsh a volume of its own over the file's surfaces. In its Python API: gmsh.open(path), then faces = [t for _, t in gmsh.model.getBoundary([(3, 1)], oriented=False)], gmsh.model.geo.addVolume([gmsh.model.geo.addSurfaceLoop(faces)]), gmsh.model.geo.synchronize() and gmsh.model.mesh.generate(3). A plain generate(3) leaves a volume read from any .msh file empty — Gmsh's own saved meshes too — and gmsh.model.mesh.createGeometry() re-meshes the surfaces rather than keeping these triangles.

Prefer Gmsh's HXT algorithm: gmsh.option.setNumber("Mesh.Algorithm3D", 10) before generate(3). On these surfaces the default left tetrahedra of exactly zero volume (four in a 100 mm bar), which no solver can use, and HXT's worst element came out far better on curved bodies (a minimum SICN of 0.1 to 0.3 where the default's was 0.001). Then name the tetrahedra before saving: HXT fills the new volume rather than the file's own, and gmsh.write keeps only elements in a physical group, so without this step every tetrahedron is dropped from the file without a word — filled = [t for _, t in gmsh.model.getEntities(3) if len(gmsh.model.mesh.getElementsByType(4, t)[0])], gmsh.model.removePhysicalGroups(gmsh.model.getPhysicalGroups(3)) and gmsh.model.addPhysicalGroup(3, filled, name="body"). The saved file also lists a few interior nodes no element uses — points Gmsh's refinement tried and gave up on — so a solver reading it should keep only the tetrahedra's own nodes: each unused one is an unconstrained unknown.

On this side of the ABI the library's text is owned and handed over, released by the wrapper (cadaclysm_blacksmith_string_free at the ABI) as every other text this library writes — Solid.stepText(), Solid.satText(), Solid.brepText(). Two asks give two independent texts, and neither dies with the handle. The reader library's own msh_text is the other way round: it borrows a slot on its handle, replaced by the next call and gone with the mesh. A reader porting one side's reasoning onto the other leaks or double-frees.

The unlicensed notice is printed here, on this writer and on FemMesh.saveMsh(), and not by Solid.femMesh(): meshing is not a licensed output and the .msh file is, which is where Solid.satText() and Solid.brepText() put theirs too. The reader library notices in its constructor instead and on neither .msh call; each matches its own siblings, so moving the call to look like the other side breaks a convention.

It throws BuildError for a mesh the writer refuses, naming the field it cannot honour, and for a freed handle.

FemMesh.saveMsh()

saveMsh(path: string): void

FemMesh.mshText() written to a path, replacing any file there. It throws BuildError for a mesh the writer refuses or a file it cannot write, naming the path. Prints the unlicensed notice; see FemMesh.mshText().

FemMesh.free()

free(): void

Give the mesh back, and with it every view taken from it. Idempotent; the collector or the scope does it otherwise.

There are no views to give back with it: every array this wrapper hands out is a copy (see nodes() above), so what free() ends is the handle and the calls that read through it — each of which throws fem mesh: freed afterwards. A second free() is a no-op, and the collector does it for a mesh you drop.

FemMesh.freed

readonly freed: boolean

Whether the mesh has been freed.

Tool

class Tool

A cutter: Grbl tool number (1 to 255, the T word), diameter and flute_length in mm, feed and plunge in mm/min, rpm its spindle speed, ramping into its cuts at ramp_angle degrees. Immutable; a job keeps its own copy.

Tool.flat()

static flat(number: number, diameter: number, fluteLength: number, feed: number, plunge: number, rpm: number, rampAngle?: number): Tool

A flat end mill. A number outside 1..255, a size, feed or speed not positive and finite, or a ramp_angle outside (0, 90], throws BuildError.

Tool.ball()

static ball(number: number, diameter: number, fluteLength: number, feed: number, plunge: number, rpm: number, rampAngle?: number): Tool

A ball end mill, as flat but its tip a half sphere of the diameter; in 2.5D it cuts where a flat does, bottom being the tip.

Tool.drill()

static drill(number: number, diameter: number, fluteLength: number, feed: number, rpm: number): Tool

A drill, plunging at feed. A job takes it for Job.drill() only.

Tool.number

readonly number: number

The Grbl tool number, 1 to 255 (the T word).

Tool.shape

readonly shape: 'flat' | 'ball' | 'drill' | 'vbit' | 'bullnose'

The cutting end: "flat", "ball", "drill", "vbit" or "bullnose" — spelled as a machining view's tool description spells it.

Tool.diameter

readonly diameter: number

The cutting diameter, in mm.

Tool.fluteLength

readonly fluteLength: number

How far up the cutting edge reaches from the tip, in mm.

Tool.angle

readonly angle: number | null

A V-bit's included angle, in degrees; null for every other shape.

Tool.cornerRadius

readonly cornerRadius: number | null

A bull-nose's corner radius, in mm; null for every other shape.

Stock

class Stock

The block of material a job cuts, an axis-aligned box. Immutable; a job keeps its own copy.

Stock.box()

static box(min: Point3, max: Point3): Stock

The box from min (x, y, z) to max. Unless every min is below its max and all six are finite, throws BuildError.

Stock.around()

static around(solid: Solid, margin?: number): Stock

solid's bounds grown by margin in -X, +X, -Y, +Y and +Z; the bottom stays at the solid's lowest Z. A margin negative or not finite throws BuildError.

Program

class Program

One file a job wrote: a Grbl program (tool its T number, name <job name>-T<n>, or <job name>-<k>-T<n> for a repeated tool) or, from Job.writeCamotics(), a simulation copy or the CAMotics project (tool 0). Read-only.

Program.tool

readonly tool: number

The program's Grbl T number, or 0 for a CAMotics project file.

Program.name

readonly name: string

The program's name without extension (<name>-T<n>, or <name>-<k>-T<n> for a repeated tool) from Job.gcode(); the file name from Job.writeCamotics().

Program.text

readonly text: string

The program's text.

Job

class Job

A machining job on a Stock: operations kept in the order they are added, written as one Grbl 1.1 program per run of operations sharing a tool. Mutable — each operation is added in place, and a refused one leaves the job as it was. safe_z is the absolute Z of rapids between operations and at a program's start and end, above the stock's top; an operation enters and leaves its passes clearance above its top; tolerance fits free-form sides and offsets; name names the programs (<name>-T<n>); every program waits spindle_dwell seconds after starting the spindle; resolution is the CAMotics project's voxel size in mm. A safe_z not above the stock, or a setting the job refuses, throws BuildError.

Job.face()

face(tool: Tool, z: number, stepover: number, stepdown: number): void

Face the stock's top down to z, in zigzag rows along X stepover apart and passes at most stepdown deep. A drill, a z above the stock's top, a stepover past the tool's diameter, or what the job otherwise refuses, throws BuildError.

Job.contour()

contour(tool: Tool, profile: Profile, top: number, bottom: number, side?: 'outside' | 'inside' | 'on', stepdown?: number, climb?: boolean, open?: boolean): void

Cut along profile from top to bottom in passes at most stepdown deep: side "outside" the profile, "inside" it, or "on" its line; climb for climb milling, else conventional; open to cut the outline as an open chain (only "on" its line, and with no holes). Any other side raises ValueError; what the job otherwise refuses, throws BuildError.

Job.pocket()

pocket(tool: Tool, profile: Profile, top: number, bottom: number, stepover: number, stepdown: number): void

Clear profile — its holes left standing as islands — from top to bottom, in rings stepover apart (at most the tool's radius) and passes at most stepdown deep. What the job refuses throws BuildError; a pocket too small for the tool is refused by Job.gcode(), naming the operation.

Job.drill()

drill(tool: Tool, points: Iterable<Point2>, top: number, bottom: number, peck?: number | null): void

Drill a hole at each (x, y) of points from top to bottom, pecking peck deep at a time (retracting between pecks), or straight to depth for none. A point that is not two numbers raises ValueError; a tool that is not a drill, no points, or what the job otherwise refuses, throws BuildError.

Job.gcode()

gcode(): Program[]

The job as Grbl 1.1 programs, one per run of consecutive operations sharing a tool (T1, T2, T1 gives three), each named <name>-T<n> (or <name>-<k>-T<n> for run k of a tool that runs more than once); an empty list for a job with no operations. An operation whose geometry the tool cannot cut (named by its index and kind) throws BuildError.

Job.writeCamotics()

writeCamotics(filePath: string): string[]

A CAMotics project at path and its files beside it, named after the project's file stem (out/part.camotics writes out/part-T1.nc), not the job's name: each program, a simulation copy of it (.sim.nc, which the project lists), and the project last. Creates the directory. Returns the paths written, the project last. A path with no file stem, what Job.gcode() refuses, or a file that cannot be written, throws BuildError.

Job.machine()

machine(part: Solid, endMill: Tool | (Tool | null)[], drills?: Tool | Iterable<Tool>, stepover?: number | null, stepdown?: number | null, skin?: number, peck?: number | null, cornerRelief?: boolean): Report

Recognise part — a solid inside the job's stock — by Z-level sectioning, and append the operations that make it: one face (if the stock top is above the part's top), the pockets level by level from the top down, then one drill per drill tool and bottom. end_mill must be a flat or ball tool, not a drill; drills are tried against each hole found, the closest match within 0.05 mm winning. end_mill may also be a list of end mills, largest first: the first clears as above, and each later one cleans only what the earlier ones left — inside corners, regions too narrow for them, and holes no drill matches — with pockets of its own after the earlier tools' and before the drills. Each later tool's stepover and stepdown default to its own; one given applies to the first and is clamped to each later tool's radius and flutes. The report then lists only what no end mill reached; a corner, or a region too narrow, names the smallest end mill that tried. stepover defaults to 0.4 x diameter, stepdown to min(diameter / 2, flute_length) (null asks for the kernel's own default for either); skin (at least 0, default 0.3) is how far above the part's lowest point the outline stops, so the part stays attached to the stock — 0 cuts through; corner_relief (default off) relieves every inside corner the smallest end mill leaves with a dog-bone: the cutter runs on along the corner's bisector until its edge touches the corner, notching both walls by r (1 - sin(θ/2)) for a corner of angle θ — 0.293 mm for a 2 mm end mill at a right angle. Each comes back as a relief item in place of its corner item: the vertex, the notch depth as size, the tool and Z range in reason, the notch as its region. Narrow regions, undercuts, holes and slopes are never relieved. peck is passed to every drill operation (null for none). Returns a Report of what could not be cut — nothing that would gouge is ever emitted; a feature the tools can't make is machined as far as possible and reported instead. The job changes only on success: what the kernel otherwise refuses (a drill as end_mill, a drills entry that isn't a drill, a tool number clashing with one already in the job, part outside the stock, a skin negative or not less than the part's height, no level found, a stepover or stepdown out of range, an empty list of end mills, one not smaller than the one before it, two sharing a number) throws BuildError and leaves the job exactly as it was.

Job.operations()

operations(): Operation[]

Every operation added to this job so far, in order — whether by Job.face(), Job.contour(), Job.pocket(), Job.drill() or Job.machine() — as a list of Operation.

Job.show

Play the job on its stock with the GPU view library, in the one shared window, from its start at real time, and return at once. The window's keys drive it — space plays or pauses, left and right step a move, up and down multiply the speed by 4 or divide it, Home and End seek the start and the end, L loops — and its title is the status line (move 370 of 638 · T1 flat 6 mm · X12.3 Y-4.0 Z7.0). part, a Solid, colours the stock by deviation from it. The terminal library cannot cut a stock and refuses. In the notebook, draw with show(job, part).

Not in this wrapper yet: play a job's programs with its View's machining view (show_machining in this wrapper's spelling) instead.

Job.view

Job.show in a fresh window that blocks until it is closed; returns the camera and the last pick, as Solid.view() does.

Not in this wrapper yet: play a job's programs with its View's machining view (show_machining in this wrapper's spelling) instead.

Job.stock

readonly stock: [[number, number, number], [number, number, number]]

The stock's box as the job holds it, ((min_x, min_y, min_z), (max_x, max_y, max_z)) — what Stock.box() was given, or what Stock.around() worked out.

[[minX, minY, minZ], [maxX, maxY, maxZ]].

Job.tools

readonly tools: Map<number, Tool>

The tools this job was given — by Job.face(), Job.contour(), Job.pocket(), Job.drill() and Job.machine() (the end mill and drills its operations use; it refuses two different tools offered under one number) — by Grbl number, so a Program's tool finds its tool. A refused call adds none. A new mapping each time.

A Map from number to Tool, a new one each time.

Report

interface Report extends ReadonlyArray<ReportItem>

What Job.machine() could not make: a read-only sequence of ReportItem, in the order found, read once when machine returns. len(report) counts the items, it iterates and indexes them, and str(report) is the kernel's own text — one line per item, or "nothing left uncut"; bool(report) is true when it has items.

Report item

class ReportItem

One thing Job.machine() left uncut, one of Report's items. Read-only.

ReportItem.kind

readonly kind: string

"corner" (material the end mill doesn't reach), "hole" (a round hole no drill matches or a matched drill can't make), "slope" (a face that is neither horizontal nor vertical, cut as steps), "undercut" (material under an overhang), "too_deep" (a level below the end mill's flute length, cut only that far) or "relief" (an inside corner cut beyond the part on purpose — a dog-bone, corner_relief).

ReportItem.at

readonly at: number[]

The item's XYZ location — a centroid for an area, the axis point at the top for a hole.

ReportItem.size

readonly size: number

An area in mm^2 for corner/undercut, a diameter in mm for hole, a height in mm (its Z range) for slope and too_deep, and the notch depth in mm for relief.

ReportItem.reason

readonly reason: string

One sentence naming the cause and the tool involved.

ReportItem.top

readonly top: number

The highest Z the item stands at: a corner's or undercut's band top, a hole's top, a slope's top, or for too_deep the flutes' reach.

ReportItem.bottom

readonly bottom: number

The lowest Z the item stands down to: the floor a corner or undercut reaches, a hole's floor, a slope's foot, or for too_deep the level.

ReportItem.region

readonly region: Profile[]

The XY area the item covers, as a list of Profile: a corner's or undercut's piece, a hole's disc, the area a slope's face covers, or for too_deep the reachable area cut short (the whole stock when it is the part's top).

Operation

class Operation

One operation of a Job, read back by Job.operations(). Read-only.

Operation.kind

readonly kind: string

"face", "contour", "pocket" or "drill".

Operation.tool

readonly tool: number

Its Grbl T number.

Operation.params

readonly params: Record<string, number | string | boolean | null>

A dict of the operation's own arguments, in the kind-specific order it stores them — z, top, bottom, stepover, stepdown, side, climb, open, peck and the point count, with a profile summarised by its bounds. side reads as "outside"/"inside"/"on"; climb and open as a bool; points as an int; a NaN peck as null; every other value stays a float.

Sketches

class Sketch

A 2D sketch of points, lines, circles, arcs and free curves (Bezier, conic, NURBS), held by geometric constraints and dimensions and solved on request — the sketcher a parametric part starts from. Draw roughly, constrain, Sketch.solve(), then hand Sketch.profiles() to Solid.extrude() or any other verb that takes a Profile.

Entities and constraints are named by integer ids, which are never reused. Entity kinds are "point", "line", "circle", "arc" and "free_curve"; a constraint's kind is the name of the method that added it ("point_line_distance", ...), but for Sketch.radiusOf(), whose kind is "radius". Lengths are the kernel's own unitless numbers, angles radians. A sense is "auto" (taken from the geometry when the constraint is added), "positive" (a line and a circle: the centre on the left of the line, from its first point to its second; two circles: touching from outside) or "negative" (the centre on the right; one circle inside the other); an end is "start" or "end".

A constraint that conflicts with the ones already there is refused when it is added, the refusal naming the constraints it fights, so a sketch is never left over-constrained by an edit; a redundant one (already implied) is kept and reported by Sketch.diagnose(). An edit that will not converge (Sketch.setValue(), Sketch.setDriving()) rolls the sketch back to where it was. Close it when done, or let the language's scope do it; see Lifetimes.

In Python an unknown sense or end name raises ValueError; every other wrapper raises its kernel error.

Sketch.fromProfile()

static fromProfile(profile: Profile, infer?: boolean, tolerance?: number): Sketch

A sketch of profile's lines, arcs and curves, joined end to end by coincident constraints, holes included. With infer (the default) it also adds every constraint the geometry already meets within tolerance — horizontal and vertical lines, tangent joints, concentric arcs, equal radii — so the profile comes back as a sketch a designer can dimension. Ends within tolerance (1e-6 by default) count as joined.

Sketch.close()

close(): void

Free this handle now. The garbage collector, or the language's scope, does it otherwise.

Sketch.addPoint()

addPoint(x: number, y: number): number

A free point at (x, y): its id. A coordinate that is not finite throws BuildError.

Sketch.addLine()

addLine(a: number, b: number): number

A line from the point a to the point b: its id. Refused for ids that are not two distinct points.

Sketch.addCircle()

addCircle(centre: number, r: number): number

A circle of radius r about the point centre: its id. Refused for a radius that is not positive and finite.

Sketch.addArc()

addArc(centre: number, start: number, end: number): number

A counter-clockwise arc about the point centre from the point start to the point end: its id. Its radius is start's distance from centre; end is held on that circle by the solve, not moved there now. The three must be different points.

Sketch.addBezier()

addBezier(start: number, c1: Point2, c2: Point2, to: Point2): number

A cubic Bezier free curve from the point start through the controls c1 and c2 (each an (x, y) pair) to a new end point at to: its id. The curve owns its control and end points (Sketch.ends() lists them), which constraints and drags move like any other point.

Sketch.addConic()

addConic(start: number, control: Point2, to: Point2, weight: number): number

A rational quadratic (conic) free curve from the point start with the control control of weight to a new end point at to: its id. A weight below 1 is an ellipse's arc, 1 a parabola, above 1 a hyperbola.

Sketch.addNurbs()

addNurbs(start: number, points: Iterable<Point2>, knots: ArrayLike<number>, degree?: number, weights?: ArrayLike<number> | null): number

A NURBS free curve of degree (3 by default) from the point start through the control points after it, on knots: its id. weights is null for a plain B-spline, or one per control point counting the start (one more than points holds); any other count, a negative degree, or knots that do not fit the points and the degree, throws BuildError.

degree and weights take null for their defaults (3, and none).

Sketch.addRect()

addRect(a: Point2, b: Point2): [number[], number[]]

The rectangle with opposite corners a and b, as two lists: its four corner points, counter-clockwise from a, and its four sides (side i runs from corner i to corner i + 1). Its sides come held level and plumb by two horizontal and two vertical constraints, so a fix and two lengths constrain it fully.

a and b are [x, y] arrays; returns [corners, sides], two arrays of four ids.

Sketch.kind()

kind(id: number): SketchEntityKind

The kind of entity id: "point", "line", "circle", "arc" or "free_curve". An unknown or removed id throws BuildError.

Sketch.entities()

entities(): number[]

The live entity ids, ascending.

Sketch.point()

point(id: number): [number, number]

The point id's position, as an (x, y) pair. Not a point, throws BuildError.

Sketch.setPoint()

setPoint(id: number, x: number, y: number): void

Moves the point id to (x, y) without solving — a raw write, as loading a saved sketch does.

Sketch.radius()

radius(id: number): number

The radius of the circle or arc id. (The RADIUS dimension is Sketch.radiusOf().)

Sketch.setRadius()

setRadius(id: number, r: number): void

Sets the circle id's radius to r without solving. Refused for an arc, whose radius its points set, and for a radius that is not positive and finite.

Sketch.centre()

centre(id: number): number

The centre point of the circle or arc id.

Sketch.ends()

ends(id: number): number[]

The points entity id runs between: a line's [a, b], an arc's [start, end], a free curve's [start, controls..., end]. Refused for a point or a circle.

Sketch.setConstruction()

setConstruction(id: number, on?: boolean): void

Marks entity id as construction geometry (on, the default) or back: still solved and constrained, but never part of Sketch.profiles() or Sketch.openChains().

Sketch.isConstruction()

isConstruction(id: number): boolean

Whether entity id is construction geometry (false for an unknown id).

Sketch.isReference()

isReference(id: number): boolean

Whether entity id is a reference copy of another sketch's, made by Sketch.reference() (false for an unknown id).

Sketch.removeEntity()

removeEntity(id: number): number[]

Removes entity id, each of its points no other entity uses, and every constraint on any of them: the removed constraint ids, ascending. A point a line, circle, arc or curve still uses is refused, throws BuildError naming those entities. Nothing is solved.

Sketch.reference()

reference(other: Sketch, entity: number): number

A fixed construction copy of other's entity entity in this sketch, its id: something to dimension against that this sketch's solve never moves. Sketch.updateReference() re-reads it. other must be a different sketch.

Sketch.updateReference()

updateReference(id: number, other: Sketch): SolveReport

Re-reads the reference id from other (where other's solve has moved it) and re-solves this sketch, as a SolveReport.

Sketch.coincident()

coincident(a: number, b: number): number

The points a and b at one place. Each constraint method returns the new constraint's id, and refuses one that conflicts with the sketch, throws BuildError.

Sketch.pointOnLine()

pointOnLine(point: number, line: number): number

The point point on the line line, taken as infinite.

Sketch.pointOnCircle()

pointOnCircle(point: number, circle: number): number

The point point on the circle circle, or on an arc's whole circle.

Sketch.horizontal()

horizontal(a: number, b: number): number

The points a and b level with each other (one y).

Sketch.vertical()

vertical(a: number, b: number): number

The points a and b one above the other (one x).

Sketch.parallel()

parallel(a: number, b: number): number

The lines a and b parallel, either way round.

Sketch.perpendicular()

perpendicular(a: number, b: number): number

The lines a and b at right angles.

Sketch.collinear()

collinear(a: number, b: number): number

Line b's two ends on line a, taken as infinite.

Sketch.tangent()

tangent(a: number, b: number, sense?: SketchSense): number

A line and a circle or arc, or two circles or arcs, tangent; sense picks the side ("auto": the side they are on now). Where the two meet end to end — the ends one point, or held together by a coincident when the tangent is added — it is held at that joint instead, their directions there running on smoothly, and sense plays no part (Sketch.isJointTangent()).

Sketch.tangentAtEnd()

tangentAtEnd(curve: number, other: number, end?: SketchEnd): number

The free curve curve's handle at its end ("start" or "end") along other when that is a line, or square to its radius at the curve's end when it is a circle or an arc.

Sketch.concentric()

concentric(a: number, b: number): number

The circles or arcs a and b about one centre.

Sketch.equalLength()

equalLength(a: number, b: number): number

The lines a and b the same length.

Sketch.equalRadius()

equalRadius(a: number, b: number): number

The circles or arcs a and b the same radius.

Sketch.midpoint()

midpoint(point: number, line: number): number

The point point at the middle of the line line.

Sketch.symmetric()

symmetric(a: number, b: number, about: number): number

The points a and b mirror images of each other across the line about.

Sketch.fix()

fix(entity: number): number

Every parameter of entity held where it is now: a point's position, a circle's centre and radius, ...

Sketch.distance()

distance(a: number, b: number, value: number, driving?: boolean): number

The points a and b value apart. Every dimension takes driving: true (the default) sets the geometry, false only reports what it measures (Sketch.measure()), never conflicting.

Sketch.pointLineDistance()

pointLineDistance(point: number, line: number, value: number, driving?: boolean, sense?: SketchSense): number

The point point value from the line line (taken as infinite), on the side sense says.

Sketch.lineDistance()

lineDistance(a: number, b: number, value: number, driving?: boolean, sense?: SketchSense): number

Line b's start value from line a, on the side sense says — with Sketch.parallel(), the gap between two lines. It is measured from the second line's start point, not from the line as a whole.

Sketch.circleLineDistance()

circleLineDistance(circle: number, line: number, value: number, driving?: boolean, sense?: SketchSense): number

The circle circle's rim value from the line line (its centre's distance less the radius), on the side sense says.

Sketch.circleDistance()

circleDistance(a: number, b: number, value: number, driving?: boolean): number

The circles a and b value apart rim to rim: their centres' distance less both radii, negative where they overlap.

Sketch.horizontalDistance()

horizontalDistance(a: number, b: number, value: number, driving?: boolean): number

b's x less a's, signed, equal to value.

Sketch.verticalDistance()

verticalDistance(a: number, b: number, value: number, driving?: boolean): number

b's y less a's, signed, equal to value.

Sketch.length()

length(line: number, value: number, driving?: boolean): number

The line line value long.

Sketch.angle()

angle(a: number, b: number, value: number, driving?: boolean): number

The angle counter-clockwise from line a's direction to line b's, value radians.

Sketch.radiusOf()

radiusOf(circle: number, value: number, driving?: boolean): number

The circle or arc circle's radius value: the RADIUS dimension, kind "radius", named apart from Sketch.radius(), which reads a radius.

Sketch.diameter()

diameter(circle: number, value: number, driving?: boolean): number

The circle or arc circle's diameter value.

Sketch.smooth()

smooth(a: number, b: number): number

Two curves joined end to end with matching tangent and curvature (G2): each a line, an arc or a free curve, at least one a free curve, meeting at an end (one point, or held together by a coincident). A free curve must be clamped at that end; two arcs, or a line and an arc, are refused, as there is no curvature to match. Kind "smooth".

Sketch.translated()

translated(a: number, b: number, from: number, to: number): number

The point b held at the point a moved by the step from the point from_ to the point to (b - a = to - from_): what a rectangular pattern holds each copied point with. Kind "translated".

Sketch.rotated()

rotated(a: number, b: number, centre: number, from: number, to: number): number

The point b held at the point a turned about the point centre by the turn that takes from_ to to: what a circular pattern holds each copied point with. from_ or to the same point as centre is refused. Kind "rotated".

Sketch.addPolygon()

addPolygon(centre: Point2, vertex: Point2, sides: number): SketchPolygon

A regular polygon of sides (3 to 1024) about the point centre, its corner 0 at vertex, as a SketchPolygon: the sides held equal, with a construction circumcircle through the corners and a construction incircle tangent to side 0, both about the one centre point. Four degrees of freedom are left (centre, size, rotation); dimension either circle to size it. centre and vertex must be apart. A refusal leaves the sketch as it was.

Sketch.chamfer()

chamfer(a: number, b: number, da: number, db: number): SketchChamfer

Cuts the corner where the lines a and b meet, da along a and db along b from the corner, as a SketchChamfer. The two lines are trimmed to the new ends and a new line joins them; the old corner stays as a construction point (the virtual sharp, on both lines) with the two distances as driving dimensions, so the degrees of freedom are unchanged. The lines must meet at an end and not be parallel, neither a reference, each distance positive and shorter than its line, and no tangent or smooth held at that end. A length dimension on a trimmed line now measures the trimmed line. A refusal, or a solve that fails, leaves the sketch as it was.

Sketch.chamferAngle()

chamferAngle(a: number, b: number, da: number, angle: number): SketchChamfer

As Sketch.chamfer(), with da along a and angle (radians) the interior angle at the new point on a between a and the chamfer; the second dimension is that angle. The angle must leave a chamfer shorter than b allows.

Sketch.patternRectangular()

patternRectangular(entities: Iterable<number>, d1: Point2, n1: number, d2?: Point2, n2?: number): SketchPattern

Copies entities (any kinds) into a grid of n1 by n2 instances, the source counted, d1 and d2 each an (x, y) step, as a SketchPattern. Each copied point is held to the one before it by Sketch.translated(); the first step along each direction is set by driving horizontal and vertical distances, so set_value on one respaces the whole grid and a fully constrained sketch stays so. Construction flags are copied. n1, n2 at least 1, n1 * n2 at least 2 and at most 10 000 instances; an entity dead or given twice is refused, and the sketch left as it was.

Sketch.patternCircular()

patternCircular(entities: Iterable<number>, centre: number, count: number, step: number): SketchPattern

Copies entities round the point centre: count instances (at least 2, the source counted), each turned step radians counter-clockwise from the last, as a SketchPattern. Each copied point is held by Sketch.rotated(); two construction lines from the centre and a driving angle dimension carry the step, so set_value on it respaces the copies. A first point of the source on centre, or a step of 0, is refused and the sketch left as it was.

Sketch.autoConstrain()

autoConstrain(tolerance?: number, dimensions?: boolean): number[]

Adds the constraints the geometry already satisfies within tolerance (0 or null takes 1e-6 of the sketch's extent), as the new constraint ids, ascending: coincident ends, horizontal and vertical lines, tangents at joined ends, parallel, perpendicular, concentric, equal radius and length, midpoints and points on lines and circles. A candidate is kept only where it removes a degree of freedom without being redundant or conflicting. With dimensions, driving dimensions at the measured values follow (radii, lengths, angles, an anchor and the distances to it) until nothing is left free. One diagnosis runs per candidate: fine for hand-sized sketches. A failed solve leaves the sketch as it was.

Sketch.constraints()

constraints(): number[]

The live constraint ids, ascending.

Sketch.constraintKind()

constraintKind(id: number): SketchConstraintKind

The kind of constraint id, e.g. "point_line_distance". An unknown or removed id throws BuildError.

Sketch.constraintRefs()

constraintRefs(id: number): number[]

The entity ids constraint id was made on, in the order they were given.

Sketch.constraintValue()

constraintValue(id: number): number | null

The value of the dimension id; null for a constraint that is not a dimension. An unknown id throws BuildError.

Sketch.constraintDriving()

constraintDriving(id: number): boolean

Whether the dimension id drives the geometry; false for a constraint that is not a dimension. An unknown id throws BuildError.

Sketch.constraintSense()

constraintSense(id: number): SketchSense

The sense of constraint id as the sketch holds it, "auto" resolved to the side it took; "auto" for a kind without one.

Sketch.constraintEnd()

constraintEnd(id: number): SketchEnd

The end ("start" or "end") of the free curve a Sketch.tangentAtEnd() constraint id holds; "start" for a kind without one. An unknown id throws BuildError.

Sketch.isJointTangent()

isJointTangent(id: number): boolean

Whether the tangent id is held at a joint (two curves meeting end to end) rather than as a touch; false for any other constraint.

Sketch.remove()

remove(id: number): void

Removes the constraint id. Nothing is solved; a joint tangent the removed coincident held goes back to a touch.

Sketch.setValue()

setValue(id: number, value: number): SolveReport

Sets the dimension id to value and re-solves, as a SolveReport. One that will not converge is refused, throws BuildError, and the sketch is left as it was.

Sketch.setDriving()

setDriving(id: number, driving: boolean): SolveReport

Makes the dimension id drive the geometry (true) or only report it, and re-solves, as a SolveReport. Made driving, it first takes the value it measures now, so nothing moves; one that would conflict is refused and the sketch left as it was.

Sketch.measure()

measure(id: number): number

What the geometry measures for the dimension id right now, driving or not.

Sketch.solve()

solve(): SolveReport

Solves the sketch, as a SolveReport. Each independent part is solved alone, every point moving as little as it can; a part that conflicts or does not converge is put back where it was and named in the report — reported, not raised.

Sketch.drag()

drag(moves: Map<number, Point2> | Record<number, Point2>): SolveReport

Drags each point id in moves (a mapping of id to (x, y)) towards its target while the constraints hold, as a pointer drag does, as a SolveReport: the dragged points go where they can and everything else moves as little as it can; a fully constrained point stays put. An id that is not a point throws BuildError. The moves are sent in ascending id order, whatever order they are given in, and an id given twice is refused where the language can hold one (sketch_drag: point <id> given twice).

moves is a Map or a plain object of point id to its [x, y] target; neither can repeat an id.

Sketch.diagnose()

diagnose(): Dof

The sketch's degrees of freedom, as a Dof: whole and per independent part.

Sketch.profiles()

profiles(tolerance?: number): Profile[]

The closed loops among the solved, non-construction curves, as Profile values of exact segments (lines, arcs, the free curves' own shapes); a loop inside another becomes its hole. Ends within tolerance (1e-6 by default) join.

Sketch.openChains()

openChains(tolerance?: number): Profile[]

The chains of curves that do not close, as open Profile values — sweep paths; ends within tolerance join.

SolveReport

class SolveReport

What a Sketch.solve(), Sketch.drag(), Sketch.setValue(), Sketch.setDriving() or Sketch.updateReference() did, as plain data.

SolveReport.status

status: SketchStatus

"converged", "conflicting" (constraints that cannot all hold) or "diverged" (no solution found within the iteration budget). The library hands the number back as a double and every wrapper converts it exactly: a value that is not a whole number in range is an error naming the call, never a status.

SolveReport.converged

readonly converged: boolean

Whether status is "converged".

SolveReport.iterations

iterations: number

The most solver iterations any one part took (each part is solved alone).

SolveReport.maxResidual

maxResidual: number

The largest constraint residual left, scaled by the sketch's size; 0 when nothing was left to solve.

SolveReport.ids

ids: number[]

The constraints a conflict ran into, or the worst ones of a diverged solve; empty when it converged.

Dof

class Dof

A sketch's degrees of freedom, as Sketch.diagnose() returns them: plain data, read after a solve. A sketch is "under" constrained while something can still move, "full" when nothing can and nothing fights, "over" when constraints fight.

Dof.free

free: number

How many degrees of freedom are left: the unknowns less the rank of the constraint equations. The counts arrive as doubles and are converted exactly: a value that is not a whole number in range is an error naming the call, never a state.

Dof.state

state: SketchState

"under", "full" or "over".

Dof.redundant

redundant: number[]

The constraint ids already implied by earlier ones — harmless, kept.

Dof.conflicting

conflicting: number[]

The constraint ids that fight earlier ones.

Dof.freeEntities

freeEntities: number[]

The entity ids that can still move, ascending (references never).

Dof.parts

parts: PartDof[]

The independent parts the sketch splits into, as PartDof values: each solved, and dragged, alone.

PartDof

class PartDof

One independent part of a diagnosed sketch — constraints and the unknowns they share, solved apart from the rest: one of Dof.parts. Plain data.

PartDof.params

params: number

How many unknowns the part has.

PartDof.free

free: number

How many of them stay free.

PartDof.state

state: SketchState

"under", "full" or "over".

PartDof.constraints

constraints: number[]

The constraint ids in the part, in the order they were added.

PartDof.redundant

redundant: number[]

Its constraints already implied by earlier ones.

PartDof.conflicting

conflicting: number[]

Its constraints that fight earlier ones.

PartDof.freeEntities

freeEntities: number[]

Its entities that can still move; a curve whose points lie in two parts may be in both.

Garments

A garment: patterns (a closed outline, a fabric, a grain and a seam allowance, placed by a frame), the seams that sew arc-length ranges of two patterns together, and the fabrics, with CLO-compatible parameters — the flat pattern a cloth simulation starts from. Lengths are millimetres in the session API. Patterns, seams and fabrics are named by integer ids, which are never reused. A fabric is twenty numbers in the order of Garment.FABRIC_FIELDS (stretch_warp, ..., internal_damping); a notch kind is NOTCH_SLIT, NOTCH_V, NOTCH_T, NOTCH_CASTLE or NOTCH_U; an internal line is LINE, FOLD or DART.

A refused call raises the kernel's error with the call's name first (garment_add_seam: unknown pattern 9). The lists the library lends are copied before a call returns, so they survive later edits. Close it when done, or let the language's scope do it; see Lifetimes.

A garment is also a Document node's value: garment.fabric, garment.pattern, garment.seam and garment.garment nodes evaluate to one, read with Document.resultGarment.

Not in this wrapper yet.

Garment.FABRIC_PARAMS

How many numbers a fabric has: 20.

Not in this wrapper yet.

Garment.FABRIC_FIELDS

The names of a fabric's twenty parameters, in order: stretch_warp, stretch_weft, shear_left, shear_right, bending_warp, bending_weft, bending_bias_left, bending_bias_right, the four buckling_ratio_*, the four buckling_stiffness_*, density, thickness, friction and internal_damping.

Not in this wrapper yet.

Garment.fromAama

A garment read from AAMA DXF text: its patterns over one fabric, id 0, called "imported", with all-zero parameters. Text that is not AAMA DXF throws BuildError.

Not in this wrapper yet.

Garment.close

Free this handle now. Leaving a with block or the garbage collector does the same.

Not in this wrapper yet.

Garment.addFabric

A fabric called name with its twenty parameters, as a list in FABRIC_FIELDS order or a dict keyed by those names: its id. A negative parameter is reported by Garment.validate.

Not in this wrapper yet.

Garment.fabricParams

Fabric fabric's twenty parameters, in FABRIC_FIELDS order. An unknown id throws BuildError.

Not in this wrapper yet.

Garment.fabricName

Fabric fabric's name. An unknown id throws BuildError.

Not in this wrapper yet.

Garment.fabrics

The live fabric ids, ascending.

Not in this wrapper yet.

Garment.addPattern

A pattern called name over the closed outline (its holes are kept), with the grain direction (x, y), a fabric id, a layer (stacking order) and the seam allowance: one width for every side, or one per side. Its id. The pattern starts on the origin, flat. An unknown fabric or an allowance count that fits neither throws BuildError; a zero grain is reported by Garment.validate.

Not in this wrapper yet.

Garment.patternName

Pattern pattern's name.

Not in this wrapper yet.

Garment.patternOutline

Pattern pattern's outline, as a new Profile.

Not in this wrapper yet.

Garment.patternInfo

Pattern pattern's (grain_x, grain_y, fabric, layer).

Not in this wrapper yet.

Garment.patternAllowance

Pattern pattern's seam allowances, one per side.

Not in this wrapper yet.

Garment.patternFrame

The frame pattern pattern is placed by: its origin, then its x, y and z axes, as four points.

Not in this wrapper yet.

Garment.patternSetFrame

Places pattern pattern by frame: twelve numbers, the origin then the x, y and z axes.

Not in this wrapper yet.

Garment.patternSetWrap

Wraps pattern pattern round a cylinder: seven numbers, the axis origin, the axis direction and the radius. null clears the wrap.

Not in this wrapper yet.

Garment.patternAddNotch

Adds a notch to pattern pattern at arc length at, of kind (Garment.NOTCH_*) and depth. An arc length outside the outline is reported by Garment.validate; a position or depth that is not finite throws BuildError.

Not in this wrapper yet.

Garment.patternNotches

Pattern pattern's notches, as (at, kind, depth) triples.

Not in this wrapper yet.

Garment.patternAddInternal

Adds an internal line to pattern pattern: kind (LINE, FOLD or DART), path a Profile read as an open path: the profile's segments are copied as given (a closed profile keeps its closing segment); holes are ignored.

Not in this wrapper yet.

Garment.removePattern

Removes pattern pattern and every seam that names it.

Not in this wrapper yet.

Garment.patterns

The live pattern ids, ascending.

Not in this wrapper yet.

Garment.addSeam

Sews pattern a between arc lengths a_from and a_to to pattern b between b_from and b_to, reversed when one runs against the other: its id. An unknown pattern throws BuildError.

Not in this wrapper yet.

Garment.seam

Seam seam read back, as a GarmentSeam.

Not in this wrapper yet.

Garment.removeSeam

Removes seam seam.

Not in this wrapper yet.

Garment.seams

The live seam ids, ascending.

Not in this wrapper yet.

Garment.validate

Checks the garment, measuring outlines to accuracy (a fraction in (0, 1), 0.01 by default), and returns the issues found as Issue values, an empty list for a garment that is clean. Any edit afterwards clears them.

Not in this wrapper yet.

Garment.issue

Issue index of the last Garment.validate, as an Issue. Before a validation, or past the last issue, throws BuildError.

Not in this wrapper yet.

Garment.cutLine

Pattern pattern's cut line (the outline offset by its allowance) flattened to tolerance (0.1 by default), as (x, y) points.

Not in this wrapper yet.

Garment.rangePoints

The points of pattern pattern's outline between arc lengths start and end, flattened to tolerance (0.1 by default), as (x, y) points.

Not in this wrapper yet.

Garment.toAama

The patterns as AAMA DXF text, curves flattened to tolerance (0.1 by default), with author in the header when given. The text is written as metric, so a garment from a non-millimetre document must be converted to millimetres first.

Not in this wrapper yet.

Issue

One thing Garment.validate found, as a named tuple. severity is Garment.ERROR or Garment.WARNING; kind what was found (Garment.SEAM_OVERLAP, Garment.SEAM_LENGTH_MISMATCH, ...); ratio the length ratio of a seam length mismatch, null for every other kind; message the issue in words, naming the parts.

Not in this wrapper yet.

GarmentSeam

A seam read back by Garment.seam, as a named tuple: pattern a's arc-length range a_from to a_to sewn to pattern b's b_from to b_to, reversed when one range runs against the other.

Not in this wrapper yet.

Cloth

A cloth: a Garment simulated on an avatar. The garment's patterns are meshed and arranged round the avatar; each step then sews and drapes at once: the seam pairs pull together and weld while gravity pulls the cloth down. Gravity acts from the first frame, so a garment is usually sewn with it off and draped after: create the cloth with gravity=(0, 0, 0) (in C, the options gravity.x, gravity.y and gravity.z, indices 4 to 6, at 0), step about 60 frames until status().welded_pairs reaches status().seam_pairs, then set_options back to the defaults and step on to drape. Units are grams, millimetres and seconds, as the garment's.

avatar is None (no body: the cloth only falls), the bytes of a binary or ASCII STL file, or (positions, indices): xyz triples and index triples. options overrides Cloth.default_options() by the kernel's own names. The cloth does not keep the garment: a later edit to it changes nothing until Cloth.remeshPattern. Close it when done, or let the language's scope do it; see Lifetimes.

The options are twenty numbers, in the order of Cloth.OPTION_FIELDS: particle_distance, frame_dt, substeps, iterations, gravity.x, gravity.y, gravity.z, damping, local_damping, air_drag, air_lift, air_density, sewing_stiffness, sewing_speed, weld_distance, avatar_thickness, self_thickness, self_stiffness, self_collision and drag_stiffness. The gravity components are the dotted names gravity.x, gravity.y and gravity.z; options and set_options also take all three as one gravity=(x, y, z), as in set_options(gravity=(0, 0, 0)) (not both spellings at once). particle_distance is the mesh spacing in mm and is fixed once the cloth exists. self_thickness is the *minimum* contact thickness of the cloth against itself: a fabric thicker than it separates at its own thickness, a thinner one at this, and it must stay below weld_distance so that seams still close.

A blown-up simulation does not raise: read Cloth.status. non_finite counts the particles whose position or velocity is not finite, dropped the self-collision elements that were too large or not finite to be hashed, and max_speed is the fastest finite particle in mm/s; a healthy cloth has non_finite and dropped at zero.

The lists the library lends (positions, triangles, links) are borrowed from the cloth in the C ABI and stay valid only until the next call on the same cloth; this wrapper copies them before a call returns, so they survive step and Cloth.remeshPattern, which can change the vertex and triangle counts: read the lists again afterwards. A refused call raises the kernel's error with the call's name first (cloth_pin: vertex 9999 is not a sim vertex (2731 vertices)).

On the GPU: in the browser, a WebGPU View steps a cloth on the graphics card and writes its vertices straight into what it draws — showCloth(cloth) shows and uploads it, stepCloth(id, frames) steps it, clothPositions(id) and clothHealth(id) read it back (promises), and pinCloth, unpinCloth, dragCloth and setClothOptions edit it; clothGpu is false on WebGL2, where the cloth stays on the CPU. Not in this wrapper yet: the GPU cloth is the web View's only, the View's C ABI and the other wrappers come later. The GPU steps the cloth without the intersection analysis that untangles a cloth caught through itself: showCloth uploads it with the analysis off, whatever the cloth's options; the analysis on the GPU comes later.

Not in this wrapper yet.

Cloth.OPTION_FIELDS

The names of the twenty options, in order: particle_distance, frame_dt, substeps, iterations, gravity.x, gravity.y, gravity.z, damping, local_damping, air_drag, air_lift, air_density, sewing_stiffness, sewing_speed, weld_distance, avatar_thickness, self_thickness, self_stiffness, self_collision and drag_stiffness.

Not in this wrapper yet.

Cloth.STATUS_FIELDS

The names of ClothStatus's eight fields, in order: frame, vertices, triangles, seam_pairs, welded_pairs, non_finite, dropped and max_speed.

Not in this wrapper yet.

Cloth.close

Free this handle now. Leaving a with block or the garbage collector does the same.

Not in this wrapper yet.

Cloth.defaultOptions

The options a new cloth starts with, as a dict keyed by OPTION_FIELDS name: particle_distance, frame_dt, substeps, iterations, gravity.x, gravity.y, gravity.z, damping, local_damping, air_drag, air_lift, air_density, sewing_stiffness, sewing_speed, weld_distance, avatar_thickness, self_thickness, self_stiffness, self_collision and drag_stiffness.

Not in this wrapper yet.

Cloth.options

The cloth's current options, keyed as Cloth.defaultOptions.

Not in this wrapper yet.

Cloth.setOptions

Merges changes (by option name, or gravity as one (x, y, z), as in set_options(gravity=(0, 0, 0))) into the current options. particle_distance cannot change, and a refused set (an unknown name, a self_thickness or fabric thickness that is not below weld_distance) throws BuildError and leaves the options as they were.

Not in this wrapper yet.

Cloth.step

Advances the simulation by frames frames (1 by default), each frame_dt seconds, sewing and draping together under the current options (sew with gravity off first: see Cloth). Check Cloth.status afterwards for a blow-up.

Not in this wrapper yet.

Cloth.status

The simulation's state, as a ClothStatus.

Not in this wrapper yet.

Cloth.positions

The current position of every sim vertex, in mm, as (x, y, z) triples. A copy.

Not in this wrapper yet.

Cloth.rest

Each sim vertex's arranged starting position in 3D, in mm, as (x, y, z) triples. A copy.

Not in this wrapper yet.

Cloth.triangles

The sim mesh's triangles, as triples of vertex indices into Cloth.positions.

Not in this wrapper yet.

Cloth.vertexPatterns

The id of the garment pattern each sim vertex belongs to. Every sim vertex keeps its own pattern: a weld across a seam merges the two vertices' particles, not the vertices.

Not in this wrapper yet.

Cloth.pin

Pins vertex v at at (x, y, z in mm), or where it is now when null. A pinned vertex does not move until Cloth.unpin. An unknown vertex throws BuildError.

Not in this wrapper yet.

Cloth.unpin

Releases vertex v's pin. An unknown vertex throws BuildError.

Not in this wrapper yet.

Cloth.drag

Pulls vertex v towards target (x, y, z in mm) with the drag_stiffness spring; null releases the drag. An unknown vertex throws BuildError.

Not in this wrapper yet.

Cloth.remeshPattern

Meshes pattern pattern of garment again after its outline changed there, keeping the rest of the cloth where it is. The vertex and triangle counts may change: read the lists again. An unknown pattern throws BuildError.

Not in this wrapper yet.

ClothStatus

The state of a simulation, as Cloth.status returns it, a named tuple: the frame count, the sim vertices and triangles, the seam_pairs in the sim mesh and the welded_pairs closed so far (sewing is done when welded_pairs == seam_pairs), then the health: non_finite live particles (a position or velocity that is not finite), dropped (the most hash elements one self-collision gather dropped during the last step, which only a blown-up state produces) and max_speed, the fastest finite particle, in mm/s. The counts are converted exactly; a cloth is healthy when non_finite and dropped are both zero.

Not in this wrapper yet.

Errors

class BuildError extends Error

What the kernel refused, in its own words: a profile that crosses itself, a fillet too large for its faces, a boolean with nothing left. Raised by the call that failed, at once.

BuildError.ids

ids: number[]

The ids a Sketch refusal names, as a list: the constraints a new constraint, value or reference conflicts with (Sketch.coincident() and the other constraint methods, Sketch.setValue(), Sketch.setDriving(), Sketch.updateReference()), or the entities still using a point (Sketch.removeEntity()). Empty when the refusal names none, and for every error outside a sketch — so a sketcher's interface can mark the clash without reading the text.

Lifetimes

What borrows, what to close

scene.close() and solid.close(), or using where the runtime supports explicit resource management; a finalizer frees what is forgotten. The …Async twins run the slow calls on a worker thread.

Node.mesh() and Node.edges() hand back fresh typed arrays, decoded out of the scene's memory at call time rather than views into it: koffi.decode allocates a Float32Array of its own. Measured — two asks give two buffers, each exactly its own length, and a write into one is invisible to the other — so an array in hand survives Scene.forgetMeshes(), Scene.close() and the collector, with nothing of the library's left in it to go stale. Nothing here needs a slice() to outlive its owner, and the price runs the other way: every ask copies again, so hold the array rather than asking twice in a loop. Solid.mesh() is the same over the solid's cache, so meshing the solid again at another tolerance cannot stale a copy already handed back, and FemMesh's arrays are copies of its own memory in just the same way.

Strings are always copied on the way out and outlive everything. One scene or solid may be read from several threads; closing it while another thread reads it is the caller's to prevent.