Re: Conversion tools: stl2pov, pov2png, iges2stl, iges2png

233 views
Skip to first unread message

Bryan Bishop

unread,
Oct 14, 2009, 2:25:28 PM10/14/09
to pythono...@gna.org, kan...@gmail.com, a...@utlists.utexas.edu, Open Manufacturing
On Wed, Oct 14, 2009 at 10:46 AM, Bryan Bishop wrote:
> stl2pov.py
> http://adl.serveftp.org/skdb/import_tools/stl2pov.py

Now with images. Here's what the output looks like for me:

http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.png

The rest of this email is just describing how I did it and what files I used.

You can find bearing.stl in OCC 6.3.0; linux users can run `locate
bearing.stl` and find it.

bearing.stl was here for me on various machines:
/home/bryan/opencascade/OpenCASCADE6.3.0/data/stl/bearing.stl
/home/kanzure/local/opencascade/OpenCASCADE6.3.0/data/stl/bearing.stl

python stl2pov.py bearing.stl bearing.pov

stl file: http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.stl
pov file (mesh data):
http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.pov.inc
pov file: http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.pov

> pov2png.py
> http://adl.serveftp.org/skdb/import_tools/pov2png.py

python pov2png.py bearing.pov bearing.png

pov file (mesh data):
http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.pov.inc
pov file: http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.pov

resulting png: http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.png

> iges2stl.py
> http://adl.serveftp.org/skdb/import_tools/iges2stl.py

You can find bearing.iges in OCC 6.3.0; linux users can run `locate
bearing.iges` and find it.

bearing.iges was here for me on various machines:
/home/bryan/opencascade/OpenCASCADE6.3.0/data/iges/bearing.iges
/home/kanzure/local/opencascade/OpenCASCADE6.3.0/data/iges/bearing.iges
/home/kanzure/code/skdb/import_tools/models/bearing.iges

python iges2stl.py bearing.iges bearing.stl

input iges file: http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.iges

I don't want to upload that STL file, sorry. There's already an STL
file there, but it's the one provided with OCC 6.3.0, not the one
generated by running iges2stl.

iges2stl is *slow*. OCC is very slow when exporting or converting to
STL. Took me about 30 to 60 seconds for the bearing.

> iges2png.py
> http://adl.serveftp.org/skdb/import_tools/iges2png.py

python iges2png.py bearing.iges bearing.png

input iges file: http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.iges
resulting png: http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.png

Clearly the resulting image doesn't look as good as occray. I wish I
would have known about occray last night, I wouldn't have written
iges2png and have to reinvent the wheel.

http://code.google.com/p/occray/

I looked around on the opencascade.org forum and found that others
have been trying to generate images from CAD files since 2000. There
were posts in 2000, 2002, and one more recently in 2008, of people
complaining about Xw_Window.cxx and how OCC uses Xlib to save an image
of the scene, rather than using some off screen rendering mechanism. I
also noticed that src/OpenGl/ isn't included in pythonOCC? I was
hoping to dig around in there and see if I could find a way to do off
screen rendering. PyOpenGL doesn't implement the gl off screen
rendering method, sadly enough, so it might have to be either compiled
into OCC, or we just hope that the OCC devs bothered to put it in
(which I am starting to doubt).

The other option is to use blender for rendering of STL files. Sadly
this still requires using OCC to convert from IGES/STEP to STL, which
takes forever. The other problem is that my blender script doesn't
seem to work-- I use renderAnim, I set up lamps and lights, and point
the camera at the object, but the resulting image is just black
pixels.

I was running blender with:
blender -b -P render_image.py

And here's what I had in render_image.py ...
http://adl.serveftp.org/~bryan/pythonocc-tools/render_image.py

Why is it so hard to get a rendered image? Does anyone know how
thingiverse is rendering their images of STL and DXF files?

- Bryan
http://heybryan.org/
1 512 203 0507

Bryan Bishop

unread,
Oct 14, 2009, 2:48:28 PM10/14/09
to Vitaly Mankevich, Open Manufacturing, kan...@gmail.com
On Wed, Oct 14, 2009 at 1:42 PM, Vitaly Mankevich <alban...@gmail.com> wrote:
> Looks like Thingiverse uses povray for actual rendering:
>
> http://blog.reprap.org/2008/11/announcing-thingiversecom.html
> "From STL, its easy to convert to POV which i use for doing the actual
> rendering. linux (or something independent, say python) and command
> line is also crucial here."

I see. Right now converting from IGES to STL is taking a long time.
The povray part is pretty quick. One other option that I am
investigating is using gmsh (which links to OCC) to load an IGES file
and then save an image (it has some image saving functions). The
problem is that the output of the GIF exporter looks like this:

http://adl.serveftp.org/~bryan/pythonocc-tools/bearing.gif

But it is significantly faster, so a compiled tool (linking to gmsh)
might be better in the end. I don't know how fast occray is, it was
just announced this morning. An off-screen OpenGL renderer would be
even better. I guess I'll go back to digging through the OCC
code-base.

Erik

unread,
Oct 15, 2009, 8:17:42 AM10/15/09
to Open Manufacturing

> Why is it so hard to get a rendered image? Does anyone know how
> thingiverse is rendering their images of STL and DXF files?
>
> - Bryanhttp://heybryan.org/

I've experimented a bit with Zach Smith's render, which is in use at
Thingiverse.com. I think I have the files you need to get similar to
Thingiverse rendering. The following are files branched from a very
old release of Zach's setup, but they do work under Debian and Ubuntu
(with perl and probably requiring some libraries). I've uploaded it
here:

http://counter.reprap.org/stl2web/povray-render-stl.tgz

It was part of an attempt to improve it for Thingiverse, which I
really wish to support. Perhaps, since it's also useful to you, we can
improve it together.

In http://counter.reprap.org/stl2web/ you'll find an interactive
viewer that I started building. It's very coarse at this moment, but
should work in any browser (no flash/java required). I've just
committed it into the RepRap subversion repository under my personal
directory:
svn co http://reprap.svn.sourceforge.net/svnroot/reprap/trunk/users/erik/stl2web

Eventually it should be part of a system, I envision that serves as a
distributed processing system where everyone can participate in
helping rendering and toolpath generation (skeinforge for 3D printing
is pretty processor intensive) for fabbing.

Also, I'd like to see user generated parametric models being converted
into fabber ready (e.g. STL) file format. I've just tried a proof of
concept of this by making a bottle from a script. I only 'told it'
which dimensions I wanted. Creating a completely seamless (but clogged
together) toolchain to have the machine fab without any manual steps
in between it is entirely a plausible thing to code in a week, but I'm
afraid that I don't have a spare week right now ;)

Bryan Bishop

unread,
Oct 20, 2012, 4:32:26 PM10/20/12
to openmanu...@googlegroups.com, Andrew Mazzotta, Bryan Bishop
On Sat, Oct 20, 2012 at 3:03 PM, Andrew Mazzotta <andrewm...@gmail.com> wrote:
Would one of you be able to elaborate on how to have stls be viewable like Thingiverse? The file can be successfully loaded by a user but open up in a new page as data.

I don't understand your second sentence. Anyway, thingiverse has since changed their rendering system to something using blender. The original method was the stl2pov script with some tweaks.

Triffid Hunter

unread,
Oct 20, 2012, 10:23:18 PM10/20/12
to openmanu...@googlegroups.com
On Sun, Oct 21, 2012 at 7:03 AM, Andrew Mazzotta
<andrewm...@gmail.com> wrote:
> Would one of you be able to elaborate on how to have stls be viewable like
> Thingiverse? The file can be successfully loaded by a user but open up in a
> new page as data.

how about using an in-browser renderer like jsc3d or three.js?

Andrew Mazzotta

unread,
Oct 20, 2012, 10:48:33 PM10/20/12
to openmanu...@googlegroups.com
Just ran across three.js. Reading on jsc3d now. Thanks guys.
Reply all
Reply to author
Forward
0 new messages