" />

ProtoTech's Blog

CAD Customization, CAD Plugin development, QA, 3D development and Services, Augmented and Virtual Reality applications

Plug-in: Exporting VRML from Autodesk Inventor

In this blog article, I am going to provide you with a high level overview of how to go about writing a plugin on Autodesk Inventor to help export the model to VRML (Virtual Reality Modelling Language) format.

VRML (Virtual Reality Modelling Language):
VRML is a scene description language. Aspects of virtual world display, interaction and internetworking can be specified using VRML without being dependent on special gear like head-mounted devices (HMD). It is the intention of its designers to develop VRML as the standard language for interactive simulation within the World Wide Web. VRML files are not compiled, but are simple ASCII text files which can be parsed by a VRML interpreter. Many Web browsers support VRML format and can display the 3D scenes described in a VRML file.


VRML is an object-oriented language. It has objects and associated properties, events and transformations for the object. A VRML file consists of the following major functional components: the header, the scene graph, the prototypes and event routing. A VRML file always starts with the header. It can be in a following form:

#VRML V1.0 ascii

After the header, there is a “scene graph”, which contains nodes. Nodes describe objects and their properties.

A few common object types contained in VRML format are:

  • Basic Shapes

  • Basic material properties

  • Basic transformations

  • Basic camera views

  • Basic texture-mapping

  • Basic lightning

Autodesk Inventor Customization

We read in the assembly/ part file from Inventor and insert the converted details into shape nodes are required by the VRML format.

Model tessellation can be access in following three steps:

  • Identify Document type and access the document

  • Collect all the surface bodies from specific document

  • Use SurfaceBody.CalculateFacets(…) API to get Triangle List

Once you have list of surface bodies you have to just query for facet information from surface like vertex count, vertex coordinates, normal vectors which all are inserted in the IndexedFaceSet node (VRML node) using CalculateFacets (Inventor API).

Material Node

Information like color attributes is fetched from each face level as well as body level (face level is preferred ) which is then inserted in the material node of vrml files as below:

Material {
ambientColor   0.2 0.2 0.2    # MFColor
diffuseColor   0.8 0.8 0.8    # MFColor
specularColor  0 0 0          # MFColor
emissiveColor  0 0 0          # MFColor
shininess      0.2            # MFFloat
transparency   0              # MFFloat }

Each of the Material node arguments which specifies a type of color uses RGB values (red, green and blue intensities), the red value being leftmost, the green value center, and the blue rightmost.

Example of Material applied is as below:








Any shape can have a texture applied to its surface. The texture can be from an image file external to the VRML world file or specified within the world file as a series of coordinates.
Texture{filename “stone.jpg”}

Example of Texture applied:

Mapping of VRML Texture and Material Nodes:


This node allows you to perform simple geometric transformations, scale, rotation, and translation, on texture coordinates. This node is defined inside an Appearance node.


This node takes a set of points in 2-D to define how a texture is applied to IndexedFaceSet. If this node is not specified the texture is applied to the shape as a whole. Specifying a TextureCoordinate node causes the texture to be applied to each face of the shape according to the coordinates given.


   appearance Appearance {
      texture ImageTexture { url "geome.jpg"}
      textureTransform TextureTransform{
      scale 1 1
   geometry IndexedFaceSet {
      coord Coordinate { point [ -3 -3 1,3 -3 1,3  3 1,-3  3 1] }
      coordIndex [0,1,2,3]
      texCoord TextureCoordinate {
         point [0 0 1 0  1 1  0 1   ]}

Material Node:

The material node specifies color, light reflection and transparency. This node can only be defined inside an Appearance node.

This node has six fields: diffuseColor, emissiveColor, ambientIntensity, shininess, specularColor, and transparency. The transparency field controls the transparency of the associated geometry. If a value of 0.0 is specified then the related geometry is completely opaque, a value of 1.0 means that the geometry is completely transparent.

All the “Color” fields have an RGB value associated, i.e., three floating point values between 0.0 and 1.0. The other fields have a single floating point value between 0.0 and 1.0.


Material {
   diffuseColor 0.8 0.8 0.8
   ambientIntensity 0.2
   emissiveColor 0.0 0.0 0.0
   specularColor 0.0 0.0 0.0
   shininess 0.2
   transparency 0.0 }

From Inventor (for Textures and Material)- code snippet::

StyleSourceTypeEnum Face_StyleSourceType;
RenderStyle* RenderedStyle;
hr = pFace->GetRenderStyle(&Face_StyleSourceType,&RenderedStyle);
//get material
color AmbientColor; //color structure
hr=pRenderedStyle->GetAmbientColor(&AmbientColor.red,&AmbientColor.blue, &AmbientColor.green);

Below is a Flow Diagram to fetch the information from Inventor and write into VRML Format:

Contact Us info@prototechsolutions.com

Author :Kalyani H.



ProtoTech Solutions is a custom engineering software development company with skills in 3D visualization on desktop/mobile/cloud. My role in the company is essentially Business Development and Marketing.

View all posts by


You must be logged in to post a comment.