Skip to content

Instantly share code, notes, and snippets.

@arnholm
Last active May 13, 2020 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnholm/49c52c130240184460668c281e8307c2 to your computer and use it in GitHub Desktop.
Save arnholm/49c52c130240184460668c281e8307c2 to your computer and use it in GitHub Desktop.
union()
{
translate([0, 0, 6])
scale([0.9842519685, 0.9842519685, 1])
import("floor.stl");
cube([50, 50, 6]);
}

Original problem using OpenSCAD to import an STL fils

union()
{
  translate([0, 0, 6])
  scale([0.9842519685, 0.9842519685, 1])
  import("floor.stl");
  cube([50, 50, 6]);
}

Error message Rendering Polygon Mesh using CGAL... ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e_below != SHalfedge_handle() File: /usr/include/CGAL/Nef_3/SNC_FM_decorator.h Line: 426

Fix the problem using AngelCADs polyfix utility:

$ polyfix floor.stl 

Parameters:
  input_file = floor.stl


polyhedron 0 ================= volume=10890.5, dtol=0.01, atol=1e-06, maxiter=10
iteration 0: vertices=92100 faces=30700
         warning: 1 zero area faces.
         warning: nonmanifold edges: uc(1)=92100 
         merged 76748 vertices
         removed 1 collapsed or zero area face
         split 1 face
         total changes=76750
         no warnings

iteration 1: vertices=15352 faces=30700
         total changes=0
         no warnings

Summary: 
         polyhedron 0: vertices=15352 faces=30700 : no warnings

Writing: floor_1.stl

... polyfix finished, time used: 0d 00h 00m 01s

Then import the repaired file into OpenSCAD and press F6

union()
{
  translate([0, 0, 6])
  scale([0.9842519685, 0.9842519685, 1])
  import("floor_1.stl");
  cube([50, 50, 6]);
}

The problem is now gone

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

@arnholm
Copy link
Author

arnholm commented May 13, 2020

You are welcome, please tell your friends/colleagues about the software so it becomes better known.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment