Sunday, December 06, 2009

STL to IGS (IGES) Conversion

I've been trying to get my models from Sketchup into a decent file format for use with different analysis engines and for producing drawings for machining.

After a week of playing about with different options I have managed to get from Sketchup files to IGES files.
I used BRL-CAD to convert from .stl to its native format and then exported as an .igs from there.
Below is a copy of the script i used to convert a whole directory of files.


#!/bin/bash
# Convert an STL file to IGES format using BRL CAD

for file in *.stl
do
# Add the -b option or binary format stl files (aoi,solid edge etc)
# stl-g -b ${file} ${file}.g

# Use ascii format for exports from sketchup
stl-g ${file} ${file}.g
done

for file in *.g
do
mkdir ${file}.d
g-iges -m -o ${file}.d ${file} all
cp ${file}.d/*.igs ${file}.igs
rm -rf ${file}.d
done


I did run into an issue or two along the way. When initially export as iges with the command g-iges -o file.igs file.g all the file produced caused every program I tried to load it with to crash with the exception of BRL-CAD which loaded it just fine. I found that when I used the -m option and export all regions to a directory of iges files the files worked. The STL files produced by the STL output plug-in for sketchup produces STL files in the ASCII format some programs may produce files in binary format, in which case you will need to add the -b option to the stl-g command. I had to use this when converting the STL files from the reprap project to iges files.

Why IGES files? Because I couldnt get STEP files. While STL files are widely supported they are mesh files that describe surfaces only. Most professional mechanical CAD packages use constructive solid geometry (CSG) techniques and don't like mesh files so much. That's not to say I couldn't load STL files into these packages but the loaded part was less useful when imported from STL as compared to IGES. An IGES file allows me to measure and convert to a solid object or more easily produce drawings for a machinist to work with.

10 Comments:

At 2:08 AM, Blogger Ali said...

is this a batch code I mean I write it to .bat file

 
At 6:58 AM, Blogger Nick said...

Sorry no this was a script file for use on unix machines.

You could probably write a windows version easily enough. I don't have any experience with BRL-CAD on windows.

the important commands are
stl-g FILE FILE.G
and
g-iges -m -o DIRECTORY FILE all

 
At 9:58 PM, Blogger mike said...

Hello

I noticed the work you did with brl-cad for converting sketchup files to iges.

I have tried to do similar without success including brl-cad.

First, none of this will work with the windows version of brl-cad.

On linux the converters do run, with no apparent problem in going from binary stl to brl-cad .g dbase files

As you noted trying to run g-iges without putting the pieces into a directory does not work at all.

But even using g-iges with the -m option fails after maybe 10 minutes of executing something. (-v for verbose apparently does nothing)

the file i was experimenting with was a sketchup file from google's own database of community .skp files of a car. Sketchup can read it, and meshlab can see the stl file.

I see this kind of output:

header data:
solid vcg
facet normal -5.169539e-001 -1.819919e-001 8.364434e-001
outer l

Using solid name: s.stl
175140719 facets
98815 faces were degenerate
Making region (r.stl)


Then it goes away for while and then writes a ***bomb***.log file which is almost impossible to read.

I also tried setting tolerances with the -a etc options but no success.

btw i also tried a windows code named cad-exchanger which simply fails out of the box trying to convert the stl file to iges with no explanation either.

Is it possible the 'degenerate faces' are the culprit. and perhaps meshlab is simply more forgiving

thx

mike in utah

 
At 12:35 PM, Blogger Vivek Hariharan said...

can anyone explain about the following command in the original post

cp ${file}.d/*.igs ${file}.igs

does this copy all the resulting .igs files into one .igs file? i mean does it merge/append several igs files into one and if so will it work when imported?

 
At 4:58 PM, Blogger Nick said...

This copies one of the .igs files to the upper directory. The conversion process in my experience gave only one .igs file but I could not guarantee what it was called. If the conversion gives more than one igs file then only the last igs file will be copied.

This should not interfere in anyway with the igs file itself.

 
At 2:41 PM, Blogger Vivek Hariharan said...

hmmmm..........i see..........thank you

 
At 7:13 AM, Blogger sandeep1 said...

Hi,
Desde la empresa, ya estamos brindando soluciones de IGS Móvil Geolocalizada para Iphone y Android.Mediante la creación de capas de datos geoposicionados, podemos mostrar cientos de puntos de Interés que se encuentren a nuestro alrededor, hacer juegos de búsqueda del tesoro, y visitas guiadas para lugares abiertos. http://igs.com.ar

 
At 12:18 PM, Blogger uyyu said...

This comment has been removed by the author.

 
At 12:19 PM, Blogger uyyu said...

Hello,
Estamos trabajando y entregando proyectos de Realidad Aumentada, pero utilizando un motor no basado en Flash, obteniendo excelentes resultados a nivel gráfico

 
At 11:13 AM, Blogger jazzros said...

You may use SurfaceReconstructionTool for approximating any STL to NURBS.

 

Post a Comment

<< Home