This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

stlwrite

Create STL file from triangulation

Syntax

stlwrite(TR,filename)
stlwrite(TR,filename,fileformat)
stlwrite(___,Name,Value)

Description

stlwrite(TR,filename) writes a triangulation TR to a binary STL file filename. The triangulation can be either a triangulation object or a 2-D delaunayTriangulation object.

example

stlwrite(TR,filename,fileformat) also specifies a file format for the written file. fileformat can be either 'binary' (default) or 'text'.

stlwrite(___,Name,Value) specifies additional options for writing to the STL file using one or more Name,Value pair arguments for either of the previous syntaxes. For example, stlwrite(TR,'stlbinary','Attribute',attributes) also writes a uint16 vector of attributes for each triangle in TR.

Examples

collapse all

Create and plot a 2-D triangulation object.

P = [2.5 8.0; 6.5 8.0; 2.5 5.0; 6.5 5.0; 1.0 6.5; 8.0 6.5];
T = [5 3 1; 3 2 1; 3 4 2; 4 6 2];
TR = triangulation(T,P);
triplot(TR)

Write the triangulation to a text file named tritext.stl.

stlwrite(TR,'tritext.stl','text')

Input Arguments

collapse all

Triangulation, specified as a triangulation object or a 2-D delaunayTriangulation object.

STL file name, specified as a character vector or scalar string. The file name must end with the .stl or .STL extension.

Example: 'stltextfile.stl'

File format, specified as either 'binary' or 'text'.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify the name and value pair arguments in any order as Name1,Value1,Name2,Value2.

Example: stlwrite(TR,'stltext','SolidIndex',solidIDs)

Binary attributes, specified as a uint16 vector. When the input file is a binary file, attributes can contain coded information about the triangles. Its length must be equal to the number of triangles in the triangulation. This parameter is not supported when the input file is a text file.

Solid grouping index, specified as a vector of identification numbers. When the input file is a text file, the identification numbers must assign each triangle to a grouping of triangles in the triangulation. The length of the vector must be equal to the number of triangles in the triangulation. This parameter is not supported when the input file is binary.

Introduced in R2018b