SteveK
SteveK

Reputation: 1006

Can't seem to get this polyhedron+cube mesh to render

This is a simplified version of a model that I'm working on in OpenSCAD:

// Base Parameters
baseMargin = 1.0;
baseHeight = 5.0;
baseWidth = 112.0 + (2 * baseMargin);
baseLength = 28.0 + (2 * baseMargin);
baseOffset = 5.0;

module base() {
    bottomWidth = baseWidth + 2 * baseOffset;
    bottomLength = baseLength + 2 * baseOffset;
    
    points = [
        // Bottom
        [0, 0, 0], // Point 0
        [bottomWidth, 0, 0], // Point 1
        [bottomWidth, bottomLength, 0], // Point 2
        [0, bottomLength, 0], // Point 3
        // Top
        [baseOffset, baseOffset, baseHeight], // Point 4
        [baseWidth + baseOffset, baseOffset, baseHeight], // Point 5
        [baseWidth + baseOffset, baseLength + baseOffset, baseHeight], // Point 6
        [baseOffset, baseLength + baseOffset, baseHeight], // Point 7
    ];
    
    faces = [
        [0, 1, 2, 3], // Bottom
        [4, 5, 6, 7], // Top
        [0, 1, 5, 4], // Front
        [1, 2, 6, 5], // Right
        [2, 3, 7, 6], // Back
        [3, 0, 4, 7], // Left
    ];
    
    polyhedron(points, faces);
}

module building() {
    translate([20, 20, baseHeight])
    cube([10, 10, 10]);
}

union() {
    base();
    building();
}

Both the base and the building render fine separately, but when I try to render them together, I only see the building (a cube on top of the base).

If I lower the building so it protrudes into the base, I get this error when rendering:

ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. 

In both cases, the preview looks correct.

I'm not very familiar with OpenSCAD, so please be gentle :)

Upvotes: 0

Views: 36

Answers (1)

SteveK
SteveK

Reputation: 1006

Nevermind, the problem was in the ordering of the points in the faces.

My points were defined correctly, but I had to refer to the manual to find the correct order for the face points of the polyhedron: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron

Upvotes: 0

Related Questions