I design in OpenSCAD (a programmer’s CAD tool where you write code and “run” it to make your model as opposed to interactively building). When it comes time for mass production you need an industry-standard “.STEP” file format, which OpenSCAD doesn’t support, but another tool called FreeCAD does. The FreeCAD’s importer works on OpenSCAD models, but it was written in 2013 so programming features added to OpenSCAD after that aren’t supported.

In particular this includes polyhedrons with faces, which was added in March 2015. This post will hopefully help out anyone who was as lost as I was in trying to understand why the FreeCAD importer isn’t behaving as expected. I will expand as I find more issues.

For polyhedrons you need to use only 3 points per face. So a square needs to be made up of 2 triangle faces, a five-sided face needs 3 triangle faces, etc. Here is the faces vector for the rectangle polyhedron from the OpenSCAD online documentation.

CubeFaces = [
  [0,1,2,3],  // bottom
  [4,5,1,0],  // front
  [7,6,5,4],  // top
  [5,6,2,1],  // right
  [6,7,3,2],  // back
  [7,4,0,3]]; // left

And here it is translated into triangles

CubeFaces = [
  [0,1,2],  // bottom
  [0,2,3],  // bottom
  [4,5,1],  // front
  [4,1,0],  // front
  [7,6,5],  // top
  [7,5,4],  // top
  [5,6,2],  // right
  [5,2,1],  // right
  [6,7,3],  // back
  [6,3,2],  // back
  [7,4,0], // left
  [7,0,3]]; // left

How to easily convert from 4-sided faces: For each face in your faces vector:

  1. Copy the line
  2. In the original, drop the last number.
  3. In the copy, drop the 2nd number.