Ops¶
⚙️ Spec sheet → — visual schematic and metrics measured from a real rendered STL.
Boolean operations, offsets, text and cross helpers.
- pybosl2.shapes2d.ops.fill(children)[source]¶
children with every hole filled in – only the outermost outline survives.
(OpenSCAD
fill(), the module form ofBosl2Shape2D.fill()).
- pybosl2.shapes2d.ops.hull(*children)[source]¶
Return the 2-D convex hull of children (OpenSCAD
hull(), the module form of.Bosl2Shape2D.hull()).
-
pybosl2.shapes2d.ops.round2d(radius=
None, outer_radius=None, inner_radius=None, children=None, fn=None, fa=None, fs=None)[source]¶ Round the concave and/or convex corners of arbitrary 2-D children, via chained .offset() calls.
Giving radius rounds all corners; inner_radius alone rounds only concave corners; outer_radius alone rounds only convex corners; giving both rounds each to a different radius.
Note: BOSL2’s outer-radius parameter is named or, exposed here as outer_radius.
- Parameters:¶
- radius : float | None¶
radius to round all concave and convex corners to
- outer_radius : float | None¶
radius to round only convex (outside) corners to (BOSL2 or)
- inner_radius : float | None¶
radius to round only concave (inside) corners to
- children : Bosl2Shape2D | PyOpenSCAD | None¶
the 2-D solid(s) to round
- fn : int | None¶
arc smoothness overrides
- fa : float | None¶
arc smoothness overrides
- fs : float | None¶
arc smoothness overrides
- Return type:¶
Bosl2Shape2D
-
pybosl2.shapes2d.ops.shell2d(thickness=
None, outer_radius=0, inner_radius=0, children=None, fn=None, fa=None, fs=None)[source]¶ Create a hollow shell from 2-D children, with optional rounding.
Note: BOSL2’s outer-radius parameter is named or, exposed here as outer_radius.
- Parameters:¶
- thickness : float | Sequence[float] | None¶
shell thickness; positive expands outward, negative shrinks inward, or a 2-element list to do both
- outer_radius : float | Sequence[float]¶
rounding radius for outside corners of the shell (BOSL2 or); a [CONVEX,CONCAVE] pair rounds those corner types separately (default 0)
- inner_radius : float | Sequence[float]¶
rounding radius for inside corners of the shell; a [CONVEX,CONCAVE] pair rounds those corner types separately (default 0)
- children : Bosl2Shape2D | PyOpenSCAD | None¶
the 2-D solid(s) to shell
- fn : int | None¶
arc smoothness overrides
- fa : float | None¶
arc smoothness overrides
- fs : float | None¶
arc smoothness overrides
- Return type:¶
Bosl2Shape2D
-
pybosl2.shapes2d.ops.cross(size=
[10, 10], arm_width=None, center=None, anchor=Anchor.CENTER, spin=0)[source]¶ Return a 2-D cross (plus) shape: two perpendicular centred rectangles.
- Parameters:¶
- size : float | Sequence[float]¶
overall size, a scalar square or
[width, length](default[10, 10]).- arm_width : float | Sequence[float] | None¶
width of each arm; a scalar or
[horizontal, vertical]pair. When None (default) the arms are one-third of the overall size.- center : bool | None¶
centre alignment (default True).
- anchor : Anchor | Sequence[float]¶
anchor point (default CENTER).
- spin : float¶
Z-axis rotation in degrees after anchor (default 0).
- Returns:¶
A
Bosl2Shape2Dwrapping the cross polygon.- Return type:¶
CsgShape2D
Examples
from pybosl2 import shapes2d as s2 s2.cross(size=30).linear_extrude(height=5).show()Loading 3-D preview…
-
pybosl2.shapes2d.ops.text(text, size=
10, font='Liberation Sans', halign=None, valign=None, spacing=1.0, direction='ltr', language='en', script='latin', anchor='baseline', spin=0, fn=None, fa=None, fs=None)[source]¶ 2-D text, built directly with the builtin text() (which already supports halign/valign).
- Parameters:¶
- text : str¶
text to create
- size : float¶
font size (default 10)
- font : str¶
font to use (default “Liberation Sans”)
- halign : str | None¶
horizontal alignment: “left”, “center”, “right” (default “center”)
- valign : str | None¶
vertical alignment: “top”, “center”, “baseline”, “bottom” (default: anchor)
- spacing : float¶
relative spacing multiplier between characters (default 1.0)
- direction : str¶
text direction: “ltr”, “rtl”, “ttb”, “btt” (default “ltr”)
- language : str¶
language the text is in (default “en”)
- script : str¶
script the text is in (default “latin”)
- anchor : str¶
vertical alignment fallback used when valign isn’t given (default “baseline”)
- spin : float¶
Z-axis rotation in degrees (default 0)
- fn : int | None¶
number of fragments for circle resolution.
- fa : float | None¶
minimum fragment angle for circle resolution.
- fs : float | None¶
minimum fragment size for circle resolution.
- Return type:¶
CsgShape2D