Solid

Statically typed shape constructors and backend-neutral solid facade.

pybosl2.solid.DefaultValue : TypeAlias = 'bool | int | float | str | tuple[float, ...] | Anchor | Point | None'

a scalar, a size/shift tuple, an anchor, or None – which means “decide for me” rather than “no value” (PLAN T-9b). Every façade and backend default across the shape surface is one of these.

Type:

What an omitted argument resolves to, as reported by effective_defaults()

pybosl2.solid.effective_defaults(shape, backend=None)[source]

Report the value each argument of shape takes when the caller leaves it out.

The façade owns the default for every argument both backends understand and forwards it whether or not the caller passed one (SPEC B-3, PLAN F-P1); the backend then takes the subset its own constructor declares (F-P2). One filter, in one place. This reports what an omitted argument resolves to, read live off the constructor the backend would call, so it can never drift from the code – and where the façade owns the default it is the façade’s that is reported, because that is the one that decides.

Parameters:
shape : str

BOSL2 shape name, e.g. "cuboid".

backend : str | None

Backend to report for; the active one by default.

Returns:

the façade’s own default for everything both backends understand, plus the backend’s own for its exclusive options. Parameters with no default (the caller must supply those) and the ambient resolution knobs are omitted – the latter come from pybosl2.defaults.use_defaults().

Return type:

Each parameter mapped to the DefaultValue a bare call resolves to

Raises:

ValueError – If the backend has no constructor by that name.

Examples

>>> from pybosl2.solid import effective_defaults
>>> effective_defaults("cuboid")["size"]
(1, 1, 1)
pybosl2.solid.cube(size=1, *, chamfer=0, treatment=None, rounding=0, anchor=Anchor.CENTER, center=None, spin=0, orient=Anchor.TOP, placement=None, edges=Anchor.ALL, except_edges=None, selection=None, teardrop=False, trimcorners=True, fn=None, fa=None, fs=None, res=None)[source]

Return a cube on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
size : float | Sequence[float] | None

Size of the cube, a number or length-3 vector.

chamfer : float | None

Chamfer size along all edges (default none)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

rounding : float | None

Rounding radius along all edges (default none)

anchor : Anchor | Sequence[float] | None

Anchor point (default Anchor.CENTER)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> FRONT+LEFT+BOTTOM)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default Anchor.TOP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

edges : EdgeAtom | list[EdgeAtom] | None

edge specifier — “ALL”, “NONE”, “X”, “Y”, “Z”, or list of direction vectors (CSG backend).

except_edges : list[EdgeAtom] | None

edges to exclude from chamfer/rounding (CSG backend).

selection : EdgeSelection | None

Which edges to treat and which to spare, as one value (SPEC G-1). Giving it beside edges= or except_edges= raises (SPEC G-3).

teardrop : bool | None

limit the overhang angle for FDM printing (default False) (CSG backend).

trimcorners : bool | None

trim corners where 3+ edges meet (default True) (CSG backend).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

Basic cube:

from pybosl2 import cube

cube(size=20).show()
Loading 3-D preview…

⬇ Download STL mesh

Cube with chamfered edges:

from pybosl2 import cube

cube(size=20, chamfer=2).show()
Loading 3-D preview…

⬇ Download STL mesh

Cube with rounded edges:

from pybosl2 import cube

cube(size=20, rounding=3).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.cuboid(size=(1, 1, 1), *, chamfer=0, treatment=None, rounding=0, edges=Anchor.ALL, except_edges=None, selection=None, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP, placement=None, p1=None, p2=None, teardrop=False, trimcorners=True, fn=None, fa=None, fs=None, res=None)[source]

Return a cuboid on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
size : float | Sequence[float] | None

Size of the cuboid, a number or length-3 vector.

chamfer : float | None

Chamfer size, inset from sides (default: no chamfer)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

rounding : float | None

Edge rounding radius (default: no rounding)

edges : EdgeAtom | list[EdgeAtom] | None

Edges to mask (default "ALL")

except_edges : list[EdgeAtom] | None

Edges to explicitly not mask (BOSL2’s except= synonym; except is a Python keyword)

selection : EdgeSelection | None

Which edges to treat and which to spare, as one value (SPEC G-1). Giving it beside edges= or except_edges= raises (SPEC G-3).

anchor : Anchor | Sequence[float] | None

Anchor point (default Anchor.CENTER)

spin : float | None

Z-axis rotation in degrees (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards (default Anchor.TOP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

p1 : Sequence[float] | None

align the cuboid’s corner at p1, if given (forces anchor=BOTTOM_FRONT_LEFT) (CSG backend).

p2 : Sequence[float] | None

if given with p1, defines the cuboid’s opposing cornerpoint (CSG backend).

teardrop : bool | None

enable teardrop rounding (not supported by this pure-Python port) (CSG backend).

trimcorners : bool | None

round/chamfer corners where three treated edges meet (default True) (CSG backend).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import cuboid

shape = cuboid([40, 30, 20])
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

from pybosl2 import cuboid

shape = cuboid([40, 30, 20], rounding=5)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.cyl(height=None, radius=None, *, center=None, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, chamfer=None, treatment=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, shift=(0, 0), anchor=None, spin=0, orient=Anchor.TOP, placement=None, chamfer_angle=None, chamfer_angle1=None, chamfer_angle2=None, circumscribe=False, clip_angle=90.0, extra=0.0, extra1=None, extra2=None, from_end=False, from_end1=None, from_end2=None, realign=False, teardrop=False, tex_depth=1.0, tex_inset=False, tex_reps=None, tex_size=None, texture=None, texturing=None, fn=None, fa=None, fs=None, res=None)[source]

Return a cyl on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Length of the cylinder along its axis (default 1)

radius : float | None

Radius of the cylinder (default 1)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> BOTTOM)

length : float | None

Length of the cylinder along its axis (default 1)

radius1 : float | None

Radius of the negative end of the cylinder.

radius2 : float | None

Radius of the positive end of the cylinder.

diameter : float | None

Diameter of the cylinder.

diameter1 : float | None

Diameter of the negative end of the cylinder.

diameter2 : float | None

Diameter of the positive end of the cylinder.

chamfer : float | None

Chamfer size on the end rims (overall/negative/positive)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | None

Chamfer size on the end rims (overall/negative/positive)

chamfer2 : float | None

Chamfer size on the end rims (overall/negative/positive)

rounding : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding1 : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding2 : float | None

Rounding radius on the end rims (overall/negative/positive)

shift : Sequence[float] | None

X/Y offset for the positive end (shear) (default [0,0])

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

chamfer_angle : float | None

End chamfer angle in degrees away from the ends (CSG backend).

chamfer_angle1 : float | None

Chamfer angle at the bottom end (CSG backend).

chamfer_angle2 : float | None

Chamfer angle at the top end (CSG backend).

circumscribe : bool | None

Circumscribe rather than inscribe the given radius (CSG backend).

clip_angle : float | None

Clip the rounding arc at the bottom of the cylinder (CSG backend).

extra : float | None

Extra height at both ends, invisible to anchoring (CSG backend).

extra1 : float | None

Extra height at the bottom end (CSG backend).

extra2 : float | None

Extra height at the top end (CSG backend).

from_end : bool | None

Measure the chamfer along the conic face rather than the axis (CSG backend).

from_end1 : bool | None

Measure the bottom chamfer along the conic face (CSG backend).

from_end2 : bool | None

Measure the top chamfer along the conic face (CSG backend).

realign : bool | None

Shift point alignment by half a facet (CSG backend).

teardrop : bool | float | None

Limit the rounding angle from horizontal, for printability (CSG backend).

tex_depth : float | None

Depth of the texture (CSG backend).

tex_inset : bool | float | None

Inset the texture into the surface (CSG backend).

tex_reps : int | Sequence[int] | None

Number of texture repetitions (CSG backend).

tex_size : float | Sequence[float] | None

Size of one texture tile (CSG backend).

texture : Any

Named texture for the side surface (CSG backend).

texturing : Texturing | None

The texture and how it is applied, as one value (SPEC G-1). Giving it beside any of the tex_* arguments raises (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

A basic cylinder: .. pythonscad-example:

from pybosl2 import cyl

shape = cyl(radius=10, height=30)
shape.show()

A cylinder with chamfered ends: .. pythonscad-example:

from pybosl2 import cyl

shape = cyl(radius=15, height=40, chamfer=2)
shape.show()

A cylinder with rounded ends: .. pythonscad-example:

from pybosl2 import cyl

shape = cyl(radius=12, height=35, rounding=3)
shape.show()
pybosl2.solid.cylinder(height=None, radius=None, *, chamfer=None, treatment=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, center=None, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, anchor=None, spin=0, orient=Anchor.TOP, placement=None, chamfer_angle=None, chamfer_angle1=None, chamfer_angle2=None, circumscribe=False, clip_angle=90.0, extra=0.0, extra1=None, extra2=None, from_end=False, from_end1=None, from_end2=None, realign=False, shift=(0, 0), teardrop=False, tex_depth=1.0, tex_inset=False, tex_reps=None, tex_size=None, texture=None, texturing=None, fn=None, fa=None, fs=None, res=None)[source]

Return a cylinder on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Length of the cylinder along its axis (default 1)

radius : float | None

Radius of the cylinder (default 1)

chamfer : float | None

Chamfer size on the end rims (overall/negative/positive)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | None

Chamfer size on the end rims (overall/negative/positive)

chamfer2 : float | None

Chamfer size on the end rims (overall/negative/positive)

rounding : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding1 : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding2 : float | None

Rounding radius on the end rims (overall/negative/positive)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> BOTTOM)

length : float | None

Length of the cylinder along its axis (default 1)

radius1 : float | None

Radius of the negative end of the cylinder.

radius2 : float | None

Radius of the positive end of the cylinder.

diameter : float | None

Diameter of the cylinder.

diameter1 : float | None

Diameter of the negative end of the cylinder.

diameter2 : float | None

Diameter of the positive end of the cylinder.

anchor : Anchor | Sequence[float] | None

Anchor point (default BOTTOM if center=False, otherwise CENTER)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

chamfer_angle : float | None

End chamfer angle in degrees away from the ends (CSG backend).

chamfer_angle1 : float | None

Chamfer angle at the bottom end (CSG backend).

chamfer_angle2 : float | None

Chamfer angle at the top end (CSG backend).

circumscribe : bool | None

Circumscribe rather than inscribe the given radius (CSG backend).

clip_angle : float | None

Clip the rounding arc at the bottom of the cylinder (CSG backend).

extra : float | None

Extra height at both ends, invisible to anchoring (CSG backend).

extra1 : float | None

Extra height at the bottom end (CSG backend).

extra2 : float | None

Extra height at the top end (CSG backend).

from_end : bool | None

Measure the chamfer along the conic face rather than the axis (CSG backend).

from_end1 : bool | None

Measure the bottom chamfer along the conic face (CSG backend).

from_end2 : bool | None

Measure the top chamfer along the conic face (CSG backend).

realign : bool | None

Shift point alignment by half a facet (CSG backend).

shift : Sequence[float] | None

[x, y] offset for the positive end, shearing the solid (CSG backend).

teardrop : bool | float | None

Limit the rounding angle from horizontal, for printability (CSG backend).

tex_depth : float | None

Depth of the texture (CSG backend).

tex_inset : bool | float | None

Inset the texture into the surface (CSG backend).

tex_reps : int | Sequence[int] | None

Number of texture repetitions (CSG backend).

tex_size : float | Sequence[float] | None

Size of one texture tile (CSG backend).

texture : Any

Named texture for the side surface (CSG backend).

texturing : Texturing | None

The texture and how it is applied, as one value (SPEC G-1). Giving it beside any of the tex_* arguments raises (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

A basic cylinder:

from pybosl2 import cylinder

cylinder(height=30, radius=10).show()
Loading 3-D preview…

⬇ Download STL mesh

A cylinder with chamfered ends:

from pybosl2 import cylinder

cylinder(height=40, radius=15, chamfer=2).show()
Loading 3-D preview…

⬇ Download STL mesh

A cylinder with rounded ends:

from pybosl2 import cylinder

cylinder(height=30, radius=12, rounding=2).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.octahedron(size=1, *, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP, placement=None, res=None)[source]

Return a octahedron on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
size : float | None

Width of the octahedron, tip to tip.

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import octahedron

octahedron(size=20).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.onion(radius=None, *, angle=45, cap_height=None, diameter=None, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP, placement=None, circumscribe=False, fn=None, fa=None, fs=None, res=None)[source]

Return a onion on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
radius : float | None

Radius of the spherical portion of the bottom (default 1)

angle : float | None

Angle of the cone from vertical in degrees (default 45)

cap_height : float | None

Height above the sphere center to truncate the shape (default: no truncation)

diameter : float | None

Diameter of the spherical portion of the bottom.

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

circumscribe : bool | None

circumscribe rather than inscribe the given radius/diameter (default False) (CSG backend).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import onion

onion(radius=15).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.pie_slice(height=None, radius=None, *, angle=30, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, length=None, anchor=Anchor.CENTER, center=None, spin=0, orient=Anchor.TOP, placement=None, fn=None, fa=None, fs=None, res=None)[source]

Return a pie_slice on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Height of the pie slice.

radius : float | None

Radius of the pie slice.

angle : float | None

Pie slice angle in degrees (default 30)

radius1 : float | None

Bottom radius of the pie slice.

radius2 : float | None

Top radius of the pie slice.

diameter : float | None

Diameter of the pie slice.

diameter1 : float | None

Diameter of the bottom.

diameter2 : float | None

Diameter of the top.

length : float | None

Height of the pie slice.

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

center : bool | None

If given, overrides anchor.

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import pie_slice

pie_slice(radius=20, angle=120, height=5).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.prismoid(size1, size2, *, height=None, shift=(0, 0), length=None, rounding=0, rounding1=None, rounding2=None, chamfer=0, treatment=None, chamfer1=None, chamfer2=None, anchor=Anchor.BOTTOM, center=None, spin=0, orient=Anchor.TOP, placement=None, fn=None, fa=None, fs=None, res=None)[source]

Return a prismoid on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

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.

shift : Sequence[float] | None

[X,Y] shift of the top center relative to the bottom center.

length : float | None

Height of the prism.

rounding : float | Sequence[float] | None

Radius of the vertical edge rounding, or one radius per edge (CSG backend – the SDF prismoid has no exact form for a tapered box’s independently-radiused vertical edges; see pybosl2.sdf.shapes3d.prismoid()).

rounding1 : float | Sequence[float] | None

Vertical edge rounding at the bottom end (CSG backend).

rounding2 : float | Sequence[float] | None

Vertical edge rounding at the top end (CSG backend).

chamfer : float | Sequence[float] | None

Size of the vertical edge chamfer, or one size per edge (CSG backend).

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | Sequence[float] | None

Vertical edge chamfer at the bottom end (CSG backend).

chamfer2 : float | Sequence[float] | None

Vertical edge chamfer at the top end (CSG backend).

anchor : Anchor | Sequence[float] | None

Anchor point (default BOTTOM)

center : bool | None

If given, overrides anchor.

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import prismoid

shape = prismoid([40, 40], [20, 25], height=30)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.rect_tube(height=None, size=None, *, isize=None, wall=None, rounding=0, inner_rounding=0, anchor=Point(0.0, 0.0, -1.0), length=None, center=None, spin=0, orient=Anchor.TOP, placement=None, chamfer=0, treatment=None, chamfer1=None, chamfer2=None, inner_chamfer=0, inner_chamfer1=None, inner_chamfer2=None, inner_rounding1=None, inner_rounding2=None, isize1=None, isize2=None, rounding1=None, rounding2=None, shift=(0, 0), size1=None, size2=None, fn=None, fa=None, fs=None, res=None)[source]

Return a rect_tube on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Height 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.

wall : float | None

Wall thickness.

rounding : float | Sequence[float] | None

Outer edge rounding radius (overall/bottom/top)

inner_rounding : float | Sequence[float] | None

Inner edge rounding radius (default: same as rounding)

anchor : Anchor | Sequence[float] | None

Anchor point (default BOTTOM)

length : float | None

Length of the tube (default 1)

center : bool | None

If given, overrides anchor.

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

chamfer : float | None

outer edge chamfer size (overall/bottom/top) (CSG backend).

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | None

outer edge chamfer size (overall/bottom/top) (CSG backend).

chamfer2 : float | None

outer edge chamfer size (overall/bottom/top) (CSG backend).

inner_chamfer : float | None

inner edge chamfer size (default: same as chamfer) (CSG backend).

inner_chamfer1 : float | None

inner edge chamfer size (default: same as chamfer) (CSG backend).

inner_chamfer2 : float | None

inner edge chamfer size (default: same as chamfer) (CSG backend).

inner_rounding1 : float | None

inner edge rounding radius (default: same as rounding) (CSG backend).

inner_rounding2 : float | None

inner edge rounding radius (default: same as rounding) (CSG backend).

isize1 : Sequence[float] | None

inner [X,Y] size at the bottom/top (CSG backend).

isize2 : Sequence[float] | None

inner [X,Y] size at the bottom/top (CSG backend).

rounding1 : float | None

outer edge rounding radius (overall/bottom/top) (CSG backend).

rounding2 : float | None

outer edge rounding radius (overall/bottom/top) (CSG backend).

shift : Sequence[float] | None

[X,Y] shift of the top center relative to the bottom center (CSG backend).

size1 : Sequence[float] | None

outer [X,Y] size at the bottom/top (CSG backend).

size2 : Sequence[float] | None

outer [X,Y] size at the bottom/top (CSG backend).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import rect_tube

rect_tube(size=30, wall=3, height=20).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.regular_prism(sides, height=None, radius=None, *, diameter=None, inner_radius=None, inner_diameter=None, side=None, length=None, radius1=None, radius2=None, shift=(0, 0), circumscribe=False, rounding=None, rounding1=None, rounding2=None, chamfer=None, treatment=None, chamfer1=None, chamfer2=None, realign=False, anchor=None, center=None, spin=0, orient=Anchor.TOP, placement=None, fn=None, fa=None, fs=None, res=None)[source]

Return a regular_prism on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
sides : int

Number of sides (integer >= 3)

height : 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)

length : float | None

Prism height (default 1)

radius1 : float | None

Bottom radius, for a tapered prism (CSG backend).

radius2 : float | None

Top radius, for a tapered prism (CSG backend).

shift : Sequence[float] | None

[x, y] offset of the top face from the bottom (CSG backend).

circumscribe : bool | None

If True the polygon encloses the given radius instead of being inscribed in it (CSG backend).

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)

chamfer : float | None

End chamfer size (overall/bottom/top)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | None

End chamfer size (overall/bottom/top)

chamfer2 : float | None

End chamfer size (overall/bottom/top)

realign : bool | None

Rotate by half a facet so a face, not a vertex, faces +X (default False)

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> BOTTOM)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import regular_prism

shape = regular_prism(6, height=20, radius=15)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

from pybosl2 import regular_prism

shape = regular_prism(5, height=20, inner_radius=12, rounding=2)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.sphere(radius=None, *, diameter=None, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP, placement=None, circumscribe=False, fn=None, fa=None, fs=None, res=None)[source]

Return a sphere on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
radius : float | None

Radius of the sphere.

diameter : float | None

Diameter of the sphere.

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

circumscribe : bool | None

circumscribe rather than inscribe the sphere (default False) (CSG backend).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import sphere

shape = sphere(radius=15)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.spheroid(radius=None, *, diameter=None, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP, placement=None, circumscribe=False, fn=None, fa=None, fs=None, res=None)[source]

Return a spheroid on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
radius : float | None

Radius of the spheroid.

diameter : float | None

Diameter of the spheroid.

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

circumscribe : bool | None

circumscribe rather than inscribe the spheroid (default False) (CSG backend).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import spheroid

spheroid(radius=15).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.teardrop(height=None, radius=None, *, angle=45, cap_height=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, anchor=Anchor.CENTER, spin=0, orient=Anchor.TOP, placement=None, cap_h1=None, cap_h2=None, chamfer=0, chamfer1=0, chamfer2=0, circumscribe=False, realign=False, fn=None, fa=None, fs=None, res=None)[source]

Return a teardrop on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Thickness of the teardrop (default 1)

radius : float | None

Radius of the circular part (default 1)

angle : float | None

Angle of the hat walls from the Z axis in degrees (default 45)

cap_height : float | None

Height above center to truncate the shape (default: no truncation)

radius1 : float | None

Radius of the circular portion of the front end.

radius2 : float | None

Radius of the circular portion of the back end.

diameter : float | None

Diameter of the circular portion.

diameter1 : float | None

Diameter of the front end.

diameter2 : float | None

Diameter of the back end.

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

cap_h1 : float | None

truncation height on the front side (CSG backend).

cap_h2 : float | None

truncation height on the back side (CSG backend).

chamfer : float | None

chamfer size along the bottom/top faces (overall) (default 0) (CSG backend).

chamfer1 : float | None

chamfer size along the bottom face (default 0) (CSG backend).

chamfer2 : float | None

chamfer size along the top face (default 0) (CSG backend).

circumscribe : bool | None

produce a circumscribing teardrop shape (default False) (CSG backend).

realign : bool | None

shift face alignment, passed to teardrop2d (default False) (CSG backend).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import teardrop

shape = teardrop(radius=8, angle=45, height=15)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.torus(major_radius=None, minor_radius=None, *, major_diameter=None, minor_diameter=None, outer_radius=None, inner_radius=None, outer_diameter=None, inner_diameter=None, anchor=Anchor.CENTER, center=None, spin=0, orient=Anchor.TOP, placement=None, fn=None, fa=None, fs=None, res=None)[source]

Return a torus on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
major_radius : float | None

Major radius of the torus ring (use with minor_radius or minor_diameter)

minor_radius : float | None

Minor radius of the torus ring (use with major_radius or major_diameter)

major_diameter : float | None

Major diameter of the torus ring.

minor_diameter : float | None

Minor diameter of the torus ring.

outer_radius : float | None

Outer radius of the torus (BOSL2 or) (use with inner_radius or inner_diameter)

inner_radius : float | None

Inside radius of the torus (use with outer_radius or outer_diameter)

outer_diameter : float | None

Outer diameter of the torus (use with inner_radius or inner_diameter)

inner_diameter : float | None

Inside diameter of the torus (use with outer_radius or outer_diameter)

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> DOWN)

spin : float | None

Z-axis rotation in degrees (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import torus

shape = torus(major_radius=25, minor_radius=8)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.tube(height=None, outer_radius=None, *, inner_radius=None, outer_diameter=None, inner_diameter=None, wall=None, length=None, rounding=None, rounding1=None, rounding2=None, chamfer=None, treatment=None, chamfer1=None, chamfer2=None, anchor=Anchor.CENTER, center=None, spin=0, orient=Anchor.TOP, placement=None, inner_diameter1=None, inner_diameter2=None, inner_radius1=None, inner_radius2=None, outer_diameter1=None, outer_diameter2=None, outer_radius1=None, outer_radius2=None, realign=False, fn=None, fa=None, fs=None, res=None)[source]

Return a tube on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Height of the tube (default 1)

outer_radius : float | None

Outer radius of the tube (BOSL2 or) (default 1)

inner_radius : float | None

Inner radius of the tube.

outer_diameter : float | None

Outer diameter of the tube.

inner_diameter : float | None

Inner diameter of the tube.

wall : float | None

Horizontal wall thickness (default 1)

length : float | None

Height of the tube (default 1)

rounding : float | None

Rounding radius on end rims (overall/bottom/top)

rounding1 : float | None

Rounding radius on end rims (overall/bottom/top)

rounding2 : float | None

Rounding radius on end rims (overall/bottom/top)

chamfer : float | None

Chamfer size on end rims (overall/bottom/top)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | None

Chamfer size on end rims (overall/bottom/top)

chamfer2 : float | None

Chamfer size on end rims (overall/bottom/top)

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> DOWN)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

inner_diameter1 : float | None

inner diameter of the bottom/top (CSG backend).

inner_diameter2 : float | None

inner diameter of the bottom/top (CSG backend).

inner_radius1 : float | None

inner radius of the bottom/top (CSG backend).

inner_radius2 : float | None

inner radius of the bottom/top (CSG backend).

outer_diameter1 : float | None

outer diameter of the bottom/top (CSG backend).

outer_diameter2 : float | None

outer diameter of the bottom/top (CSG backend).

outer_radius1 : float | None

outer radius of the bottom/top (CSG backend).

outer_radius2 : float | None

outer radius of the bottom/top (CSG backend).

realign : bool | None

rotate by half the angle of one face (default False) (CSG backend).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import tube

shape = tube(height=20, outer_radius=15, inner_radius=10)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

A tube with chamfered end rims:

from pybosl2 import tube

shape = tube(height=20, outer_radius=15, inner_radius=10, chamfer=1)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.wedge(size=(1, 1, 1), *, anchor=Point(-1.0, -1.0, -1.0), center=None, spin=0, orient=Anchor.TOP, placement=None, res=None)[source]

Return a wedge on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
size : Sequence[float] | None

[width, thickness, height].

anchor : Anchor | Sequence[float] | None

Anchor point (default FRONT+LEFT+BOTTOM)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> FRONT+LEFT+BOTTOM)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import wedge

wedge([30, 20, 15]).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.xcyl(height=None, radius=None, *, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, chamfer=None, treatment=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, anchor=None, center=None, spin=0, orient=Anchor.TOP, placement=None, chamfer_angle=None, chamfer_angle1=None, chamfer_angle2=None, circumscribe=False, clip_angle=90.0, extra=0.0, extra1=None, extra2=None, from_end=False, from_end1=None, from_end2=None, realign=False, shift=(0, 0), teardrop=False, tex_depth=1.0, tex_inset=False, tex_reps=None, tex_size=None, texture=None, texturing=None, fn=None, fa=None, fs=None, res=None)[source]

Return a xcyl on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Length of the cylinder along its axis (default 1)

radius : float | None

Radius of the cylinder (default 1)

length : float | None

Length of the cylinder along its axis (default 1)

radius1 : float | None

Radius of the negative end of the cylinder.

radius2 : float | None

Radius of the positive end of the cylinder.

diameter : float | None

Diameter of the cylinder.

diameter1 : float | None

Diameter of the negative end of the cylinder.

diameter2 : float | None

Diameter of the positive end of the cylinder.

chamfer : float | None

Chamfer size on the end rims (overall/negative/positive)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | None

Chamfer size on the end rims (overall/negative/positive)

chamfer2 : float | None

Chamfer size on the end rims (overall/negative/positive)

rounding : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding1 : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding2 : float | None

Rounding radius on the end rims (overall/negative/positive)

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> BOTTOM)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

chamfer_angle : float | None

End chamfer angle in degrees away from the ends (CSG backend).

chamfer_angle1 : float | None

Chamfer angle at the bottom end (CSG backend).

chamfer_angle2 : float | None

Chamfer angle at the top end (CSG backend).

circumscribe : bool | None

Circumscribe rather than inscribe the given radius (CSG backend).

clip_angle : float | None

Clip the rounding arc at the bottom of the cylinder (CSG backend).

extra : float | None

Extra height at both ends, invisible to anchoring (CSG backend).

extra1 : float | None

Extra height at the bottom end (CSG backend).

extra2 : float | None

Extra height at the top end (CSG backend).

from_end : bool | None

Measure the chamfer along the conic face rather than the axis (CSG backend).

from_end1 : bool | None

Measure the bottom chamfer along the conic face (CSG backend).

from_end2 : bool | None

Measure the top chamfer along the conic face (CSG backend).

realign : bool | None

Shift point alignment by half a facet (CSG backend).

shift : Sequence[float] | None

[x, y] offset for the positive end, shearing the solid (CSG backend).

teardrop : bool | float | None

Limit the rounding angle from horizontal, for printability (CSG backend).

tex_depth : float | None

Depth of the texture (CSG backend).

tex_inset : bool | float | None

Inset the texture into the surface (CSG backend).

tex_reps : int | Sequence[int] | None

Number of texture repetitions (CSG backend).

tex_size : float | Sequence[float] | None

Size of one texture tile (CSG backend).

texture : Any

Named texture for the side surface (CSG backend).

texturing : Texturing | None

The texture and how it is applied, as one value (SPEC G-1). Giving it beside any of the tex_* arguments raises (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import xcyl

shape = xcyl(radius=10, height=30)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.ycyl(height=None, radius=None, *, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, chamfer=None, treatment=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, anchor=None, center=None, spin=0, orient=Anchor.TOP, placement=None, chamfer_angle=None, chamfer_angle1=None, chamfer_angle2=None, circumscribe=False, clip_angle=90.0, extra=0.0, extra1=None, extra2=None, from_end=False, from_end1=None, from_end2=None, realign=False, shift=(0, 0), teardrop=False, tex_depth=1.0, tex_inset=False, tex_reps=None, tex_size=None, texture=None, texturing=None, fn=None, fa=None, fs=None, res=None)[source]

Return a ycyl on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Length of the cylinder along its axis (default 1)

radius : float | None

Radius of the cylinder (default 1)

length : float | None

Length of the cylinder along its axis (default 1)

radius1 : float | None

Radius of the negative end of the cylinder.

radius2 : float | None

Radius of the positive end of the cylinder.

diameter : float | None

Diameter of the cylinder.

diameter1 : float | None

Diameter of the negative end of the cylinder.

diameter2 : float | None

Diameter of the positive end of the cylinder.

chamfer : float | None

Chamfer size on the end rims (overall/negative/positive)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | None

Chamfer size on the end rims (overall/negative/positive)

chamfer2 : float | None

Chamfer size on the end rims (overall/negative/positive)

rounding : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding1 : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding2 : float | None

Rounding radius on the end rims (overall/negative/positive)

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> BOTTOM)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

chamfer_angle : float | None

End chamfer angle in degrees away from the ends (CSG backend).

chamfer_angle1 : float | None

Chamfer angle at the bottom end (CSG backend).

chamfer_angle2 : float | None

Chamfer angle at the top end (CSG backend).

circumscribe : bool | None

Circumscribe rather than inscribe the given radius (CSG backend).

clip_angle : float | None

Clip the rounding arc at the bottom of the cylinder (CSG backend).

extra : float | None

Extra height at both ends, invisible to anchoring (CSG backend).

extra1 : float | None

Extra height at the bottom end (CSG backend).

extra2 : float | None

Extra height at the top end (CSG backend).

from_end : bool | None

Measure the chamfer along the conic face rather than the axis (CSG backend).

from_end1 : bool | None

Measure the bottom chamfer along the conic face (CSG backend).

from_end2 : bool | None

Measure the top chamfer along the conic face (CSG backend).

realign : bool | None

Shift point alignment by half a facet (CSG backend).

shift : Sequence[float] | None

[x, y] offset for the positive end, shearing the solid (CSG backend).

teardrop : bool | float | None

Limit the rounding angle from horizontal, for printability (CSG backend).

tex_depth : float | None

Depth of the texture (CSG backend).

tex_inset : bool | float | None

Inset the texture into the surface (CSG backend).

tex_reps : int | Sequence[int] | None

Number of texture repetitions (CSG backend).

tex_size : float | Sequence[float] | None

Size of one texture tile (CSG backend).

texture : Any

Named texture for the side surface (CSG backend).

texturing : Texturing | None

The texture and how it is applied, as one value (SPEC G-1). Giving it beside any of the tex_* arguments raises (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import ycyl

shape = ycyl(radius=10, height=30)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.zcyl(height=None, radius=None, *, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, chamfer=None, treatment=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, anchor=None, center=None, spin=0, orient=Anchor.TOP, placement=None, chamfer_angle=None, chamfer_angle1=None, chamfer_angle2=None, circumscribe=False, clip_angle=90.0, extra=0.0, extra1=None, extra2=None, from_end=False, from_end1=None, from_end2=None, realign=False, shift=(0, 0), teardrop=False, tex_depth=1.0, tex_inset=False, tex_reps=None, tex_size=None, texture=None, texturing=None, fn=None, fa=None, fs=None, res=None)[source]

Return a zcyl on the active backend.

The same call builds the same shape on either backend: the façade owns the default for every argument both understand and forwards it (see use_backend(), and effective_defaults() to see what an omitted argument resolves to). Options only one backend has are marked below; each backend receives only what its own constructor declares.

Parameters:
height : float | None

Length of the cylinder along its axis (default 1)

radius : float | None

Radius of the cylinder (default 1)

length : float | None

Length of the cylinder along its axis (default 1)

radius1 : float | None

Radius of the negative end of the cylinder.

radius2 : float | None

Radius of the positive end of the cylinder.

diameter : float | None

Diameter of the cylinder.

diameter1 : float | None

Diameter of the negative end of the cylinder.

diameter2 : float | None

Diameter of the positive end of the cylinder.

chamfer : float | None

Chamfer size on the end rims (overall/negative/positive)

treatment : EdgeTreatment | None

A rounding or a chamfer as one value (SPEC G-1). An edge is rounded or chamfered, never both, so this makes the pair unrepresentable rather than checked; giving it beside rounding= or chamfer= raises (SPEC G-3).

chamfer1 : float | None

Chamfer size on the end rims (overall/negative/positive)

chamfer2 : float | None

Chamfer size on the end rims (overall/negative/positive)

rounding : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding1 : float | None

Rounding radius on the end rims (overall/negative/positive)

rounding2 : float | None

Rounding radius on the end rims (overall/negative/positive)

anchor : Anchor | Sequence[float] | None

Anchor point (default CENTER)

center : bool | None

If given, overrides anchor (True -> CENTER, False -> BOTTOM)

spin : float | None

Z-axis rotation in degrees after anchor (default 0)

orient : Anchor | Sequence[float] | None

Direction to rotate the top towards, after spin (default UP)

placement : Placement | None

Anchor, spin and orient as one reusable value (SPEC G-1). Giving this and any of those three raises, since the call cannot mean both (SPEC G-3).

chamfer_angle : float | None

End chamfer angle in degrees away from the ends (CSG backend).

chamfer_angle1 : float | None

Chamfer angle at the bottom end (CSG backend).

chamfer_angle2 : float | None

Chamfer angle at the top end (CSG backend).

circumscribe : bool | None

Circumscribe rather than inscribe the given radius (CSG backend).

clip_angle : float | None

Clip the rounding arc at the bottom of the cylinder (CSG backend).

extra : float | None

Extra height at both ends, invisible to anchoring (CSG backend).

extra1 : float | None

Extra height at the bottom end (CSG backend).

extra2 : float | None

Extra height at the top end (CSG backend).

from_end : bool | None

Measure the chamfer along the conic face rather than the axis (CSG backend).

from_end1 : bool | None

Measure the bottom chamfer along the conic face (CSG backend).

from_end2 : bool | None

Measure the top chamfer along the conic face (CSG backend).

realign : bool | None

Shift point alignment by half a facet (CSG backend).

shift : Sequence[float] | None

[x, y] offset for the positive end, shearing the solid (CSG backend).

teardrop : bool | float | None

Limit the rounding angle from horizontal, for printability (CSG backend).

tex_depth : float | None

Depth of the texture (CSG backend).

tex_inset : bool | float | None

Inset the texture into the surface (CSG backend).

tex_reps : int | Sequence[int] | None

Number of texture repetitions (CSG backend).

tex_size : float | Sequence[float] | None

Size of one texture tile (CSG backend).

texture : Any

Named texture for the side surface (CSG backend).

texturing : Texturing | None

The texture and how it is applied, as one value (SPEC G-1). Giving it beside any of the tex_* arguments raises (SPEC G-3).

fn : int | None

Fixed fragment count for curved surfaces; the ambient default applies when omitted, and 0 means “use fa/fs” (CSG backend). Omitted, the ambient use_defaults(fn=...) value applies; fn=0 opts back out to fa/fs.

fa : float | None

Minimum fragment angle in degrees; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fa=...) value applies.

fs : float | None

Minimum fragment size in millimetres; ambient default when omitted (CSG backend). Omitted, the ambient use_defaults(fs=...) value applies.

res : int | None

Sampling resolution; ambient default when omitted (SDF backend). Omitted, the ambient use_defaults(res=...) value applies.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import zcyl

shape = zcyl(radius=10, height=30)
shape.show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.polyhedron(points, faces=None, convexity=None)[source]

Return a polyhedron on the active backend.

Backends differ on what a polyhedron means (this is not part of the shared primitive surface): the CSG backend builds the exact mesh from points and faces (both required); the SDF backend builds the intersection of the face half-spaces, which can only describe a convex solid. For convex input the two agree. For anything else the SDF backend refuses rather than handing back the hull – which would fill the concavities, report the same bounding box, and give no sign that it was not what you asked for (SPEC B-4, B-9).

Parameters:
points : Any

The vertices, as [x, y, z] triples.

faces : Any

Vertex indices per face. Required by the CSG backend; on the SDF backend they must bound a convex solid.

convexity : int | None

Convexity hint for preview rendering (CSG backend).

Raises:

UnsupportedByBackendError – On the SDF backend, if faces bound a non-convex solid.

Returns:

The solid, built by whichever backend is active.

Return type:

Solid

Examples

from pybosl2 import polyhedron

points = [[0, 0, 0], [20, 0, 0], [10, 18, 0], [10, 6, 16]]
faces = [[0, 2, 1], [0, 1, 3], [1, 2, 3], [2, 0, 3]]
polyhedron(points, faces).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.union(*solids)[source]

Return the union of solids on the active backend.

Parameters:
solids : Solid

The shapes to combine; all must share a backend (SPEC C-1).

Returns:

One solid covering all of them.

Raises:

ValueError – If no solids are given.

Return type:

Solid

Examples

from pybosl2 import cuboid, cyl, union

union(cuboid([20, 20, 10]), cyl(height=20, radius=5)).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.difference(*solids)[source]

Return the first solid minus the rest, on the active backend.

Parameters:
solids : Solid

The shape to cut from, then the shapes to remove.

Returns:

The first solid with the others carved out of it.

Raises:

ValueError – If no solids are given.

Return type:

Solid

Examples

from pybosl2 import cuboid, cyl, difference

difference(cuboid([20, 20, 10]), cyl(height=30, radius=5)).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.intersection(*solids)[source]

Return the intersection of solids on the active backend.

Parameters:
solids : Solid

The shapes to intersect; all must share a backend.

Returns:

The solid covered by every one of them.

Raises:

ValueError – If no solids are given.

Return type:

Solid

Examples

from pybosl2 import cuboid, sphere, intersection

intersection(cuboid([20, 20, 20]), sphere(radius=13)).show()
Loading 3-D preview…

⬇ Download STL mesh

pybosl2.solid.use_backend(name)[source]

Make name the active backend for the duration of the with block (nestable, thread-safe).

Parameters:
name : str

The name to look up.

Return type:

Iterator[None]

pybosl2.solid.set_default_backend(name)[source]

Change the process-wide default backend (outside any use_backend() block).

Parameters:
name : str

The name to look up.

Return type:

None

pybosl2.solid.current_backend()[source]

Return the backend active in this context (default "csg").

Return type:

str

class pybosl2.solid.Solid(*args, **kwargs)[source]

Bases: Shape, Protocol

A 3-D shape: Shape plus what only three dimensions can do.

.to_csg() / .to_sdf() convert between the backends; projection() is the one way down to 2-D (SPEC C-17).

bounds()[source]

Return the 3-D axis-aligned bounding box (SPEC S-2b).

Return type:

Bounds3D

vnf()[source]

Return this solid as a mesh (SPEC C-8, S-19a).

A method rather than a property because it does real work – meshing a field, or crossing the FFI for a native tessellation – and because isinstance against a runtime-checkable Protocol calls hasattr on every declared member, which evaluates a property (PLAN T-6e). As a property this meshed an SDF field on every isinstance(shape, Solid) and, where no mesher was available, raised out of the check.

Return type:

VNF

export(path, *, file_format=None, check=True)[source]

Write this solid to a mesh file (SPEC S-53).

Parameters:
path : str | os.PathLike[str]

The path to draw.

file_format : str | None

The format to write, taken from the suffix when not given.

check : bool

Validate the mesh before writing it.

Return type:

FilePath

rotate(a=None, v=None)[source]
Parameters:
a : float | Sequence[float] | None

v : Sequence[float] | None

Return type:

Solid

up(z)[source]
Parameters:
z : float

Return type:

Self

down(z)[source]
Parameters:
z : float

Return type:

Self

left(x)[source]
Parameters:
x : float

Return type:

Self

right(x)[source]
Parameters:
x : float

Return type:

Self

forward(y)[source]
Parameters:
y : float

Return type:

Self

back(y)[source]
Parameters:
y : float

Return type:

Self

multmatrix(m)[source]
Parameters:
m : Any

Return type:

Self

color(c=None, alpha=None)[source]
Parameters:
c : Any

alpha : float | None

Return type:

Self

hull(*others, **kwargs)[source]
Parameters:
others : Any

kwargs : Any

Return type:

Self

half_of(v=Ellipsis, center=None, s=None, cut_path=None, cut_angle=0, offset=0)[source]
Parameters:
v : Any

center : Any

s : float | None

cut_path : Any

cut_angle : float

offset : float

Return type:

Self

left_half(x=0, s=None)[source]
Parameters:
x : float

s : float | None

Return type:

Self

right_half(x=0, s=None)[source]
Parameters:
x : float

s : float | None

Return type:

Self

front_half(y=0, s=None)[source]
Parameters:
y : float

s : float | None

Return type:

Self

back_half(y=0, s=None)[source]
Parameters:
y : float

s : float | None

Return type:

Self

top_half(z=0, s=None)[source]
Parameters:
z : float

s : float | None

Return type:

Self

bottom_half(z=0, s=None)[source]
Parameters:
z : float

s : float | None

Return type:

Self

partition(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

tuple[Self, Self]

edge_mask(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

edge_profile(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

edge_profile_asym(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

corner_profile(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

face_profile(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

round_edges(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

chamfer_edges(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

cove_edges(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

projection(cut=False)[source]
Parameters:
cut : bool

Return type:

Any

offset3d(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

round3d(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

wrap(radius, fn=None)[source]
Parameters:
radius : float

fn : int | None

Return type:

Self

oversample(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

repair(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

chain_hull(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

minkowski_difference(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Self

to_csg(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Any

to_sdf(*args, **kwargs)[source]
Parameters:
args : Any

kwargs : Any

Return type:

Any

anchor_point(anchor, bbox=None)[source]
Parameters:
anchor : Any

bbox : Sequence[Sequence[float]] | None

Return type:

list[float]

reanchor(anchor, bbox=None)[source]
Parameters:
anchor : Any

bbox : Sequence[Sequence[float]] | None

Return type:

Self

reorient(anchor=Ellipsis, spin=0, orient=Ellipsis, bbox=None)[source]
Parameters:
anchor : Any

spin : float

orient : Any

bbox : Sequence[Sequence[float]] | None

Return type:

Self

orient(direction=Ellipsis, spin=0, bbox=None)[source]
Parameters:
direction : Any

spin : float

bbox : Sequence[Sequence[float]] | None

Return type:

Self

exception pybosl2.solid.CrossBackendError(left, right)[source]

Bases: Bosl2Error

A boolean/transform combined solids from two different backends.

Solids must share a backend to be combined. Convert one first: meshing an SDF solid into a CSG polyhedron is exact (sdf_solid.to_csg()); voxel-sampling a CSG solid into an SDF is lossy and opt-in (csg_solid.to_sdf(voxel_size=...)).

Parameters:
left : str

backend of the left operand.

right : str

backend of the right operand.

Return type:

None

exception pybosl2.solid.UnsupportedByBackendError(feature, backend, hint=None)[source]

Bases: Bosl2Error, AttributeError

A feature the active backend cannot express.

Also an AttributeError, because a backend refuses most often from __getattr__ and Python’s attribute protocol is defined in terms of that type (SPEC E-6): hasattr() and getattr(obj, name, default) catch AttributeError and nothing else, so any other type turns a capability probe into a traceback and breaks copy, pickle, inspect and every REPL completion. The extra base is invisible to a refusal raised from a call.

Raised, rather than silently producing different geometry, when a call needs something the chosen backend has no faithful equivalent for – e.g. the BOSL2 attachment/anchor system on the "sdf" backend, or a smooth-blend union on the "csg" backend.

Parameters:
feature : str

short name of the unsupported operation (e.g. "attach", "smooth_union").

backend : str

the active backend that cannot do it ("csg" / "sdf").

hint : str | None

optional guidance (an alternative call, or which backend does support it).

Return type:

None