STEP X3D Translation

From Web3D.org
Revision as of 16:05, 13 October 2016 by Brutzman (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

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 an 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)
else:
    print("Error: can't read file.")
    sys.exit(0)

Tesselator(aResShape).ExportShapeToX3D( output_file )

SPRI Server

SPRI is a web application that allows browsing the content of STEP files. A STEP file can contain multiple geometric models and the web application allows for viewing what models are available in a file and selecting which are translated to X3C content. Preparing an X3D model requires these steps:

  1. Using the FORM element on the upload page, choose a local STEP file and submit it to the server.
  2. The page displayed on a successful upload will offer options for information views of the STEP file. The "assemblies" view is the most direct way to retrieve X3D translations.
  3. On the assemblies page choose which assembly to render.
  4. The rendering page will present an X3DOM view and also have links to download an X3D file and to view the X3D model with the Cobweb browser.