<p>This is a case of &quot;<a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#Mis-ordered_faces" rel="noreferrer">Mis-ordered faces</a>&quot;.</p>
<p>That means the order in which the vertices making up one or more faces aren't in the correct order.
The vertices of a face should be listed in clockwise order from the perspective of a camera looking at the face form the exterior of the polyhedron.</p>
<p>In this case, the problem can be solved by reordering the <code>[0,1,2]</code> face of the <code>tri_prism</code> polyhedron as, for example, <code>[0,2,1]</code>.</p>
<p>The misordered face(s) can be found by enabling the <strong>Thrown Together</strong> option from the <strong>View</strong> menu and <strong>Preview</strong>ing. The faces in question will be shown in magenta.</p>
<p>Why, then, if the faces are mis-ordered, did the prisms render just fine individually? My guess is that faces have to be properly ordered to be sure to get a correct Render. The behavior of Render is simply indeterminate for polyhedra with misordered faces. It can work in some situations, but it's not guaranteed.</p>
<p>Edit: I forgot to add that, in my opinion, this shouldn't be an issue, and that if it's such a big problem for the Rendering subroutine, it should intelligently reorder the mis-ordered faces in a prelude. It would avoid beginners such needless troubles.</p>

CC BY-SA 4.0
2022-02-18T05:49:38.840Z
2022-02-18T06:02:12.870Z
2022-02-18T06:02:12.870Z
nc404
<p>I am running into what honestly seems like a bug in OpenSCAD, but I can't believe that something so simple could reveal a bug. I am trying to render the following code:</p>
<pre><code>module tri_prism(base1, base2) {
    polyhedron([
        base1[0], base1[1], base1[2],
        base2[0], base2[1], base2[2]],
        [[0,1,2],[3,4,5],
        [0,1,4,3],[1,2,5,4],[2,0,3,5]],
        convexity=5);
}

union() {
    tri_prism(
        [[0,0,0],[0,1,0],[1,0,0]],
        [[0,0,1],[0,1,1],[1,0,1]]);
    tri_prism(
        [[2,1,0],[2,0,0],[1,1,0]],
        [[2,1,1],[2,0,1],[1,1,1]]);
}
</code></pre>
<p>This should render two (non-overlapping) triangular prisms, like so:</p>
<p><a href="https://i.sstatic.net/YZwAU.png" rel="nofollow noreferrer" title="Two triangular prisms side-by-side"><img src="https://i.sstatic.net/YZwAU.png" alt="Two triangular prisms side-by-side" title="Two triangular prisms side-by-side" /></a></p>
<p>However, this image is only the preview. When I hit <kbd>F6</kbd>, it renders this, with only the triangular bases being rendered:</p>
<p><a href="https://i.sstatic.net/TgpBw.png" rel="nofollow noreferrer" title="Only the triangular bases are rendered"><img src="https://i.sstatic.net/TgpBw.png" alt="Only the triangular bases are rendered" title="Only the triangular bases are rendered" /></a></p>
<p>And the console shows this warning, which I don't know the meaning of because I am a beginner:</p>
<pre><code>UI-WARNING: Object may not be a valid 2-manifold and may need repair!
</code></pre>
<p>Each of the prisms individually renders just fine, but the two of them together don't. Also, it is not merely a problem of appearance since exporting it as STL and opening it in Cura, I see the same useless nonsense.</p>
<p>Is this a bug or am I doing something wrong? And if it is a bug, how do I work around it?</p>

CC BY-SA 4.0
2022-02-18T14:24:25.820Z
If you are opening these files in Cura, then presumably you are going to (eventually) 3D print them, once you have fixed the issue described in your question?
Greenonline
<openscad>
OpenSCAD can't render union of two polyhedrons, but can preview just fine
nc404
# OpenSCAD can't render union of two polyhedrons, but can preview just fine

(Asked by: username_0 on 2022-02-18)

I am running into what honestly seems like a bug in OpenSCAD, but I can't believe that something so simple could reveal a bug. I am trying to render the following code:

```
module tri_prism(base1, base2) {
    polyhedron([
        base1[0], base1[1], base1[2],
        base2[0], base2[1], base2[2]],
        [[0,1,2],[3,4,5],
        [0,1,4,3],[1,2,5,4],[2,0,3,5]],
        convexity=5);
}

union() {
    tri_prism(
        [[0,0,0],[0,1,0],[1,0,0]],
        [[0,0,1],[0,1,1],[1,0,1]]);
    tri_prism(
        [[2,1,0],[2,0,0],[1,1,0]],
        [[2,1,1],[2,0,1],[1,1,1]]);
}

```

This should render two (non-overlapping) triangular prisms, like so:

[![Two triangular prisms side-by-side](https://i.sstatic.net/YZwAU.png "Two triangular prisms side-by-side")](https://i.sstatic.net/YZwAU.png "Two triangular prisms side-by-side")

However, this image is only the preview. When I hit `F6`, it renders this, with only the triangular bases being rendered:

[![Only the triangular bases are rendered](https://i.sstatic.net/TgpBw.png "Only the triangular bases are rendered")](https://i.sstatic.net/TgpBw.png "Only the triangular bases are rendered")

And the console shows this warning, which I don't know the meaning of because I am a beginner:

```
UI-WARNING: Object may not be a valid 2-manifold and may need repair!

```

Each of the prisms individually renders just fine, but the two of them together don't. Also, it is not merely a problem of appearance since exporting it as STL and opening it in Cura, I see the same useless nonsense.

Is this a bug or am I doing something wrong? And if it is a bug, how do I work around it?

**Tags:** openscad

> **Comments:**
> **username_1**: If you are opening these files in Cura, then presumably you are going to (eventually) 3D print them, once you have fixed the issue described in your question?  

---

## 1 answers

### Answer by username_0 on 2022-02-18. Score: 11 | Accepted answer

This is a case of "[Mis-ordered faces](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#Mis-ordered_faces)".

That means the order in which the vertices making up one or more faces aren't in the correct order.
The vertices of a face should be listed in clockwise order from the perspective of a camera looking at the face form the exterior of the polyhedron.

In this case, the problem can be solved by reordering the `[0,1,2]` face of the `tri_prism` polyhedron as, for example, `[0,2,1]`.

The misordered face(s) can be found by enabling the **Thrown Together** option from the **View** menu and **Preview**ing. The faces in question will be shown in magenta.

Why, then, if the faces are mis-ordered, did the prisms render just fine individually? My guess is that faces have to be properly ordered to be sure to get a correct Render. The behavior of Render is simply indeterminate for polyhedra with misordered faces. It can work in some situations, but it's not guaranteed.

Edit: I forgot to add that, in my opinion, this shouldn't be an issue, and that if it's such a big problem for the Rendering subroutine, it should intelligently reorder the mis-ordered faces in a prelude. It would avoid beginners such needless troubles.


---

