Polygons

What is it?

You can create customized polygons in OpenSCAD by specifying points and paths. The path is either a single vector, enumerating the points in a list and the order to traverse the points, or, a vector of vectors, ie a list of point lists for each seperate curve of the polygon. You would need to use a vector of vectors if your polygon has holes. The parameter is optional and if you omit it OpenSCAD assumes that the points are in order. syntax:
polygon(points = [ [x, y], ... ], paths = [ [p1, p2, p3..], ...], convexity = N);
                   
example:
polygon(points=[[0,0],[100,0],[0,100],[10,10],[80,10],[10,80]], paths=[[0,1,2],[3,4,5]]);
In this example, you have 6 points (three for the "outer" triangle, and three for the "inner" one). The points (the numbers that correspond to the position of a point defined in the points vector) are connected using 2 paths.

In order to get a 3D object, you either extrude a 2D polygon (linear or (rotation ) or directly use the polyhedron primitive solid. When using extrusion to form solids, its important to realize that the winding direction of the polygon is significant. If a polygon is wound in the wrong direction with respect to the axis of rotation, the final solid (after extrusion) may end up invisible. This problem can be checked for by flipping the polygon using scale([-1,1]) (assuming that extrusion is being done about the Z axis as it is by default).

Working with Polygons in OpenSCAD can get confusing, but there are some helper applications that can simplify the proces for you.

Click on the links below to explore each option: