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. fileName and tryDownload matter
only where a browser download can be started.
The layered parts, the color format, the DXF version and the download options
The DXF file as text
Writes a shape as STEP, the standard exchange format for exact CAD geometry, and starts a browser download of the file.
With adjustYtoZ true, Y and Z swap, which mirrors the shape; to keep it as built, turn it 90
degrees about X with transforms.rotate first. fileName names the download, tryDownload
false skips it, and saveShapeSTEPAndReturn gives the text instead.
The shape, the file name, the axis adjustment and the download options
Nothing; the download starts when the file is ready
Writes a shape as STEP, the standard exchange format for exact CAD geometry, and returns the file's text.
With adjustYtoZ true, Y and Z swap so Y-up becomes STEP's Z-up, which mirrors the shape;
turn it 90 degrees about X with transforms.rotate first to keep it as built. fileName and
tryDownload matter only where a browser download can be started.
The shape, the file name, the axis adjustment 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 running right along its direction.
tryDownload false skips the download; saveShapeSvgAndReturn gives the text instead.
The shape, the view, whether to draw hidden edges, the precision and the download options
Nothing; the download starts when the file is ready
Draws the edges a view of a shape sees as an SVG drawing, with the hidden edges dashed when asked, and returns the file's text.
It shows the view from the frame's normal side in model units, x running right along the frame's direction and y up, so the file holds each point as x and minus y.
The shape, the view, whether to draw hidden edges, the precision and the download options
The SVG file as text
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
Reads a STEP or IGES file, given as a File, into one shape.
The file's extension decides the kind: .step, .stp are STEP, .iges, .igs are IGES.
adjustZtoY turns the file's Z-up into Y-up. A file that cannot be read gives undefined.
The file and the axis adjustment
The loaded shape
Reads a STEP or IGES file, given as its text, into one shape; fileType says which of the
two formats the text is in.
adjustZtoY turns the file's Z-up into Y-up. Text that cannot be read gives undefined.
The file text, its format and the axis adjustment
The loaded shape
Reading and writing CAD files with OCCT: everything
iooffers on the kernel, plus loaders that take a STEP or IGES file as a File object or as its text and give back a shape. Files are Z-up by convention, soadjustZtoYturns the loaded shape to this library's Y-up unless it is set false.