Skip to documentation
DocumentationAll documentsEnglish

STL-G(1)

NAME

stl-g - Stereolithography (STL) to BRL-CAD converter

On this page

SYNOPSIS

stl-g [-db] [-t tolerance] [-N forced_name] [-i initial_ident] [-I constant_ident] [-m material_code] [-c units] [-x rt_debug_flag] input.stl output.g

DESCRIPTION

stl-g converts a Stereolithography file input.stl into a BRL-CAD database output.g. Each STL solid becomes a bot(5) (bag-of-triangles) primitive wrapped in its own region, and all regions are unioned together into a top-level group named all. Coincident vertices (within the tolerance distance) are merged so the resulting BOT shares vertices between adjacent faces.

Both ASCII and binary STL are supported. Input is assumed to be ASCII unless the -b option is given. Because the STL format carries no useful object names, region and solid names are derived from the embedded solid name (ASCII), the input file name, or the -N option, and made unique within the database.

The inverse conversion (BRL-CAD to STL) is performed by g-stl(1).

OPTIONS

-b

Treat the input as a binary STL file. The default is ASCII.

-d

Print additional debugging information, including each face and its normal as it is read.

-t tolerance

Minimum distance, in millimeters, between two distinct vertices. Any two vertices closer than this are treated as the same vertex. The default is 0.0005 mm (the same default used by mged(1) and the raytracer).

-N forced_name

Use forced_name as the base name for the converted object instead of deriving one from the STL solid name or input file name.

-i initial_ident

Set the ident (region) number assigned to the first region; it is incremented for each subsequent region. The default is 1000. Conflicts with -I.

-I constant_ident

Assign constant_ident to every region created. Must be zero or greater. Conflicts with -i.

-m material_code

Set the integer material code (GIFT material code) assigned to all regions. The default is 0.

-c units

Specify the units used in the STL file so coordinates can be converted to millimeters. units may be any string accepted by BRL-CAD, such as "mm", "cm", "m", "in", or "ft". The default is "mm".

-x rt_debug_flag

Set the librt debug flag (a hexadecimal value; see raytrace.h).

EXAMPLES

Example 1. Convert a binary STL exported from a 3D printing tool
stl-g -b -c in -N bracket part.stl part.g

Reads the binary STL file part.stl whose coordinates are expressed in inches, converts them to millimeters, names the resulting object bracket, and writes the BRL-CAD database part.g.

Example 2. Convert and immediately raytrace an ASCII STL model
stl-g model.stl model.g
rt -o model.png model.g all

Converts the ASCII STL file model.stl, then renders the top-level group all with rt(1) to verify the geometry imported correctly.

SEE ALSO

brlcad(1), g-stl(1), mged(1), rt(1), bot(5)

AUTHOR

BRL-CAD Team

This software is Copyright (c) 1999-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