Skip to main content
OCCT category icon with a stylized logo representation

Importing STEP and IGES

STEP and IGES are the two exchange formats CAD systems agree on. Both describe exact geometry rather than a mesh, so what you get back is a real solid you can cut, fillet and measure, not a triangulated approximation.

Four extensions, two shapes of data​

ExtensionFormatData
.step, .stpSTEPtext
.iges, .igsIGEStext
.stpzSTEPcompressed, binary
.igzIGEScompressed, binary

The compressed variants are ordinary STEP and IGES run through zip. They are common when a file is emailed or downloaded, because the text forms are large.

Compressed files must be handed over as binary. Read the file as an ArrayBuffer or a Uint8Array rather than as text. Reading a compressed file as text corrupts it before the importer ever sees it, because the bytes are not valid text.

Uncompressed STEP and IGES can be passed as text, which is usually the simpler path.

Passing a file from a browser​

If you have a File from an upload input, or a Blob, read it before you pass it in:

  • await file.text() for uncompressed STEP or IGES
  • await file.arrayBuffer() for the compressed .stpz and .igz forms, or when you would rather not think about which you have

Handing a File or Blob straight to the importer does not work. Reading one is asynchronous, and the importer is not, so the conversion has to happen on your side first.

Standing the model up​

CAD systems commonly treat Z as up, while Bitbybit treats Y as up. A model imported from such a system therefore arrives lying on its side.

The adjustZtoY option corrects that as part of the import. Turn it on for a file that came out of a CAD package, and leave it off for one that was written by Bitbybit.

Lengths arrive in your unit​

A STEP or IGES file states the unit its lengths are in, and programs differ: millimetres are the most common, inches the next. bitbybit.occt.io.loadSTEPorIGES and loadSTEPorIGESFromText scale whatever the file holds into the unit you ask for, millimetres by default, so a part drawn in inches arrives at its true size in a model built in millimetres. Choose inches as the unit to work in inches instead; the choices are millimetres, centimetres, metres and inches.

To know what a file is written in before you build anything, bitbybit.occt.io.fileLengthUnit reads its unit without building its geometry. It takes the file's text or its bytes, the compressed forms included, and a fileName whose extension says whether it is STEP or IGES. It tells millimetres, centimetres, metres and inches apart, and gives undefined for a file in another unit, one whose parts disagree, or one that states none.

Writing a shape back out works the other way round: unit says what the shape's numbers are, and the file is always written in millimetres (Getting a model out).

This example needs no file of your own: it writes one with bitbybit.occt.io.saveShapeSTEPAndReturn and reads the text back. The part is modelled in inches, four long, and unit says so. The file is written in millimetres, which is what fileLengthUnit reports. Read in that unit, the part comes back 101.6 long. Read in inches, it comes back at four, shown small beside it. adjustYtoZ on the way out and adjustZtoY on the way in stand it back up:

A part sent out as STEP and read back
Bitbybit Platform

A part sent out as STEP and read back in Rete

rete logoRete
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"box": {
"id": "box",
"name": "bitbybit.occt.shapes.solid.createBox",
"customName": "box",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"width": 4,
"length": 2,
"height": 1,
"center": [
0,
0.5,
0
],
"originOnCenter": true
},
"inputs": {},
"position": [
40,
40
]
},
"part": {
"id": "part",
"name": "bitbybit.occt.fillets.filletEdges",
"customName": "fillet edges",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 0.3
},
"inputs": {
"shape": {
"connections": [
{
"node": "box",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
40
]
},
"file": {
"id": "file",
"name": "bitbybit.occt.io.saveShapeSTEPAndReturn",
"customName": "save shape step and return",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"fileName": "part.step",
"adjustYtoZ": true,
"fromRightHanded": false,
"tryDownload": false,
"unit": "in"
},
"inputs": {
"shape": {
"connections": [
{
"node": "part",
"output": "result",
"data": {}
}
]
}
},
"position": [
880,
40
]
},
"fileUnit": {
"id": "fileUnit",
"name": "bitbybit.occt.io.fileLengthUnit",
"customName": "file length unit",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"fileName": "part.step"
},
"inputs": {
"filetext": {
"connections": [
{
"node": "file",
"output": "result",
"data": {}
}
]
}
},
"position": [
1300,
40
]
},
"readInFileUnit": {
"id": "readInFileUnit",
"name": "bitbybit.occt.io.loadSTEPorIGESFromText",
"customName": "load step or iges from text",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"text": "",
"fileType": "step",
"adjustZtoY": true,
"unit": "mm"
},
"inputs": {
"text": {
"connections": [
{
"node": "file",
"output": "result",
"data": {}
}
]
},
"unit": {
"connections": [
{
"node": "fileUnit",
"output": "result",
"data": {}
}
]
}
},
"position": [
1720,
40
]
},
"drawLarge": {
"id": "drawLarge",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw any async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"entity": {
"connections": [
{
"node": "readInFileUnit",
"output": "result",
"data": {}
}
]
}
},
"position": [
2140,
40
]
},
"readInInches": {
"id": "readInInches",
"name": "bitbybit.occt.io.loadSTEPorIGESFromText",
"customName": "load step or iges from text",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"text": "",
"fileType": "step",
"adjustZtoY": true,
"unit": "in"
},
"inputs": {
"text": {
"connections": [
{
"node": "file",
"output": "result",
"data": {}
}
]
}
},
"position": [
1300,
288
]
},
"beside": {
"id": "beside",
"name": "bitbybit.occt.transforms.translate",
"customName": "translate",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"translation": [
70,
0,
0
]
},
"inputs": {
"shape": {
"connections": [
{
"node": "readInInches",
"output": "result",
"data": {}
}
]
}
},
"position": [
1720,
380
]
},
"view": {
"id": "view",
"name": "bitbybit.babylon.scene.adjustActiveArcRotateCamera",
"customName": "adjust active arc rotate camera",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"position": [
17,
140,
-184
],
"lookAt": [
11,
12,
0
],
"lowerBetaLimit": 1,
"upperBetaLimit": 179,
"angularSensibilityX": 1000,
"angularSensibilityY": 1000,
"maxZ": 1000,
"panningSensibility": 1000,
"wheelPrecision": 3
},
"inputs": {},
"position": [
2140,
334
]
}
},
"modules": {}
}

A file that cannot be read gives you nothing​

If the importer cannot build a model, you get nothing back rather than an empty shape, and the reason is written to the console.

This is worth knowing because a file can be readable without being usable: it parses as valid STEP or IGES, but contains nothing the kernel can turn into geometry. That case reports as a failure too. If you get nothing back, the file is the place to look, not your script.