RegularPolyhedron

⚙️ Spec sheet →  —  visual schematic and metrics measured from a real rendered STL.

The five Platonic solids from BOSL2’s polyhedra.scad, built as watertight polyhedra. RegularPolyhedron builds tetrahedron / cube / octahedron / dodecahedron / icosahedron (with named convenience methods too), sized by circumradius, diameter, inradius or side length. The dodecahedron is derived as the dual of the icosahedron. The Archimedean, Catalan and stellated families are a follow-up.

class pybosl2.parts.polyhedra.RegularPolyhedron(name=PlatonicSolid.CUBE, radius=None, diameter=None, inner_radius=None, side=None)[source]

Bases: object

A regular Platonic solid, sized by circumradius, diameter, inradius, or side.

name is a PlatonicSolid enum. The convenience class methods tetrahedron(), cube(), octahedron(), dodecahedron() and icosahedron() construct the corresponding solid without requiring the enum.

Examples

A dodecahedron:

from pybosl2.parts.polyhedra import RegularPolyhedron, PlatonicSolid
RegularPolyhedron(PlatonicSolid.DODECAHEDRON, side=12).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
name : PlatonicSolid

radius : float | None

diameter : float | None

inner_radius : float | None

side : float | None

property name : PlatonicSolid

The Platonic solid type.

info()[source]

Return vertex/face data for this solid.

Returns:

A PolyhedronInfo object containing vertex and face lists.

Return type:

PolyhedronInfo

shape()[source]

Build and return the polyhedron geometry (cached).

Return type:

CsgSolid

show()[source]

Display the polyhedron in the viewer.

Return type:

None

classmethod tetrahedron(radius=None, diameter=None, inner_radius=None, side=None)[source]

Return a regular tetrahedron (4 triangular faces).

Parameters:
radius : float | None

Circumscribing sphere radius.

diameter : float | None

Circumscribing sphere diameter.

inner_radius : float | None

Insphere radius (distance from centre to mid-face).

side : float | None

Edge length.

Returns:

A RegularPolyhedron configured as a tetrahedron.

Return type:

RegularPolyhedron

classmethod cube(radius=None, diameter=None, inner_radius=None, side=None)[source]

Return a cube / regular hexahedron (6 square faces).

Parameters:
radius : float | None

Circumscribing sphere radius.

diameter : float | None

Circumscribing sphere diameter.

inner_radius : float | None

Insphere radius (distance from centre to mid-face).

side : float | None

Edge length.

Returns:

A RegularPolyhedron configured as a cube.

Return type:

RegularPolyhedron

classmethod octahedron(radius=None, diameter=None, inner_radius=None, side=None)[source]

Return a regular octahedron (8 triangular faces).

Parameters:
radius : float | None

Circumscribing sphere radius.

diameter : float | None

Circumscribing sphere diameter.

inner_radius : float | None

Insphere radius (distance from centre to mid-face).

side : float | None

Edge length.

Returns:

A RegularPolyhedron configured as an octahedron.

Return type:

RegularPolyhedron

classmethod dodecahedron(radius=None, diameter=None, inner_radius=None, side=None)[source]

Return a regular dodecahedron (12 pentagonal faces).

Parameters:
radius : float | None

Circumscribing sphere radius.

diameter : float | None

Circumscribing sphere diameter.

inner_radius : float | None

Insphere radius (distance from centre to mid-face).

side : float | None

Edge length.

Returns:

A RegularPolyhedron configured as a dodecahedron.

Return type:

RegularPolyhedron

classmethod icosahedron(radius=None, diameter=None, inner_radius=None, side=None)[source]

Return a regular icosahedron (20 triangular faces).

Parameters:
radius : float | None

Circumscribing sphere radius.

diameter : float | None

Circumscribing sphere diameter.

inner_radius : float | None

Insphere radius (distance from centre to mid-face).

side : float | None

Edge length.

Returns:

A RegularPolyhedron configured as an icosahedron.

Return type:

RegularPolyhedron

Examples

from pybosl2.parts.polyhedra import RegularPolyhedron
RegularPolyhedron.icosahedron(side=20).show()
Loading 3-D preview…

⬇ Download STL mesh

class pybosl2.parts.polyhedra.PolyhedronInfo(solid)[source]

Bases: object

Vertex and face data for a Platonic solid.

The constructor takes a PlatonicSolid enum and looks up the geometry, equivalent to the old Polyhedra.regular_polyhedron_info().

Parameters:
solid : PlatonicSolid

name : str
vertices : list[list[float]]
faces : list[list[int]]
num_vertices : int
num_faces : int

Examples

These mirror the examples in BOSL2’s polyhedra.scad, rendered live through PythonSCAD. Examples that rely on BOSL2’s attachment/anchor system, or on features not in this port, are omitted.

regular_polyhedron

Tetrahedron:

from pybosl2.parts.polyhedra import RegularPolyhedron
RegularPolyhedron("tetrahedron", radius=12).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Cube:

from pybosl2.parts.polyhedra import RegularPolyhedron
RegularPolyhedron("cube", radius=12).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Octahedron:

from pybosl2.parts.polyhedra import RegularPolyhedron
RegularPolyhedron("octahedron", radius=12).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Dodecahedron:

from pybosl2.parts.polyhedra import RegularPolyhedron
RegularPolyhedron("dodecahedron", radius=12).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Icosahedron:

from pybosl2.parts.polyhedra import RegularPolyhedron
RegularPolyhedron("icosahedron", radius=12).shape().show()
Loading 3-D preview…

⬇ Download STL mesh