Quantcast

Importing and using .stl files

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Importing and using .stl files

Ian Shumsky
Hi,

I would like to use .stl files (created in OpenSCAD) in other projects, however while I can import I can't get the .stl object to compile and render in GCAL. I'm using the latest Windows build (OpenSCAD-2011.11.01-Installer.exe) and to read the .stl file I use the import command:

  import ("foo.stl", convexity = 4);

I can then preview this (with an F5 compile) and see the object. With the same command when I try the F6 "compile and render in GCAL" option I receive the following warning message:

  Parsing design (AST generation)...
  Compiling design (CSG Tree generation)...
  Compilation finished.
  Rendering Polygon Mesh using CGAL...
  PolySets in cache: 3
  Polygons in cache: 41406
  CGAL Polyhedrons in cache: 5
  Vertices in cache: 24
  Total rendering time: 0 hours, 0 minutes, 0 seconds
  WARNING: No top level geometry to render

I guess there is some additional syntax needed, but I can't figure out what it should be. All help appreciated!

Cheers,
Ian


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing and using .stl files

Triffid Hunter
import_stl("filename.stl"); works for me

perhaps your STL is inside out, or non-manifold or something? CGAL is
/super/ sensitive to non-manifold STLs.

See what http://cloud.netfabb.com makes of it

On Wed, Nov 23, 2011 at 9:26 PM, Ian Shumsky <[hidden email]> wrote:

> Hi,
>
> I would like to use .stl files (created in OpenSCAD) in other projects, however while I can import I can't get the .stl object to compile and render in GCAL. I'm using the latest Windows build (OpenSCAD-2011.11.01-Installer.exe) and to read the .stl file I use the import command:
>
>  import ("foo.stl", convexity = 4);
>
> I can then preview this (with an F5 compile) and see the object. With the same command when I try the F6 "compile and render in GCAL" option I receive the following warning message:
>
>  Parsing design (AST generation)...
>  Compiling design (CSG Tree generation)...
>  Compilation finished.
>  Rendering Polygon Mesh using CGAL...
>  PolySets in cache: 3
>  Polygons in cache: 41406
>  CGAL Polyhedrons in cache: 5
>  Vertices in cache: 24
>  Total rendering time: 0 hours, 0 minutes, 0 seconds
>  WARNING: No top level geometry to render
>
> I guess there is some additional syntax needed, but I can't figure out what it should be. All help appreciated!
>
> Cheers,
> Ian
>
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing and using .stl files

Ian Shumsky
> perhaps your STL is inside out, or non-manifold or something?
> CGAL is /super/ sensitive to non-manifold STLs. See what
> http://cloud.netfabb.com makes of it

Thanks -- ran it through netfabb and received a 'fixed' .stl, and now getting some different errors:

Parsing design (AST generation)...
Compiling design (CSG Tree generation)...
Compilation finished.
Rendering Polygon Mesh using CGAL...
CGAL error in CGAL_Build_PolySet: CGAL ERROR: assertion violation!
Expr: check_protocoll == 0
File: /media/code/mingw-cross-env/usr/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/include/CGAL/Polyhedron_incremental_builder_3.h
Line: 198
CGAL error in CGA_Nef_polyhedron3(): CGAL ERROR: assertion violation!
Expr: !CGAL::is_empty_range( first, last)
File: /media/code/mingw-cross-env/usr/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/include/CGAL/normal_vector_newell_3.h
Line: 73
CGAL Cache insert: import(file="C:/IanShumsky/Personal/Mode (0 verts)
CGAL Cache insert: group(){import(file="C:/IanShumsky/Perso (0 verts)
PolySets in cache: 2
Polygons in cache: 78744
CGAL Polyhedrons in cache: 8
Vertices in cache: 0
Total rendering time: 0 hours, 0 minutes, 0 seconds
WARNING: No top level geometry to render

I have done a simple test (i.e. export a single cube) and it works, so I assume that this has to be a problem with the mesh itself (which is complex).

Cheers,
Ian




______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing and using .stl files

kintel
Administrator
On Nov 23, 2011, at 12:34 PM, Ian Shumsky wrote:
>
> Thanks -- ran it through netfabb and received a 'fixed' .stl, and now getting some different errors:
>
My guess is that you got the same error message with the first stl file, but it was hidden by the caching mechanism.
Basically, error messages like these are only output the first time an new object is encountered - subsequently, the geometry will be cached and the error suppressed. Fixing this is on the TODO list.

Regarding the stl, my guess is that you've triggered a known issue in OpenSCAD related to dense geometries. This is annoying and it's a high priority to fix it after the upcoming release.
If you could send me the original stl (or scad file generating the stl), I can put it into my archive of known-to-fail objects to better test potential solutions.

 -Marius


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing and using .stl files

Ian Shumsky
Hi Marius,

Many thanks for the explanations. The suggestion of 'dense geometries' sounds quite plausible as there are a lot of high quality curved surfaces in the final object. I will try and reduce complexity / quality to get a better example of the failure scenario and then mail you the .scad file (to [hidden email] I presume)?

Regards,
Ian



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marius Kintel
Sent: 23 November 2011 11:56
To: [hidden email]
Subject: Re: [OpenSCAD] Importing and using .stl files

On Nov 23, 2011, at 12:34 PM, Ian Shumsky wrote:
>
> Thanks -- ran it through netfabb and received a 'fixed' .stl, and now getting some different errors:
>
My guess is that you got the same error message with the first stl file, but it was hidden by the caching mechanism.
Basically, error messages like these are only output the first time an new object is encountered - subsequently, the geometry will be cached and the error suppressed. Fixing this is on the TODO list.

Regarding the stl, my guess is that you've triggered a known issue in OpenSCAD related to dense geometries. This is annoying and it's a high priority to fix it after the upcoming release.
If you could send me the original stl (or scad file generating the stl), I can put it into my archive of known-to-fail objects to better test potential solutions.

 -Marius


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing and using .stl files

kintel
Administrator
On Nov 23, 2011, at 13:01 PM, Ian Shumsky wrote:

> [...] then mail you the .scad file (to [hidden email] I presume)?
>
Please do.

 -Marius


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing and using .stl files

Ian Shumsky
> Please do.

After cutting down my complex shape I managed to boil it down to the bare minimum and came up with the following which demonstrates the problem:

// =====================================

// sizes
box_width = 720;
box_depth = 450;
box_height = 90;
box_bevel = 35;

// quality settings
fn_setting = 41; // does not work
//fn_setting = 40; // works

union ()
{
        translate ([-((box_width / 2) - box_bevel), -((box_depth / 2) - box_bevel), 0])
        cylinder (h = box_height - box_bevel, r = box_bevel, center = false, $fn = fn_setting);
        translate ([0, -((box_depth / 2) - box_bevel), box_height - box_bevel])
        rotate ([0, 90, 0])
        cylinder (h = box_width - (2 * box_bevel), r = box_bevel, center = true, $fn = fn_setting);
}

// =====================================

Exporting the above shape with an $fn value of 40 or less works fine; the .stl file can be imported and rendered in CGAL. Using an $fn value of 41 or more will not work.

Hope this helps!

Cheers,
Ian


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing and using .stl files

Ian Shumsky
After some more thinking and playing around, I think that in the example this is the key:

//fn_setting = 41; // does not work
fn_setting = 40; // works

Looking closely at the mesh at the join of the objects the many edge points need to match up. A better example follows:

// =====================================

// basic box sizes
box_width = 720;
box_depth = 450;
box_height = 90;
box_bevel = 35;

// fn settings
fn_setting = 360; // works

union ()
{
        translate ([(box_width / 2) - box_bevel, -((box_depth / 2) - box_bevel), 0])
        cylinder (h = box_height- box_bevel, r = box_bevel, center = false, $fn = fn_setting);

        translate ([0, -((box_depth / 2) - box_bevel), box_height- box_bevel])
        rotate ([0, 90, 0])
        cylinder (h = box_width - (2 * box_bevel), r = box_bevel, center = true, $fn = fn_setting);

        translate ([(box_width / 2) - box_bevel, 0, box_height- box_bevel])
        rotate ([90, 90, 0])
        cylinder (h = box_depth - (2 * box_bevel), r = box_bevel, center = true, $fn = fn_setting);
}

// =====================================

$fn values that are a multiple of 4 work in this example, other values do not. If you add in a sphere at the join:

        translate ([(box_width / 2) - box_bevel, -((box_depth / 2) - box_bevel), box_height - box_bevel])
        sphere (r = box_bevel, $fn = fn_setting);

then (with simple $fn values that are multiples of 4) the exported .stl mesh can't be used by OpenSCAD / CGAL.

However, changing the $fn setting of the sphere as follows:

        sphere (r = box_bevel, $fn = fn_setting / 2);

Looks to give valid .stl results for $fn values that are multiples of 8.

Looks like I have some playing around to do with my models!

Thanks for putting up with my ramblings :)
Ian



______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Loading...