Documentation

stl2vrml

Convert STL file to virtual world file

Description

example

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

这converted VRML file has the same name as the source STL file, except that the extension is。wrlinstead of。stl。这stl2vrmlfunction places the VRML file in the current folder.

Tip

You can also use thevrimportfunction to import STL files. However, to import Physical Modeling XML files, use thestl2vrmlfunction.

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

example

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

Examples

collapse all

This example uses an STL file in theSimscape™MultiBody™product.

Convert the STL filefourbar-Bar1-1.STL(inMATLAB / TOOLBOX / PHYMECOD / MECH / MECHDEMOS)到VRML文件并将生成的文件放在当前文件夹中。

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

This example uses an STL file in theSimscape Multibodyproduct.

Convert the STL filefourbar-Bar1-1.STL(inMATLAB / TOOLBOX / PHYMECOD / MECH / MECHDEMOS) to an XML-encoded virtual world file and place the resulting file in a folder calledvirtualworlds

stl2vrml('fourbar-Bar1-1.STL','virtualworlds','x3d') ls
。。。fourbar-Bar1-1.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,stl2vrmlconverts all STL files referenced in the XML file. It also creates a main assembly VRML file that containsInlinereferences to all converted individual VRML files. Inlines are wrapped byTransformnodes withdefnames 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, thestl2vrmlfunction 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.

  • stl2vrmlfunction places assembly parts in the global coordinate system. If thesourceis 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 thevrphysmod获取Simulink的功能金宝app®model with VRML visualization.

Introduced in R2010b