Search code examples
renderingopenscadpolyhedra

Creating a "cup" with polyhedra in openSCAD


I am trying to create a "cup" shape (hollow with one end open) with octagonal prisms (using the polyhedron function). When I render my code, OpenSCAD does not render the bottom and inside faces. What am I doing wrong?

Thanks!

My Code:

difference() {
    polyhedron(points = [ [21.5,51.9,0],[51.9,21.5,0],
    [-21.5,51.9,0],[-51.9,21.5,0],
    [-21.5,-51.9,0],[-51.9,-21.5,0],
    [21.5,-51.9,0],[51.9,-21.5,0],
    [21.5,51.9,100],[51.9,21.5,100],
    [-21.5,51.9,100],[-51.9,21.5,100],
    [-21.5,-51.9,100],[-51.9,-21.5,100],
    [21.5,-51.9,100],[51.9,-21.5,100] ], faces = [
    [0,1,9,8],[2,0,8,10],[3,2,10,11],[5,3,11,13],
    [4,5,13,12],[6,4,12,14],[7,6,14,15],[1,7,15,9],
    [0,1,7,6,4,5,3,2],[8,9,15,14,12,13,11,10] ]);

    polyhedron(points = [ [19,49.4,5],[49.4,19,5],
    [-19,49.4,5],[-49.4,19,5],
    [-19,-49.4,5],[-49.4,-19,5],
    [19,-49.4,5],[49.4,-19,5],
    [19,49.4,100],[49.4,19,100],
    [-19,49.4,100],[-49.4,19,100],
    [-19,-49.4,100],[-49.4,-19,100],
    [19,-49.4,100],[49.4,-19,100] ], faces = [
    [0,1,9,8],[2,0,8,10],[3,2,10,11],[5,3,11,13],
    [4,5,13,12],[6,4,12,14],[7,6,14,15],[1,7,15,9],
    [0,1,7,6,4,5,3,2],[8,9,15,14,12,13,11,10] ]);
}

An image of my rendering problems:

enter image description here


Solution

  • if you use polyhedron() you should always check the orientation of the faces as described here: documentation openscad

    you will see, that in both cases the orientation of the bottom-face is wrong, here your inner polyhedron():

    wrong orientated bottom-face

    Replace [0,1,7,6,4,5,3,2] for the bottom-faces by [2,3,5,4,6,7,1,0] and you get your cup: enter image description here