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 drawing paths, the first step of a 2D DXF export.
The shape is seen along Y: X stays X and Z becomes the drawing's Y (-Z under right-handed
conventions). Curves stay exact unless exactCurves is off. Give the paths a layer with
dxfPathsWithLayer and write them with dxfCreate.
The shape and the deflection settings
The DXF paths
Puts drawing paths on a named layer with a color and a line type, making one part of a drawing.
A drawing may hold several parts, each with its own layer, color and line type; dxfCreate
writes them into one file.
The paths, the layer name, the color and the line type
The paths as one layered part
Writes drawing parts into one DXF file and returns its text.
acadVersion AC1015 (AutoCAD 2000) keeps every curve exact and can state the drawing's unit;
AC1009 (R12) suits old software and writes splines and ellipses as polylines within
curveTolerance. fileName and tryDownload matter only where a browser download can start.
The layered parts, the color format, the DXF version, the unit, the curve tolerance and the download options
The DXF file as text
Reads a DXF file into one compound of exact wires, fit-point splines interpolated and block inserts expanded.
It lies on the ground, Y along Z (-Z under right-handed conventions) and elevations along Y.
Ends within joinTolerance join; makeFaces makes faces with holes. A very large file is
read up to its limits; loadDxfStructured lists what was left out.
The DXF file and the reading options
One compound holding every layer's wires, and faces when asked
Reads a DXF file as loadDxf does, into one shape per layer, color and line type, each with
its layer name, color and line type, plus the file's unit, its version and what was left out.
Use it to treat the layers apart, such as outlines to cut on one layer and lines to engrave on another.
The DXF file and the reading options
The shapes with their layers, colors and line types, the unit, the version and the warnings
Writes a shape as STEP, the exchange format for exact CAD geometry, and starts a browser download of the file.
With adjustYtoZ true the file is Z-up: with the conventions set it shows what the screen
shows, without them Y and Z are swapped. The file is in millimetres;
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 the file is Z-up, as CAD programs expect: with the conventions set it
shows what the screen shows, and without them Y and Z are swapped. 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 and binary writes the smaller binary
form. With the conventions set the file shows what the screen shows, Z-up with adjustYtoZ.
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 read, returning its
text, or its bytes when binary is true.
precision is the meshing tolerance in model units, smaller following curves more closely.
With the conventions set the file shows what the screen shows, Z-up with adjustYtoZ.
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. With the conventions set the file shows
what the screen shows, Z-up with adjustYtoZ. The file name may hold no spaces or slashes;
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 and coordinates keep six decimals. With
the conventions set the file shows what the screen shows, Z-up with adjustYtoZ. 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. With the conventions set the file shows
what the screen shows, Z-up with adjustYtoZ. 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. With the conventions set the file shows
what the screen shows, Z-up with adjustYtoZ.
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; curves stay
exact where SVG can draw them. 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. Curves stay exact
where SVG can draw them, others become cubics within precision; with the shape's unit, the
file states its true size.
The shape, the view, whether to draw hidden edges, the precision, the unit and the download options
The SVG file as text
Draws the edges a view of a shape sees as a DXF drawing, hidden ones on their own layer 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 every
curve exact. saveShapeDxfAndReturn gives the text instead.
The shape, the view, whether to draw hidden edges, the precision, the unit, the version and the download options
Nothing; the download starts when the file is ready
Draws the edges a view of a shape sees as DXF, hidden ones on their own layer when asked, and returns the file's text.
The view looks from the frame's normal side, x along the frame's direction. Curves stay exact;
hidden edges go on the layer hidden with the HIDDEN line type.
The shape, the view, whether to draw hidden edges, the precision, the unit, the version and the download options
The DXF 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
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, and the shape comes back in unit, scaled from
the file's own. A file that cannot be read gives undefined.
The file, the axis adjustment and the unit
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, and the shape comes back in unit, scaled from
the file's own. Text that cannot be read gives undefined.
The file text, its format, the axis adjustment and the unit
The loaded shape
Puts shapes on a named layer with a color and a line type, making one layer of an SVG drawing.
The shapes are kept as they are; svgCreate draws their wires when it writes the file.
The shapes, the layer name, the color and the line type
The shapes as one styled layer
Draws layers of shapes into one SVG file and returns its text.
Each layer becomes an Inkscape layer. The shapes are seen along Y: X stays X and Z becomes the
drawing's Y (-Z under right-handed conventions). Curves stay exact where SVG can draw them and
become cubics within tolerance elsewhere; with unit the file has its true size.
The layers, the unit, the line width, the border, the tolerance and the download options
The SVG file as text
const cut = await bitbybit.occt.io.svgLayer({ shapes: [outline], layer: "cut", color: "#ff0000" });
const engrave = await bitbybit.occt.io.svgLayer({ shapes: [lettering], layer: "engrave", color: "#0000ff" });
const svg = await bitbybit.occt.io.svgCreate({ layers: [cut, engrave], unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre, fileName: "panel.svg", tryDownload: false });
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.