Simple viewer for STEP files on UNIX
The STEP
format is probably the most used accurate 3D geometry exchange format.
(It can contain a lot more than just geometry!)
STL
files (most often used in 3D printers) are based on triangles, which are
basically only an approximation of the real geometry.
A lot of available STEP
-file viewer are windows-only.
I’ve been looking for a simple STEP
-file viewer for UNIX-like operating
systems, so that I can see the parts that I’m making using cadquery
(see also: cadquery documentation).
I’m not a fan of IDE’s like cq-editor or IDE’s in general. In particular, cq-editor pulls in the whole of spyder (a Python IDE) just to get syntax highlighting in its built-in editor.
Most programs working with accurate 3D data (including cadquery) use the
OpenCASCADE library.
This comes with its own draw test harness, named DRAWEXE
on UNIX
systems. We can use that to show STEP
files.
The DRAWEXE
program can be controlled using tcl commands.
The contents of a minimal shell-script to view a STEP
file are shown below.
#!/bin/sh export CASROOT="/usr/local/OpenCAS" export CSF_OCCTResourcePath="${CASROOT}/resources" export DRAWHOME="${CSF_OCCTResourcePath}/DrawResources" export CSF_DrawPluginDefaults="${CSF_OCCTResourcePath}/DrawResources" export DRAWDEFAULT="${CSF_OCCTResourcePath}/DrawResources/DrawDefault" CMDS="pload ALL;vinit;stepread \"${1}\" a *;" CMDS="${CMDS}vsetdispmode 1;vdisplay a_1;vchangeselected a_1;" CMDS="${CMDS}vsetmaterial aluminium;vaxo;vfit" DRAWEXE -i -c ${CMDS}
The exported variables seem to be needed by DRAWEXE
, based on other
scripts in the distribution.
Note that you might have to change them, especially CASROOT
, depending on where
OpenCASCADE is installed.
The commands used in CMDS
are documented in draw test harness.
The first line in CMDS
loads all libraries, initializes the viewer window
and reads the STEP
file which is the first and only argument provided to
the scipt.
The second line sets the display mode to shaded, displays the model and
selects it.
The latter makes the lines/edges visible.
The third line sets the visual properties of the model to that of aluminium,
switches to axonometric view (orientation +X-Y+Z) and fits the model to the window.
For comments, please send me an e-mail.