g-stl [-bvi8] [-x _rt_debug_] [-X _nmg_debug_] [-a _abs_tol_] [-r _rel_tol_] [-n _norm_tol_] [-D _dist_tol_] [-o _output_file_.stl | -m _directory_] _database.g_ _object_ ...
G-STL(1)
NAME
g-stl - convert BRL-CAD geometry to the STL file format
On this page
SYNOPSIS
DESCRIPTION
g-stl converts the specified object(s) from a BRL-CAD database.g file into the stereolithography (STL) file format by tessellating the geometry into triangle facets via the NMG boolean evaluator. STL is widely used for 3D printing and rapid prototyping.
By default an ASCII STL stream is written to standard output. With -o a single STL file (ASCII or, with -b, binary) is produced; with -m each region is written to a separate file in the named directory, with the region’s path name mangled into the file name ("/" becomes "@" and spaces or periods become "_"). Binary output cannot be sent to standard output. Output units default to millimeters; see -i. Related converters include g-obj(1), g-ply(1), and stl-g(1) for the reverse direction.
OPTIONS
- -b
-
Write a binary STL file instead of the default ASCII format. Binary output cannot be written to standard output, so -o or -m is required.
- -v
-
Enable verbose output, reporting object names, tolerances, and conversion statistics.
- -i
-
Use inches as the output units (the default is millimeters).
- -8
-
Tessellate using the marching cubes algorithm rather than the default NMG boolean evaluation.
- -a abs_tol
-
Set the absolute tessellation tolerance in millimeters (the maximum chord deviation). Setting this clears the relative tolerance.
- -r rel_tol
-
Set the relative tessellation tolerance as a fraction of the bounding box (default 0.01).
- -n norm_tol
-
Set the surface normal tessellation tolerance in degrees. Setting this clears the relative tolerance.
- -D dist_tol
-
Set the calculation distance tolerance in millimeters used to decide whether two vertices are coincident (default 0.0005).
- -x rt_debug
-
Set the librt debugging flags as a hexadecimal value.
- -X nmg_debug
-
Set the libnmg debugging flags as a hexadecimal value.
- -o output_file.stl
-
Write all converted geometry to the named output file. Mutually exclusive with -m.
- -m directory
-
Write each region to its own STL file inside the named directory. Mutually exclusive with -o.
- -h, -?
-
Print a usage message and exit.
EXAMPLES
g-stl -b -i -a 0.1 -o bracket.stl model.g bracket
Tessellates the bracket region from model.g with a 0.1 mm absolute tolerance, writing a compact binary STL in inch units suitable for slicing and printing.
mkdir parts
g-stl -m parts model.g assembly
Walks the assembly tree and writes one ASCII STL file per region into the parts directory, each named after the region’s full path. This is convenient when downstream tools expect a single solid per file.
SEE ALSO
brlcad(1), stl-g(1), g-obj(1), g-ply(1), g-dxf(1), mged(1)
AUTHOR
BRL-CAD Team
COPYRIGHT
This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.
BUG REPORTS
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org