Native-only mesh operations

These operations wrap PythonSCAD builtins that BOSL2 has no counterpart for, exposed as first-class pybosl2.shapes3d.Bosl2Solid methods (and one 2-D→3-D constructor) so they chain fluently and keep their anchoring metadata, rather than leaking raw native handles. They execute only inside the real PythonSCAD app; under the numeric test mock they degrade to identity/AABB stand-ins, so the pure-Python fast suite still runs and the real geometry is covered by the STL render tests.

Operation

Kind

What it does

solid.repair()

solid → solid

Force the mesh watertight, healing gaps and non-manifold edges.

solid.oversample(n)

solid → solid

Subdivide every facet n-fold (e.g. to smooth a subsequent bend).

solid.pull(direction, distance)

solid → solid

Pull the material on the +direction side apart, stretching what is between.

solid.wrap(r, _fn=…)

solid → solid

Wrap the solid around a cylinder of radius r (bends +X into the circumference).

solid.separate()

solid → list of solids

Split a solid of disconnected lumps into its connected components.

solid.inside(point)

solid → bool

Test whether a point lies inside the solid.

pybosl2.roof(shape2d)

2-D → solid

Raise a hip roof over a 2-D outline via its straight skeleton.

Note

wrap() is a valid operation but meshing/exporting a wrapped solid is very slow in the Manifold backend, so it has no render test (only mock-level coverage). Call pybosl2.shapes3d.Bosl2Solid.oversample() first if you need the bend to look smooth.

Examples

A hip roof raised over a square outline (a pyramid; over any polygon it is a proper straight-skeleton roof):

from pybosl2 import roof, shapes2d as s2

roof(s2.square([30, 30], center=True)).show()
Loading 3-D preview…

⬇ Download STL mesh

Oversampling subdivides a solid’s facets without changing its shape – useful before a bend or a displacement:

from pybosl2 import cuboid

cuboid([30, 30, 12]).oversample(3).show()
Loading 3-D preview…

⬇ Download STL mesh

Pulling a block apart stretches the material between the halves:

from pybosl2 import cuboid

cuboid([24, 24, 12]).pull([0, 0, 1], 8).show()
Loading 3-D preview…

⬇ Download STL mesh

API reference

The methods live on shapes3d (pybosl2.shapes3d.Bosl2Solid.repair(), pybosl2.shapes3d.Bosl2Solid.oversample(), pybosl2.shapes3d.Bosl2Solid.pull(), pybosl2.shapes3d.Bosl2Solid.wrap(), pybosl2.shapes3d.Bosl2Solid.separate(), pybosl2.shapes3d.Bosl2Solid.inside()); the roof constructor is shapes3d().

pybosl2.shapes3d.roof(shape, method='straight')[source]

Raise a hip roof over a 2-D shape via its straight skeleton (native roof()).

Like linear_sweep(), this turns a 2-D outline into a 3-D solid, but the top is a peaked roof (each edge slopes inward at 45 degrees to the skeleton) rather than a flat extrusion. shape is any 2-D object – a native square/circle/polygon, a Path2D.polygon(), or a Bosl2Solid wrapping one. method selects the skeleton algorithm. PythonSCAD-only (no BOSL2 counterpart); covered by the STL render tests.

Examples

from pybosl2 import roof, shapes2d as s2

roof(s2.square([20, 10]).shape).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
shape : object

method : str

Return type:

CsgSolid