Cuboid¶
⚙️ Spec sheet → — visual schematic and metrics measured from a real rendered STL.
Cubes, prismoids, wedges and general polygonal prism shapes.
-
pybosl2.shapes3d.cuboid.roof(shape, method=
'straight')[source]¶ Raise a hip roof over a 2-D shape via its straight skeleton (native
roof()).Like
linear_sweep(), this turns a 2-D outline into a 3-D solid, but the top is a peaked roof (each edge slopes inward at 45 degrees to the skeleton) rather than a flat extrusion. shape is any 2-D object – a nativesquare/circle/polygon, aPath2D.polygon(), or aBosl2Solidwrapping one. method selects the skeleton algorithm. PythonSCAD-only (no BOSL2 counterpart); covered by the STL render tests.Examples
from pybosl2 import roof, shapes2d as s2 roof(s2.square([20, 10]).shape).show()Loading 3-D preview…
-
pybosl2.shapes3d.cuboid.cube(size=
1, center=None, chamfer=None, rounding=None, edges=Anchor.ALL, except_edges=None, trimcorners=True, teardrop=False, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP, fn=None, fa=None, fs=None)[source]¶ Return a cube with optional chamfering or rounding of edges and corners.
Delegates to
cuboid()with the full set of edge/corner chamfer and rounding options.- Parameters:¶
- size : float | Sequence[float]¶
size of the cube, a number or length-3 vector
- center : bool | None¶
if given, overrides anchor (True -> CENTER, False -> FRONT+LEFT+BOTTOM)
- chamfer : float | None¶
chamfer size along all edges (default none)
- rounding : float | None¶
rounding radius along all edges (default none)
- edges : EdgeAtom | list[EdgeAtom]¶
edge specifier — “ALL”, “NONE”, “X”, “Y”, “Z”, or list of direction vectors
- except_edges : list[EdgeAtom] | None¶
edges to exclude from chamfer/rounding
- trimcorners : bool¶
trim corners where 3+ edges meet (default True)
- teardrop : bool | float¶
limit the overhang angle for FDM printing (default False)
- anchor : Anchor | Sequence[float]¶
anchor point (default Anchor.CENTER)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- orient : Anchor | Sequence[float]¶
direction to rotate the top towards, after spin (default Anchor.TOP)
- fn : int | None¶
arc smoothness overrides
- fa : float | None¶
arc smoothness overrides
- fs : float | None¶
arc smoothness overrides
- Return type:¶
Bosl2Solid
Examples
Basic cube:
from pybosl2.solid import cube cube(size=20).show()Loading 3-D preview…Cube with chamfered edges:
from pybosl2.solid import cube cube(size=20, chamfer=2).show()Loading 3-D preview…Cube with rounded edges:
from pybosl2.solid import cube cube(size=20, rounding=3).show()Loading 3-D preview…
-
pybosl2.shapes3d.cuboid.cuboid(size=
[1, 1, 1], p1=None, p2=None, chamfer=None, rounding=None, edges=Anchor.ALL, except_edges=None, trimcorners=True, teardrop=False, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP, fn=None, fa=None, fs=None)[source]¶ Return a cube/cuboid with optional chamfering or rounding of edges and corners.
Built directly from cube()/cylinder()/sphere()/hull()/minkowski(), mirroring BOSL2’s own cuboid() algorithm (which is itself CSG composition of primitive shapes at each corner, not raw polyhedron mesh math).
You cannot mix chamfering and rounding on the same call. Negative chamfers/roundings create external fillets, but only apply to edges around the top or bottom face.
Note: teardrop= is not supported by this pure-Python port.
- Parameters:¶
- size : float | Sequence[float]¶
size of the cuboid, a number or length-3 vector
- p1 : Point | None¶
align the cuboid’s corner at p1, if given (forces anchor=BOTTOM_FRONT_LEFT)
- p2 : Point | None¶
if given with p1, defines the cuboid’s opposing cornerpoint
- chamfer : float | None¶
chamfer size, inset from sides (default: no chamfer)
- rounding : float | None¶
edge rounding radius (default: no rounding)
- edges : EdgeAtom | list[EdgeAtom]¶
edges to mask (default
"ALL")- except_edges : list[EdgeAtom] | None¶
edges to explicitly not mask (BOSL2’s except= synonym; except is a Python keyword)
- trimcorners : bool¶
round/chamfer corners where three treated edges meet (default True)
- teardrop : bool | float¶
enable teardrop rounding (not supported by this pure-Python port)
- anchor : Anchor¶
anchor point (default Anchor.CENTER)
- spin : float¶
Z-axis rotation in degrees (default 0)
- orient : Anchor¶
direction to rotate the top towards (default Anchor.TOP)
- fn : int | None¶
arc smoothness overrides for rounded edges/corners
- fa : float | None¶
arc smoothness overrides for rounded edges/corners
- fs : float | None¶
arc smoothness overrides for rounded edges/corners
- Return type:¶
Bosl2Solid
Examples
from pybosl2 import cuboid shape = cuboid([40, 30, 20]) shape.show()Loading 3-D preview…from pybosl2 import cuboid shape = cuboid([40, 30, 20], rounding=5) shape.show()Loading 3-D preview…
-
pybosl2.shapes3d.cuboid.prismoid(size1, size2, height=
None, shift=[0, 0], rounding=0, rounding1=None, rounding2=None, chamfer=0, chamfer1=None, chamfer2=None, length=None, center=None, anchor=Anchor.BOTTOM, spin=0, orient=Anchor.TOP, fn=None, fa=None, fs=None)[source]¶ Return a rectangular prismoid, built as the convex hull() of two (optionally rounded/chamfered) rects.
- Parameters:¶
- size1 : Sequence[float]¶
[width, length] of the bottom end
- size2 : Sequence[float]¶
[width, length] of the top end
- height : float | None¶
height of the prism
- length : float | None¶
height of the prism
- shift : Sequence[float]¶
[X,Y] shift of the top center relative to the bottom center
- rounding : float | Sequence[float]¶
vertical-edge roundover radius, or per-corner list [X+Y+,X-Y+,X-Y-,X+Y-] (default 0)
- rounding1 : float | Sequence[float] | None¶
roundover radius for the bottom of the vertical-ish edges
- rounding2 : float | Sequence[float] | None¶
roundover radius for the top of the vertical-ish edges
- chamfer : float | Sequence[float]¶
vertical-edge chamfer size, or per-corner list (default 0)
- chamfer1 : float | Sequence[float] | None¶
chamfer size for the bottom of the vertical-ish edges
- chamfer2 : float | Sequence[float] | None¶
chamfer size for the top of the vertical-ish edges
- center : bool | None¶
if given, overrides anchor
- anchor : Anchor | Sequence[float]¶
anchor point (default BOTTOM)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- orient : Anchor | Sequence[float]¶
direction to rotate the top towards, after spin (default UP)
- fn : int | None¶
arc smoothness overrides for rounded corners
- fa : float | None¶
arc smoothness overrides for rounded corners
- fs : float | None¶
arc smoothness overrides for rounded corners
- Return type:¶
Bosl2Solid
Examples
from pybosl2 import prismoid shape = prismoid([40, 40], [20, 25], height=30) shape.show()Loading 3-D preview…
-
pybosl2.shapes3d.cuboid.octahedron(size=
1, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP)[source]¶ Return an octahedron with axis-aligned points, built directly with polyhedron().
Examples
from pybosl2.solid import octahedron octahedron(size=20).show()Loading 3-D preview…
-
pybosl2.shapes3d.cuboid.wedge(size=
[1, 1, 1], center=None, anchor=Point(-1.0, -1.0, -1.0), spin=0, orient=Anchor.TOP)[source]¶ Return a 3-D triangular wedge with the hypotenuse in the X+Z+ quadrant, built directly with polyhedron().
- Parameters:¶
- size : Sequence[float]¶
[width, thickness, height]
- center : bool | None¶
if given, overrides anchor (True -> CENTER, False -> FRONT+LEFT+BOTTOM)
- anchor : Anchor | Sequence[float]¶
anchor point (default FRONT+LEFT+BOTTOM)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- orient : Anchor | Sequence[float]¶
direction to rotate the top towards, after spin (default UP)
- Return type:¶
Bosl2Solid
Examples
from pybosl2.solid import wedge wedge([30, 20, 15]).show()Loading 3-D preview…
-
pybosl2.shapes3d.cuboid.rect_tube(height=
None, size=None, isize=None, center=None, shift=[0, 0], wall=None, size1=None, size2=None, isize1=None, isize2=None, rounding=0, rounding1=None, rounding2=None, inner_rounding=0, inner_rounding1=None, inner_rounding2=None, chamfer=0, chamfer1=None, chamfer2=None, inner_chamfer=0, inner_chamfer1=None, inner_chamfer2=None, anchor=Point(0.0, 0.0, -1.0), spin=0, orient=Anchor.TOP, length=None)[source]¶ BOSL2 rect_tube() – a rectangular tube (a rectangle with a rectangular hole through it).
- Parameters:¶
- height : float | None¶
height of the tube (default 1)
- length : float | None¶
length of the tube (default 1)
- size : float | Sequence[float] | None¶
outer [X,Y] size of the tube
- isize : float | Sequence[float] | None¶
inner [X,Y] size of the tube
- center : bool | None¶
if given, overrides anchor
- shift : Sequence[float]¶
[X,Y] shift of the top center relative to the bottom center
- wall : float | None¶
wall thickness
- size1 : float | Sequence[float] | None¶
outer [X,Y] size at the bottom/top
- size2 : float | Sequence[float] | None¶
outer [X,Y] size at the bottom/top
- isize1 : float | Sequence[float] | None¶
inner [X,Y] size at the bottom/top
- isize2 : float | Sequence[float] | None¶
inner [X,Y] size at the bottom/top
- rounding : float | Sequence[float]¶
outer edge rounding radius (overall/bottom/top)
- rounding1 : float | Sequence[float] | None¶
outer edge rounding radius (overall/bottom/top)
- rounding2 : float | Sequence[float] | None¶
outer edge rounding radius (overall/bottom/top)
- inner_rounding : float | Sequence[float]¶
inner edge rounding radius (default: same as rounding)
- inner_rounding1 : float | Sequence[float] | None¶
inner edge rounding radius (default: same as rounding)
- inner_rounding2 : float | Sequence[float] | None¶
inner edge rounding radius (default: same as rounding)
- chamfer : float | Sequence[float]¶
outer edge chamfer size (overall/bottom/top)
- chamfer1 : float | Sequence[float] | None¶
outer edge chamfer size (overall/bottom/top)
- chamfer2 : float | Sequence[float] | None¶
outer edge chamfer size (overall/bottom/top)
- inner_chamfer : float | Sequence[float]¶
inner edge chamfer size (default: same as chamfer)
- inner_chamfer1 : float | Sequence[float] | None¶
inner edge chamfer size (default: same as chamfer)
- inner_chamfer2 : float | Sequence[float] | None¶
inner edge chamfer size (default: same as chamfer)
- anchor : Anchor | Sequence[float]¶
anchor point (default BOTTOM)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- orient : Anchor | Sequence[float]¶
direction to rotate the top towards, after spin (default UP)
- Return type:¶
Bosl2Solid
Examples
from pybosl2.solid import rect_tube rect_tube(size=30, wall=3, height=20).show()Loading 3-D preview…
-
pybosl2.shapes3d.cuboid.regular_prism(sides, height=
None, radius=None, diameter=None, radius1=None, radius2=None, inner_radius=None, inner_diameter=None, side=None, length=None, chamfer=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, circumscribe=False, realign=False, shift=[0, 0], center=None, anchor=None, spin=0, orient=Anchor.TOP, fn=None, fa=None, fs=None)[source]¶ Return a regular sides-sided prism (or frustum) – the sides-gon analogue of cyl(): a regular polygon.
cross-section extruded along Z, with optional per-end chamfer or rounding. Built the same way cyl() is (native cylinder with fn=sides for the plain case; a revolved half-profile with fn=sides for chamfered/rounded ends), so it shares cyl()’s exact rim geometry.
Sizing gives the CIRCUMradius (vertex distance) unless noted – exactly one of
radius/diameter(radius/diameter to the vertices),inner_radius/inner_diameter(inradius/apothem to the face centers, converted via/cos(180/sides)), orside(edge length, converted via/(2 sin(180/sides))).radius1/radius2(or the corresponding taper) set the bottom/top radius independently for a frustum.Note: BOSL2 regular_prism()’s texture=/teardrop= options are not ported (they need the VNF texturing machinery this pure-Python port doesn’t implement).
- Parameters:¶
- sides : int¶
number of sides (integer >= 3)
- height : float | None¶
prism height (default 1)
- length : float | None¶
prism height (default 1)
- radius : float | None¶
overall size (see above)
- diameter : float | None¶
overall size (see above)
- inner_radius : float | None¶
overall size (see above)
- inner_diameter : float | None¶
overall size (see above)
- side : float | None¶
overall size (see above)
- radius1 : float | None¶
bottom/top circumradius for a tapered prism
- radius2 : float | None¶
bottom/top circumradius for a tapered prism
- chamfer : float | None¶
end chamfer size (overall/bottom/top)
- chamfer1 : float | None¶
end chamfer size (overall/bottom/top)
- chamfer2 : float | None¶
end chamfer size (overall/bottom/top)
- rounding : float | None¶
end rounding radius (overall/bottom/top)
- rounding1 : float | None¶
end rounding radius (overall/bottom/top)
- rounding2 : float | None¶
end rounding radius (overall/bottom/top)
- circumscribe : bool¶
circumscribe the nominal radius (scale by 1/cos(180/sides)) (default False)
- realign : bool¶
rotate by half a facet so a face, not a vertex, faces +X (default False)
- shift : Sequence[float]¶
[X,Y] shift of the top center relative to the bottom center
- center : bool | None¶
if given, overrides anchor (True -> CENTER, False -> BOTTOM)
- anchor : Anchor | Sequence[float] | None¶
anchor point (default CENTER)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- orient : Anchor | Sequence[float]¶
direction to rotate the top towards, after spin (default UP)
- fn : int | None¶
arc smoothness overrides
- fa : float | None¶
arc smoothness overrides
- fs : float | None¶
arc smoothness overrides
- Return type:¶
Bosl2Solid
Examples
from pybosl2 import regular_prism shape = regular_prism(6, height=20, radius=15) shape.show()Loading 3-D preview…from pybosl2 import regular_prism shape = regular_prism(5, height=20, inner_radius=12, rounding=2) shape.show()Loading 3-D preview…