Documentation Center

  • Trial Software
  • Product Updates

stl2vrml

Convert STL files to VRML format

Syntax

stl2vrml(source)
stl2vrml(source,destination)

Description

stl2vrml(source) Converts the STL file that you specify with source to a VRML file.

Converts both ASCII and binary STL files. The resulting files are VRML97 compliant, UTF-8 encoded text files.

VRML files have the same name as the source STL files, except that the extension is .WRL instead of .STL. The stl2vrml function places the VRML files into the current folder.

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

Input Arguments

source

The name of the source STL or Physical Modeling XML file. If source is a Physical Modeling XML file, stl2vrml converts all STL files that the XML file references. The stl2vrml function also creates a main assembly VRML file that contains inline references to all converted individual VRML files. All inlines are wrapped by transform nodes with DEF names corresponding to the part names defined in their respective STL source files.

Default: ''

destination

(Optional) Folder in which to create converted files. If the destination folder does not exist, stl2vrml attempts to create the destination folder.

Default: ''

Examples

These examples use STL files that SimMechanics™ product includes. If you do not have the SimMechanics product installed, then substitute another STL file .

Convert the STL file fourbar-Bar1-1.STL (which is in matlab/toolbox/physmod/mech/mechdemos) to a VRML file and place the resulting file in the current folder. The resulting VRML file (fourbar-Bar1-1.wrl) has the same name as the source file, except that it has a .wrl extension instead of a .stl extension.

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

Convert the STL file fourbar-Bar2-1.STL to a VRML file and place the resulting file in a folder called virtualworlds. The resulting VRML file is in the destination folder that you specify.

mkdir('virtualworlds')
stl2vrml('fourbar-Bar2-1.STL','virtualworlds')
cd virtualworlds
ls
.       ..   fourbar-Bar2-1.wrl

More About

expand all

Tips

  • You can use the created assembly VRML files as templates for creating virtual scenes in which you can work with objects of the converted assemblies. To work with the scene effectively, edit the scene as necessary. For example, consider whether you need to add lights, viewpoints, and surrounding objects, modify part materials, define navigation speeds, or make other additions and changes.

  • The stl2vrml function converts individual STL files according to the STL convention, which places parts in the global coordinate system. If you specify a Physical Modeling XML file as the source, the resulting VRML assembly file reflects the initial positions of the parts defined in the XML file.

  • If you use SolidWorks®, then do not use spaces when naming assemblies and components. Avoiding spaces in assembly and component names ensures that the assembly VRML file has the same tree structure as the related source in SolidWorks. You can then use the vrphysmod function to process the assembly VRML file to obtain a Simulink® model with VRML visualization.

See Also

|

Was this topic helpful?