Solid¶
Statically typed shape constructors and backend-neutral solid facade.
-
pybosl2.solid.cube(size=
None, *, chamfer=None, rounding=None, anchor=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a cube on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.cube()).
-
pybosl2.solid.cuboid(size=
None, *, chamfer=None, rounding=None, edges=None, except_edges=None, anchor=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a cuboid on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.cuboid()).- Parameters:¶
- size : float | Sequence[float] | None¶
- chamfer : float | None¶
- rounding : float | None¶
- edges : EdgeAtom | list[EdgeAtom] | None¶
- except_edges : list[EdgeAtom] | None¶
- anchor : Anchor | Sequence[float] | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.cyl(height=
None, radius=None, *, center=None, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, chamfer=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, shift=None, anchor=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a cyl on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.cyl()).- Parameters:¶
- height : float | None¶
- radius : float | None¶
- center : bool | None¶
- length : float | None¶
- radius1 : float | None¶
- radius2 : float | None¶
- diameter : float | None¶
- diameter1 : float | None¶
- diameter2 : float | None¶
- chamfer : float | None¶
- chamfer1 : float | None¶
- chamfer2 : float | None¶
- rounding : float | None¶
- rounding1 : float | None¶
- rounding2 : float | None¶
- shift : Sequence[float] | None¶
- anchor : Anchor | Sequence[float] | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.cylinder(height=
None, radius=None, *, chamfer=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=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a cylinder on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.cylinder()).- Parameters:¶
- height : float | None¶
- radius : float | None¶
- chamfer : float | None¶
- chamfer1 : float | None¶
- chamfer2 : float | None¶
- rounding : float | None¶
- rounding1 : float | None¶
- rounding2 : float | None¶
- center : bool | None¶
- length : float | None¶
- radius1 : float | None¶
- radius2 : float | None¶
- diameter : float | None¶
- diameter1 : float | None¶
- diameter2 : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.octahedron(size=
None, *, anchor=None, spin=None, orient=None, res=None)[source]¶ Return an octahedron on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.octahedron()).
-
pybosl2.solid.onion(radius=
None, *, angle=None, cap_height=None, diameter=None, anchor=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return an onion on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.onion()).
-
pybosl2.solid.pie_slice(height=
None, radius=None, *, angle=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, length=None, anchor=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a pie_slice on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.pie_slice()).- Parameters:¶
- height : float | None¶
- radius : float | None¶
- angle : float | None¶
- radius1 : float | None¶
- radius2 : float | None¶
- diameter : float | None¶
- diameter1 : float | None¶
- diameter2 : float | None¶
- length : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.prismoid(size1=
None, size2=None, *, height=None, shift=None, length=None, anchor=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a prismoid on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.prismoid()).- Parameters:¶
- size1 : Sequence[float] | None¶
- size2 : Sequence[float] | None¶
- height : float | None¶
- shift : Sequence[float] | None¶
- length : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.rect_tube(height=
None, size=None, *, isize=None, wall=None, rounding=None, inner_rounding=None, anchor=None, length=None, center=None, spin=None, orient=None, res=None)[source]¶ Return a rect_tube on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.rect_tube()).- Parameters:¶
- height : float | None¶
- size : float | Sequence[float] | None¶
- isize : float | Sequence[float] | None¶
- wall : float | None¶
- rounding : float | Sequence[float] | None¶
- inner_rounding : float | Sequence[float] | None¶
- anchor : Anchor | Sequence[float] | None¶
- length : float | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.regular_prism(sides=
None, height=None, radius=None, *, diameter=None, inner_radius=None, inner_diameter=None, side=None, length=None, realign=None, anchor=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a regular_prism on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.regular_prism()).- Parameters:¶
- sides : int | None¶
- height : float | None¶
- radius : float | None¶
- diameter : float | None¶
- inner_radius : float | None¶
- inner_diameter : float | None¶
- side : float | None¶
- length : float | None¶
- realign : bool | None¶
- anchor : Anchor | Sequence[float] | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.sphere(radius=
None, *, diameter=None, anchor=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a sphere on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.sphere()).
-
pybosl2.solid.spheroid(radius=
None, *, diameter=None, anchor=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a spheroid on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.spheroid()).
-
pybosl2.solid.teardrop(height=
None, radius=None, *, angle=None, cap_height=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, anchor=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a teardrop on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.teardrop()).- Parameters:¶
- height : float | None¶
- radius : float | None¶
- angle : float | None¶
- cap_height : float | None¶
- radius1 : float | None¶
- radius2 : float | None¶
- diameter : float | None¶
- diameter1 : float | None¶
- diameter2 : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
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=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a torus on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.torus()).- Parameters:¶
- major_radius : float | None¶
- minor_radius : float | None¶
- major_diameter : float | None¶
- minor_diameter : float | None¶
- outer_radius : float | None¶
- inner_radius : float | None¶
- outer_diameter : float | None¶
- inner_diameter : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.tube(height=
None, outer_radius=None, *, inner_radius=None, outer_diameter=None, inner_diameter=None, wall=None, length=None, anchor=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a tube on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.tube()).- Parameters:¶
- height : float | None¶
- outer_radius : float | None¶
- inner_radius : float | None¶
- outer_diameter : float | None¶
- inner_diameter : float | None¶
- wall : float | None¶
- length : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.wedge(size=
None, *, anchor=None, center=None, spin=None, orient=None, res=None)[source]¶ Return a wedge on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.wedge()).
-
pybosl2.solid.xcyl(height=
None, radius=None, *, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, chamfer=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, anchor=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a xcyl on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.xcyl()).- Parameters:¶
- height : float | None¶
- radius : float | None¶
- length : float | None¶
- radius1 : float | None¶
- radius2 : float | None¶
- diameter : float | None¶
- diameter1 : float | None¶
- diameter2 : float | None¶
- chamfer : float | None¶
- chamfer1 : float | None¶
- chamfer2 : float | None¶
- rounding : float | None¶
- rounding1 : float | None¶
- rounding2 : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.ycyl(height=
None, radius=None, *, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, chamfer=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, anchor=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a ycyl on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.ycyl()).- Parameters:¶
- height : float | None¶
- radius : float | None¶
- length : float | None¶
- radius1 : float | None¶
- radius2 : float | None¶
- diameter : float | None¶
- diameter1 : float | None¶
- diameter2 : float | None¶
- chamfer : float | None¶
- chamfer1 : float | None¶
- chamfer2 : float | None¶
- rounding : float | None¶
- rounding1 : float | None¶
- rounding2 : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
pybosl2.solid.zcyl(height=
None, radius=None, *, length=None, radius1=None, radius2=None, diameter=None, diameter1=None, diameter2=None, chamfer=None, chamfer1=None, chamfer2=None, rounding=None, rounding1=None, rounding2=None, anchor=None, center=None, spin=None, orient=None, fn=None, fa=None, fs=None, res=None)[source]¶ Return a zcyl on the active backend.
See
use_backend(); identical call, backend-appropriate realization. Only the arguments actually given are passed on, so each backend sees the ones it knows: res is the SDF backend’s resolution and spin/orient/fn/fa/fs are the CSG backend’s. Anything outside this shared set lives on the backend’s own constructor (pybosl2.shapes3d.zcyl()).- Parameters:¶
- height : float | None¶
- radius : float | None¶
- length : float | None¶
- radius1 : float | None¶
- radius2 : float | None¶
- diameter : float | None¶
- diameter1 : float | None¶
- diameter2 : float | None¶
- chamfer : float | None¶
- chamfer1 : float | None¶
- chamfer2 : float | None¶
- rounding : float | None¶
- rounding1 : float | None¶
- rounding2 : float | None¶
- anchor : Anchor | Sequence[float] | None¶
- center : bool | None¶
- spin : float | None¶
- orient : Anchor | Sequence[float] | None¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- res : int | None¶
- Return type:¶
-
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 ignores faces and builds the convex hull of points as a distance field.
- pybosl2.solid.union(*solids)[source]¶
Return the union of solids on the active backend (all operands must share the active backend).
- pybosl2.solid.difference(*solids)[source]¶
Return the first solid minus the rest, on the active backend.
- pybosl2.solid.intersection(*solids)[source]¶
Return the intersection of solids on the active backend.
- pybosl2.solid.use_backend(name)[source]¶
Make name the active backend for the duration of the
withblock (nestable, thread-safe).
- pybosl2.solid.set_default_backend(name)[source]¶
Change the process-wide default backend (outside any
use_backend()block).
- 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:
ProtocolThe common solid contract both backend wrappers satisfy.
A
Solidcarries abackendtag; booleans/transforms return aSolidon the same backend, and combining solids from two backends raisesCrossBackendError..to_csg()/.to_sdf()convert between them.- backend : str¶
- exception pybosl2.solid.CrossBackendError(left, right)[source]¶
Bases:
Bosl2ErrorA 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=...)).
-
exception pybosl2.solid.UnsupportedByBackendError(feature, backend, hint=
None)[source]¶ Bases:
Bosl2ErrorA feature the active backend cannot express.
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.