Converts a STEP file into a binary glTF (GLB), keeping the assembly tree as glTF nodes along with part names, colors, materials and placements.
stepData is the file as text, ArrayBuffer or Uint8Array. The mesh settings say how finely
curved surfaces are triangulated: meshPrecision is the deflection, meshAngle the angular
deflection. Z-up becomes glTF's Y-up. Failure throws.
The STEP file content and the meshing settings
The GLB file as bytes
Converts a STEP file into a binary glTF (GLB) like convertStepToGltf, with every option
exposed.
The read flags choose what to take from the file (colors, names, materials, layers, properties), the mesh settings how finely to triangulate, the export settings how the glTF is written (merged faces, 16-bit indexes, naming, scale). Switch off what you do not need.
The STEP file content and the reading, meshing and export settings
The GLB file as bytes
const options = new Bit.Inputs.OCCT.ConvertStepToGltfAdvancedDto();
options.stepData = stepText;
options.readColors = true;
options.readNames = true;
options.meshDeflection = 0.005;
options.mergeFaces = true;
options.adjustZtoY = true;
const glb = await bitbybit.occt.io.convertStepToGltfAdvanced(options);
Converts a STEP file into a binary glTF (GLB) like convertStepToGltf and compresses the
geometry with Draco, which makes the file much smaller at the cost of a Draco-capable loader.
The Draco settings set the compression level and how many bits positions, normals, texture coordinates and colors keep; fewer bits mean a smaller file and less precision.
The STEP file content, the meshing settings and the Draco settings
The GLB file as bytes
Converts a STEP file into a binary glTF (GLB) with every reading, meshing and writing option
exposed, as convertStepToGltfAdvanced does, and compresses the geometry with Draco.
The Draco settings set the compression level and how many bits positions, normals, texture coordinates and colors keep; fewer bits mean a smaller file and less precision.
The STEP file content, the reading, meshing and export settings, and the Draco settings
The GLB file as bytes
Reads the assembly structure of a STEP file without building geometry: every part and sub-assembly as a node with its id, name, whether it is an assembly, its visibility, its color and its placement matrix.
The nodes come in depth-first order, so children follow their parent. A file that cannot be parsed reports its error in the result.
The STEP file content
The list of nodes, the format version and any error
Turns the wires of a shape into DXF path records, the first step of a 2D DXF export.
The shape must lie flat on the XZ ground plane, since DXF drawings are two-dimensional. The
deflection settings say how closely curved edges are followed. Give the paths a layer with
dxfPathsWithLayer and write the file with dxfCreate.
The shape and the deflection settings
The DXF paths
Puts DXF paths on a named layer with a color, making one part of a DXF drawing.
A drawing may hold several parts, each with its own layer and color; dxfCreate writes them
into one file.
The paths, the layer name and the color
The paths as one layered part
Writes DXF parts into one DXF file and returns its text.
colorFormat chooses AutoCAD's indexed colors or true color, acadVersion the DXF version:
AC1009 is R12, the most widely readable, AC1015 is 2000, which can also state the drawing's
unit. fileName and tryDownload matter only where a browser download can be started.
The layered parts, the color format, the DXF version, the unit and the download options
The DXF file as text
Writes a shape as STEP, the exchange format for exact CAD geometry, and starts a browser download of the file.
With adjustYtoZ true, Y and Z swap, mirroring the shape; turn it 90 degrees about X with
transforms.rotate first to keep it as built. The file is in millimetres, another unit
scaled to them; saveShapeSTEPAndReturn returns the text.
The shape, the file name, the axis adjustment, the unit and the download options
Nothing; the download starts when the file is ready
Writes a shape as STEP, the exchange format for exact CAD geometry, and returns its text.
With adjustYtoZ true, Y and Z swap so Y-up becomes STEP's Z-up, mirroring the shape; turn it
90 degrees about X with transforms.rotate first to keep it as built. The file is in
millimetres, a shape in another unit scaled to them.
The shape, the file name, the axis adjustment, the unit and the download options
The STEP file as text
Triangulates a shape, writes it as STL, the mesh format 3D printers read, and starts a browser download of the file.
precision is the meshing tolerance in model units, adjustYtoZ swaps Y and Z, which
mirrors the shape, and binary writes the smaller binary form. fileName names the
download, tryDownload false skips it. saveShapeStlAndReturn gives the file instead.
The shape, the file name, the meshing precision, the axis adjustment, the form and the download options
Nothing; the download starts when the file is ready
Triangulates a shape and writes it as STL, the mesh format 3D printers and slicers read,
returning the file's text, or its bytes when binary is true.
precision is the meshing tolerance in model units; smaller values follow curved surfaces
more closely. adjustYtoZ swaps Y and Z, which mirrors the shape. fileName and
tryDownload matter only for a download.
The shape, the file name, the meshing precision, the axis adjustment, the form and the download options
The STL file as text, or as bytes when binary is true
const stl = await bitbybit.occt.io.saveShapeStlAndReturn({ shape: box, fileName: "box.stl", precision: 0.01, adjustYtoZ: true, tryDownload: false });
const bytes = await bitbybit.occt.io.saveShapeStlAndReturn({ shape: box, fileName: "box.stl", precision: 0.01, adjustYtoZ: true, tryDownload: false, binary: true });
Writes a shape as BREP, the text format that keeps its exact geometry and topology, and starts a browser download of the file.
io.loadBrep reads the file back into the same shape. fileName names the download and
tryDownload false skips it; saveShapeBrepAndReturn gives the text instead.
The shape, the file name and the download option
Nothing; the download starts when the file is ready
Writes a shape as BREP, the text format that keeps its exact geometry and topology, and returns the file's text.
io.loadBrep reads the text back into the same shape, placement and orientation included.
fileName and tryDownload only matter where a download can start.
The shape, the file name and the download option
The BREP file as text
Writes a shape as binary BREP, the exact geometry and topology saveShapeBrep writes as text,
in bytes, and starts a browser download of the file.
io.loadBrepBinary reads the file back into the same shape. fileName names the download and
tryDownload false skips it; saveShapeBrepBinaryAndReturn gives the bytes instead.
The shape, the file name, the download option and whether to keep the mesh
Nothing; the download starts when the file is ready
Writes a shape as binary BREP, the exact geometry and topology saveShapeBrep writes as text,
in bytes, and returns them.
io.loadBrepBinary reads them back with every face and edge at the same index.
withTriangulation false leaves out the mesh.
The shape, the file name, the download option and whether to keep the mesh
The binary BREP file's bytes
Triangulates a shape, writes it as OBJ, the mesh format most 3D programs read, and starts a browser download of the file.
precision is the meshing tolerance in model units and adjustYtoZ swaps Y and Z, which
mirrors the shape. The file name may hold no spaces or slashes; tryDownload false skips the
download, and saveShapeObjAndReturn gives the text instead.
The shape, the file name, the meshing precision, the axis adjustment and the download option
Nothing; the download starts when the file is ready
Triangulates a shape and writes it as OBJ, the mesh format most 3D programs read, returning the file's text.
precision is the meshing tolerance in model units, adjustYtoZ swaps Y and Z, which
mirrors the shape, and coordinates keep six decimals. mtl stays empty, since a shape
carries no colors; assembly.manager.exportDocumentToObj writes colored parts.
The shape, the file name, the meshing precision, the axis adjustment and the download option
The OBJ text, with an empty material library text
Triangulates a shape, writes it as ASCII PLY with a normal per vertex, and starts a browser download of the file.
precision is the meshing tolerance in model units and adjustYtoZ swaps Y and Z, which
mirrors the shape. fileName names the download and tryDownload false skips it;
saveShapePlyAndReturn gives the text instead.
The shape, the file name, the meshing precision, the axis adjustment and the download option
Nothing; the download starts when the file is ready
Triangulates a shape and writes it as ASCII PLY with a normal per vertex, a mesh format scanning tools read, returning the file's text.
Coordinates keep six significant digits, so past 1000 units they keep two decimals.
precision is the meshing tolerance in model units and adjustYtoZ swaps Y and Z, which
mirrors the shape.
The shape, the file name, the meshing precision, the axis adjustment and the download option
The PLY file as text
Draws the edges a view of a shape sees as an SVG drawing, with the hidden edges dashed when asked, and starts a browser download of the file.
The drawing shows the view from the frame's normal side, x along its direction; with the shape's
unit, it states its true width and height. saveShapeSvgAndReturn gives the text instead.
The shape, the view, whether to draw hidden edges, the precision, the unit and the download options
Nothing; the download starts when the file is ready
Draws the edges a view of a shape sees as SVG, hidden ones dashed when asked, and returns the file's text.
The view looks from the frame's normal side, x along the frame's direction and y up, so each
point is written as x and minus y. With the shape's unit, it states its true width and
height.
The shape, the view, whether to draw hidden edges, the precision, the unit and the download options
The SVG file as text
Reads the unit a STEP or IGES file writes its lengths in, without building its geometry.
Millimetres, centimetres, metres and inches are told; a file in another unit, one whose parts
disagree, or one that states none gives undefined. io.loadSTEPorIGES reads any of them into
the unit it is asked for.
The file content and its name with extension
The file's unit, or undefined when it is none of these or cannot be told
Reads an STL file, ASCII or binary, into a shape: one planar face per triangle, or one face that carries the whole mesh.
With asFaces true the faces share their corners' edges in a compound that
shapeFix.sewWithReport can join into a shell. adjustZtoY turns Z-up into Y-up, and a file
without triangles is refused.
The STL file, the face option and the axis adjustment
A compound of triangular faces, or one face that carries the mesh
Reads a BREP file, the text format that keeps a shape's exact geometry and topology, back into
the shape io.saveShapeBrep wrote.
The shape keeps its placement and orientation. Text that is not a whole BREP file, such as one cut short, is refused, and so is a damaged one, with where it is damaged.
The BREP file
The shape the file holds
Reads a binary BREP file, the bytes io.saveShapeBrepBinary writes, back into the shape it
holds, with its faces and edges in the same order.
The bytes are checked first: damaged ones, or ones not in version 4, are refused, saying where.
The binary BREP file
The shape the file holds
Reading and writing OpenCascade shapes in exchange formats: STEP, IGES, STL and BREP in; STEP, STL, BREP, OBJ, PLY, SVG and DXF out; STEP to glTF conversion with the assembly tree, colors and names preserved, and a STEP assembly structure as JSON. Files travel as text or binary data, never as paths. OpenCascade treats Z as up while this library treats Y as up, so the
adjustYtoZandadjustZtoYflags swap the axes on the way out and in.