Import geometry from STL or STEP file
creates a geometry object from the specified STL or STEP geometry file and
includes the geometry in the
Import 3-D Geometry from STL File Without Creating Model
Create a geometry object from an STL geometry file.
gm = importGeometry("ForearmLink.stl");
Plot the geometry.
Import Planar Geometry from STL File into Model
Import a planar STL geometry and include it in a PDE model. When importing a planar geometry,
importGeometry converts it to a 2-D geometry by mapping it to the xy-plane.
model = createpde;
Import a geometry into the container.
ans = DiscreteGeometry with properties: NumCells: 0 NumFaces: 1 NumEdges: 5 NumVertices: 5 Vertices: [5x3 double]
Plot the geometry with the edge labels.
Import 3-D Geometry from STEP File
Create a geometry object from a STEP geometry file.
gm = importGeometry("BlockWithHole.step");
Plot the geometry.
Now import the same geometry while specifying the relative sag. You can use this parameter to control the accuracy of the geometry import.
gm = importGeometry("BlockWithHole.step","MaxRelativeDeviation",10);
Plot the geometry.
model — Model container
PDEModel object |
ThermalModel object |
StructuralModel object |
Model container, specified as a
model = createpde(3)
geometryfile — Path to STL or STEP file
string scalar | character vector
Path to STL or STEP file, specified as a string scalar or a character
vector ending with the file extension
".step". Use can also
use the uppercase extensions
".STEP", or any
combinations of uppercase and lowercase letters in these extensions.
d — Relative sag
1 (default) | number in the range [0.1, 10]
Relative sag for importing a STEP geometry, specified as a number in the range [0.1, 10]. A relative sag is the ratio between the local absolute sag and the local mesh edge length. The absolute sag is the maximal gap between the mesh and the geometry.
importGeometrydoes not allow you to import a multidomain 2-D or 3-D geometry where subdomains have any common points. If the subdomains of the geometry have common points, the toolbox still treats these subdomains as disconnected, without any common interface between them. Each subdomain has its own mesh.
Because of this limitation, you cannot import nested 3-D geometries directly. As a workaround, you can import a mesh and then create a multidomain geometry from the mesh by using the
geometryFromMeshfunction. See Multidomain Geometry Reconstructed from Mesh.
The STL format approximates the boundary of a CAD geometry by using a collection of triangles, and the
importGeometryfunction reconstructs the faces and edges from this data. Reconstruction from STL data is not precise and can result in a loss of edges and, therefore, the merging of adjacent faces. Typically, lost edges are the edges between two adjacent faces meeting at a small angle, or smooth edges bounding blend surfaces. Usually, the loss of such edges does not affect the analysis workflow.
Because STL geometries are only approximations of the original CAD geometries, the areas and volumes of the STL and CAD geometries can differ.
Version HistoryIntroduced in R2015a
R2022b: Import from STEP files
You can now import a geometry from a STEP file. When importing from a STEP file, you can control the accuracy of the geometry import by specifying the relative sag value.
R2021a: Import without creating a model
You can now create a geometry object from an STL geometry file without attaching
the imported geometry to any model. The new syntax is
R2017b: Import and mesh planar STL geometries
You can now import a planar STL geometry and convert it to a 2-D geometry by mapping it to the xy-plane.
R2016b: Improved quality of STL import
When importing an STL geometry for a 3-D problem, the function can now recognize and reconstruct more geometric vertices, edges, and faces of the original CAD geometry in some instances. In these cases, the resulting geometry is a closer match to the original CAD geometry.
Detailed geometries can now contain more faces and edges than in previous releases. As a result, in rare instances, the new faces and edges can cause renumbering of the existing ones. If your code imports an STL geometry, visually check the geometry to ensure that you are assigning boundary and initial conditions to the intended regions.