Documentation

stl2vrml

Convert STL file to virtual world file

Syntax

  • stl2vrml(source)
    example
  • stl2vrml(source,destination)
  • stl2vrml(source,destination,format)
    example

Description

example

stl2vrml(source) converts an ASCII or 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.

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

example

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

Examples

collapse all

Convert STL File to VRML File

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

Convert the STL file fourbar-Bar1-1.STL (in matlab/toolbox/physmod/mech/mechdemos) to a VRML file and place the resulting file in the current folder.

stl2vrml('fourbar-Bar1-1.STL')
ls
.       ..   fourbar-Bar1-1.wrl
% Other files and folders in the current folder appear.

Convert STL File to X3D File

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

Convert the STL file fourbar-Bar1-1.STL (in matlab/toolbox/physmod/mech/mechdemos) to an XML-encoded virtual world file and place the resulting file in a folder called virtualworlds.

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

Related Examples

Input Arguments

collapse all

source — STL source file pathstring

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.

destination — Path to folder for converted filestring

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.

format — File format for converted virtual world file'wrl' (VRML) (default) | 'x3d' (XML-encoded X3D file) | 'x3dv' (Classic VRML-encoded X3D file)

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

More About

collapse all

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.

Introduced in R2010b

Was this topic helpful?