Main Content

STL File Import

This example shows how to import a geometry from an STL file, and then plot the geometry. Generally, you create the STL file by exporting from a CAD system, such as SolidWorks®. For best results, export a fine (not coarse) STL file in binary (not ASCII) format. After importing, view the geometry using the pdegplot function. To see the face IDs, set the FaceLabels name-value pair to 'on'.

View the geometry examples included with Partial Differential Equation Toolbox™.

figure
gm = importGeometry('Torus.stl');
pdegplot(gm)

Figure contains an axes. The axes contains 2 objects of type quiver, patch.

figure
gm = importGeometry('Block.stl');
pdegplot(gm,'FaceLabels','on')

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('Plate10x10x1.stl');
pdegplot(gm,'FaceLabels','on')

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('Tetrahedron.stl');
pdegplot(gm,'FaceLabels','on')

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('BracketWithHole.stl');
pdegplot(gm,'FaceLabels','on')

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('DampingMounts.stl');
pdegplot(gm,'CellLabels','on')

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('MotherboardFragment1.STL');
pdegplot(gm)

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('PlateHoleSolid.stl');
pdegplot(gm,'FaceLabels','on')

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('PlateSquareHoleSolid.stl');
pdegplot(gm)

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('SquareBeam.STL');
pdegplot(gm,'FaceLabels','on')

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('BracketTwoHoles.stl');
pdegplot(gm,'FaceLabels','on')

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

To see hidden portions of the geometry, rotate the figure using Rotate 3D button or the view function. You can rotate the angle bracket to obtain the following view.

figure
pdegplot(gm,'FaceLabels','on')
view([-24 -19])

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
gm = importGeometry('ForearmLink.stl');
pdegplot(gm,'FaceLabels','on');

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

figure
pdegplot(gm,'FaceLabels','on','FaceAlpha',0.5)

Figure contains an axes. The axes contains 3 objects of type quiver, patch, line.

When you import a planar STL geometry, the toolbox converts it to a 2-D geometry by mapping it to the X-Y plane.

figure
gm = importGeometry('PlateHolePlanar.stl');
pdegplot(gm,'EdgeLabels','on')

Figure contains an axes. The axes contains an object of type line.

figure
gm = importGeometry('PlateSquareHolePlanar.stl');
pdegplot(gm);

Figure contains an axes. The axes contains an object of type line.