Main Content

stl2vrml

(To be removed) Convert STL file to virtual world file

stl2vrml will be removed in a future release. For more information, see stl2vrml.

Description

stl2vrml(source) converts an ASCII or binary STL file that you specify with source to a VRML97-compliant, UTF-8 encoded text file.

The converted VRML file has the same name as the source STL file, except that the extension is .wrl instead of .stl. The stl2vrml function places the VRML file in the current folder.

Tip

You can also use the vrimport function to import STL files. However, to import Physical Modeling XML files, use the stl2vrml function.

example

stl2vrml(source,destination) creates the converted VRML file in the destination folder.

stl2vrml(source,destination,format) creates the converted virtual world file in the specified format.

example

Examples

collapse all

This example uses an STL file in the Simscape™ Multibody™ product.

Convert the STL file Bar1DefaultSLDPRT.STL to a VRML file and place the resulting file in the current folder. To access the STL file, type openExample ImportedFourBarExample in MATLAB® command window and open the folder ImportedFourBarSupport/Geometries.

stl2vrml('Bar1DefaultSLDPRT.STL')
ls
.       ..   Bar1DefaultSLDPRT.wrl
% Other files and folders in the current folder appear.

This example uses an STL file in the Simscape Multibody product.

Convert the STL file Bar1DefaultSLDPRT.STL to an XML-encoded virtual world file and place the resulting file in a folder called virtualworlds. To access the STL file, type openExample ImportedFourBarExample in MATLAB command window and open the folder ImportedFourBarSupport/Geometries.

stl2vrml('Bar1DefaultSLDPRT.STL','virtualworlds','x3d')
ls
.       ..   Bar1DefaultSLDPRT.x3d
% Other files and folders in the current folder appear, as well.

Input Arguments

collapse all

STL source file path, specified as a string. The STL file can be either ASCII or binary.

If the source file is a Physical Modeling XML file, stl2vrml converts all STL files referenced in the XML file. It also creates a main assembly VRML file that contains Inline references to all converted individual VRML files. Inlines are wrapped by Transform nodes with DEF names corresponding to the part names defined in their respective STL source files.

Path to the destination folder for converted file, specified as a string. If the destination folder does not exist, the stl2vrml function attempts to create it.

File format for converted virtual world file, specified as a string.

Tips

  • Use the created assembly virtual world files as templates for creating virtual scenes. Edit the scenes. For example, add lights, viewpoints, or surrounding objects, modify part materials, define navigation speeds, and so on.

  • The stl2vrml function places assembly parts in the global coordinate system. If the source is a physical modeling XML file, the resulting virtual world assembly file reflects the initial positions of parts defined in the XML file.

  • To use the tree structure of the related SolidWorks® source file in the assembly virtual world file, avoid spaces in assembly and component names. To process the assembly VRML files (but not X3D files), you can use the vrphysmod function to obtain a Simulink® model with VRML visualization.

Version History

Introduced in R2010b

collapse all

R2023b: To be removed

The stl2vrml will be removed in a future release. Instead, use sim3d classes and Simulation 3D blocks to interface MATLAB and Simulink with the Unreal Engine® 3D simulation environment. To get started, see Create 3D Simulations in Unreal Engine Environment.