# A faces( ) function for simple polyhedra

4 messages
Open this post in threaded view
|

## A faces( ) function for simple polyhedra

This post was updated on .
Just released a faces.scad that can generate faces for simple polyhedra:

This is part of a lib that I am working on. During my course of learning polyhedron, the faces is the most frustrating obstacle. So I think that I'd make my face() a stand-alone lib so this might help people like me.

This lib currently only supports 5 very basic polyhedra. And it use 4-point faces. I do hope that, in the future, openscad will consider having a better faces() as the builtin.

The function api:
```faces( shape // cubesides|rod|chain|ring|tube , nside // # of sides , nseg // # of segments for chain )```
Its currently-supported 5 shapes are demonstrated below. The points, pts are given in the example files in the release. The construction of those pts is beyond the scope of this work.

## cubesides

Needed for building other shape faces.
```f=faces( "cubesides", nside=4 ); polyhedron( points=pts, faces=f );```

## rod

Same as a cylinder
```polyhedron( points=pts, faces=faces( "rod", nside=4 )); polyhedron( points=pts , faces=faces( "rod", nside=6 ));```

## tube

```f=faces( "tube", nside=20 ); polyhedron( points= pts , faces=f );```

## chain

```f=faces( "chain", nside=4, nseg=5 ); polyhedron( points=pts, faces=f );```

## ring

A ring is like a closed chain.
```f=faces( "ring", nside=4, nseg=10 ); polyhedron( points=pts, faces= f );```
\$ Runsun Pan, PhD
\$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); \$ Tips; \$ Snippets
Open this post in threaded view
|

## Re: A faces( ) function for simple polyhedrons

Open this post in threaded view
|

## Re: A faces( ) function for simple polyhedrons

 I believe the error is trying to render two or more separate objects. Try do this: module showall(){     cubesides_faces("olive");     rod_faces1("olive"); }     and it still gives you the same rendering error. Render them one at a time will be ok. \$ Runsun Pan, PhD \$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); \$ Tips; \$ Snippets