Part details including id, shape, name, and optional color
Part definition that can be added to an assembly structure
Create an assembly node definition (a container for other nodes). Assembly nodes group instances and other assemblies together in the hierarchy.
Assembly node details including id, name, and optional parent
Node definition that can be added to an assembly structure
Create an instance node definition (a reference to a part with transform). Instance nodes place a part at a specific location with optional translation, rotation, and scale.
Instance node details including id, partId, name, and transform
Node definition that can be added to an assembly structure
Create a part update definition for modifying an existing part in a document. Part updates can change the shape, name, and/or color of an existing part.
Update details including label and optional new shape/name/color
Part update definition that can be added to an assembly structure's partUpdates array
// Get existing parts from document
const parts = await occt.assembly.query.getDocumentParts({ document });
// Create a new shape to replace the old one
const newBox = await occt.shapes.solid.createBox({ width: 20, length: 20, height: 20 });
// Create an update definition
const update = await occt.assembly.manager.createPartUpdate({
label: parts[0].label,
shape: newBox,
name: "Bigger Box",
colorRgba: { r: 0, g: 1, b: 0, a: 1 }
});
// Combine with structure and rebuild
const structure = await occt.assembly.manager.combineStructure({ parts: [], nodes: [], partUpdates: [update] });
await occt.assembly.manager.buildAssemblyDocument({ structure, existingDocument: document });
Combine parts and nodes into a complete assembly structure definition. This is the final step before calling buildAssemblyDocument.
Lists of parts and nodes to combine
Complete assembly structure ready for building
Build an assembly document from a structure definition. Returns the document handle directly - document stays in worker memory.
This is the recommended approach for creating assemblies:
If existingDocument is provided and valid, the document will be cleared and updated instead of creating a new one. This is useful for updating an assembly without allocating a new document each time.
Assembly structure definition and optional existing document
The document handle (reference to worker-side document, new or updated)
// Create new document
const structure = await occt.assembly.manager.combineStructure({ parts, nodes });
const document = await occt.assembly.manager.buildAssemblyDocument({ structure });
// Update existing document (reuses same handle)
const updatedStructure = await occt.assembly.manager.combineStructure({ parts: newParts, nodes: newNodes });
await occt.assembly.manager.buildAssemblyDocument({ structure: updatedStructure, existingDocument: document });
// Cleanup
await occt.assembly.manager.deleteDocument({ document });
Load a STEP file into a new assembly document. Supports both regular STEP and gzip-compressed STEP-Z.
STEP file data (as string, ArrayBuffer, Uint8Array, File, or Blob)
The document handle (reference to worker-side document)
Export an assembly document to STEP format.
Export options including document, fileName, author, organization
STEP file content as Uint8Array
Export an assembly document to glTF binary (GLB) format.
Export options including document and mesh settings
GLB content as Uint8Array
Delete an assembly document and release its memory. Call this when done with the document to free resources.
Document to delete
Set the color of a label in the document. Colors are preserved when exporting to STEP and other formats.
Document, label, and RGBA color values
true on success, false on failure
Set or change the name of a label (part, instance, or assembly).
Document, label, and new name
true on success, false on failure
Create a part definition for use in assembly structures. This is a helper for visual programming - it simply wraps the inputs into a part object.