STEP X3D Translation

Revision as of 06:23, 5 May 2016 by Vmarchetti (Talk | contribs) (Open Cascade and PythonOCC)

Jump to: navigation, search

STEP to X3D Translation

Methods for converting STEP (ISO 10303) exchange files to X3D files. Here we focus on direct translation; an alternative method will be to read import a STEP file into a full featured CAD program and then export either as X3D if avallable or export as VRML, then perform a VRML -> X3D translation.


CADExchanger is a commercial product available for Windows and Mac OS that offers import and export for a number of formats [1]. At version 3.12 It offers import (and export) for STEP files and export for X3D. Conversion is by importing a STEP file and exporting as X3D. The developers also offer command-line products for bulk conversion, a software development kit, and development services.

Open Cascade and PythonOCC

Open Casade is a open source (LGPL) geometry kernel written in C++. PythonOCC is a Python binding to the function exposed in compiled OpenCascade libraries, and so allows OpenCascade functions to be called from Python scripts. A simple Python script calling STEP import function followed by X3D export of the model :

# Python script simplified from the example script 
# core_load_step_ap203_to_x3d distributed with pythonOCC
input_file  = 'm12_2.stp'   # input STEP (AP203/AP214 file)
output_file = 'm12_2.x3d'   # output X3D file

from OCC.STEPControl import STEPControl_Reader
from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity
from OCC.Visualization import Tesselator, atNormal
step_reader = STEPControl_Reader()
status = step_reader.ReadFile( input_file )

if status == IFSelect_RetDone:  # check status
    failsonly = False
    step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)
    step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)
    aResShape = step_reader.Shape(1)
    print("Error: can't read file.")

Tesselator(aResShape).ExportShapeToX3D( output_file )

SPRI Server