The command-line converter
Convert STEP files to GLB without opening the viewer. How to run step2glb.py, and what every option does.
The converter is a Python script, step2glb.py. The app runs it for you when you drop a STEP file on the window. You can also run it yourself in a terminal, for example to convert many files, or to use options the import window does not show.
You never need this page to use the app. It is here for when you want more control.
Before you start
- Start the app once with its launcher, so the Python environment exists. See Start it the first time.
- Open a terminal in the app folder. On Windows: open the folder in File Explorer, click the address bar, type
cmdand press Enter. On macOS: open Terminal, typecdand a space, drag the app folder onto the window, and press Enter. - Switch on the app’s Python environment. This makes the command
pythonuse the add-ons the launcher installed. On Windows, type the first command below. On macOS, type the second.
.venv\Scripts\activatesource .venv/bin/activateConvert a file
python step2glb.py input.stepReplace input.step with the path of your file. The result is written next to it, with the same name and the ending .glb. The terminal prints what the converter is doing.
Examples
python step2glb.py input.step --quality 0.2 --min-size 0.5- A finer tessellation, and parts smaller than 0.5% of the model left out.
python step2glb.py input.step --relative- Quality as a fraction of the size of each edge, so it does not depend on the file’s units.
python step2glb.py input.step --meshopt- Compress the result with gltfpack.
python step2glb.py input.step --simplify 0.5- Also halve the triangle count. Lossy.
python step2glb.py input.step --no-colors --no-instance- The plain reader: no colours, no instancing.
python step2glb.py input.step --out small.glb --target-tris 200000- Adjust the quality automatically until the result has at most 200,000 triangles.
python step2glb.py a.step b.step c.step- Convert several files, one after the other.
Input and output
input- One or more STEP, IGES or BREP files.
--out,-o- The file to write. Only with a single input file. Without it, the GLB is written next to the input.
--force- Convert again even if an output that is newer than the input already exists. Without it, the converter skips a file that was already converted with the same settings.
Mesh quality
--quality,-q- How closely the triangles follow the true surface (the linear deflection). Smaller is finer and heavier. The default is 0.5, in the units of the file, normally millimetres.
--relative- Reads
--qualityas a fraction of each edge’s own size (OpenCascade’s relative deflection) instead of an absolute distance: short edges get a finer mesh, long ones a coarser one. --angular- The angular deflection, in radians: a second limit on how coarsely curved surfaces are cut into triangles. The default is 0.5, about 28.6°.
--tiers- Tessellate by part size. Give the two limits between small, medium and large parts, in percent of the size of the whole model, then a quality in millimetres and an angle in degrees for small, for medium and for large parts. For example
--tiers 5,30:2,60:0.2,30:0.05,10. --min-edge- The smallest triangle edge the mesher may make, in the units of the file. It stops tiny fillets and threads from filling up with slivers. The default, 0, is no limit.
--size-cap- A part’s quality is never coarser than this share of its own diagonal, so small round parts are not left polygonal. The default is 0.002 (0.2 %). 0 turns it off. It is ignored with
--relativeand--tiers. --grid- Mesh curved faces along their own directions: a fillet in even strips, a curved panel in a grid, not a scatter of triangles. The import window calls it Even strips.
--no-surfaces- Leave out the parts that are surfaces only (open shells) and keep the solids.
--brep- Also write the CAD faces and the true CAD edges beside the GLB (
<name>.glb.brep.jsonand.brep.bin), which the viewer uses for CAD edit. --no-normals- Do not write the normals of the CAD surfaces into the GLB. The viewer then works out the shading from the triangles. Without this option the normals are written, which is what makes fillets blend smoothly into the faces beside them.
--swap-yz- Turn the model a quarter turn about the X axis, for a Z-up CAD file that should stand in a Y-up scene.
--min-size- Leave out parts whose size is below this percentage of the model’s diagonal. The default, 0, keeps everything.
Budgets
--target-tris- Adjust
--qualityautomatically to land at or under this triangle count. The conversion is run again up to five times. --target-size-mb- The same, for the size of the output file in megabytes. With both set, the tighter one wins.
Repeated parts
--no-instance- Do not collapse identical shapes into instances. According to the README, it only has an effect together with
--no-colors. --pca-instances- An experimental, more aggressive way to find repeated shapes. It can turn symmetric parts the wrong way.
Colours, names and the tree
--no-colors- Use the plain reader: geometry only, no colours, names or hierarchy. The fastest.
--force-colors- Always read colours, names and the hierarchy. Without this option, the converter skips them for files over 1 GB.
--no-shuo- Skip per-instance colour overrides. A big saving in time on assemblies with many repeated parts.
--no-layers- Skip the CAD layers. With them read, each part carries the names of its layers into the GLB, where the app shows them and selects by them.
--no-materials- Skip material information.
--no-step-names- Skip product names. Parts get generic names in the tree.
--no-step-props- Skip validation properties such as mass and area.
--props- Work out the volume and surface area of every solid. Slow on big files.
--split-colours- A body whose faces carry several colours becomes one piece per colour, open along the colour seams, instead of one body with several materials.
--no-extras- Do not write the CAD information (names, assembly path, colour, part number, layers, material, volume and area) into the GLB.
Compression and reduction
These options use gltfpack, a separate free tool that has to be installed and on your PATH. Without it they are skipped, with a warning.
--meshopt- Compress the GLB with Meshopt, for files roughly ten times smaller. This is on by default whenever gltfpack is found.
--no-meshopt- Switch that default off.
--quantize- Store positions, normals and texture coordinates as smaller numbers.
--simplify- Keep this fraction of the triangles, between 0 and 1. 0.5 halves the count. Sharp edges are preserved. Lossy. It switches Meshopt on.
Speed
--parallel- Use this many worker processes for building the meshes in the plain reader (see
--no-colors). The default, 0, does one at a time. --mesh-jobs- Use this many worker processes to mesh the parts when colours and names are read, which is the normal case. Without it the app chooses by the size of the model: under 5,000 CAD faces everything is meshed in one process, above that in up to eight processes, half the cores of the computer.
0or1meshes in one process. It has no effect together with--brepor--split-colours.
Several files and levels of detail
--batch- Convert every STEP, IGES and BREP file in this folder with the options given, one process per file, so a file that fails does not stop the rest. It prints a table, writes
batch-report.csv, and exits with 1 if any file failed. With--out, that is the folder the GLB files go to. --recursive- With
--batch: include the sub-folders. --file-timeout- With
--batch: give up on a file after this many seconds. The default, 0, is no limit. --lod- Levels of detail as percentages of the triangles, for example
--lod 100,50,25. The first level is written to<name>.glb, the others to<name>_lod1.glb,<name>_lod2.glband so on. Cannot be combined with--simplify. --lod-error- The error limit of the level-of-detail simplifier, as a fraction of each mesh’s size. The default is 0.01.
Without typing
The folder also holds step2glb.bat (Windows) and step2glb.command (macOS). Drag a STEP file onto one of them to convert it with the default settings, without opening the viewer.
Options of the server
The launcher starts serve.py. Started by hand, it takes these options:
--tab- Open the app in an ordinary browser tab instead of a window of its own.
--no-browser- Start the server and open nothing. Type the printed address into a browser yourself.
--open,-o- Open this file at start. Accepts STEP, IGES, BREP, GLB and glTF files. For a STEP file it asks about quality first.
--port- Use this port instead of 4242.
--keep-running- Keep the server running after its window is closed. Without it, a server that opened the window stops about ten seconds after the last window closes.
--exit-when-closed- Stop the server when its window is closed, also with
--no-browser.