MCPcopy
hub / github.com/CadQuery/cadquery / solid

Function solid

cadquery/occ_impl/shapes.py:6137–6166  ·  view source on GitHub ↗

Build solid from faces or shells.

(
    s1: Shape,
    *sn: Shape,
    tol: float = 1e-6,
    history: History | None = None,
    name: str | None = None,
)

Source from the content-addressed store, hash-verified

6135
6136@multidispatch
6137def solid(
6138 s1: Shape,
6139 *sn: Shape,
6140 tol: float = 1e-6,
6141 history: History | None = None,
6142 name: str | None = None,
6143) -> Compound | Solid:
6144 """
6145 Build solid from faces or shells.
6146 """
6147
6148 builder = ShapeFix_Solid()
6149
6150 # get both Shells and Faces
6151 s = [s1, *sn]
6152 shells_faces = [f for el in s for f in _get(el, ("Shell", "Face"))]
6153
6154 # if no shells are present, use faces to construct them
6155 shells = [el.wrapped for el in shells_faces if isinstance(el, Shell)]
6156 if not shells:
6157 faces = [el for el in shells_faces if isinstance(el, Face)]
6158 shells = [
6159 tcast(
6160 TopoDS_Shell, shell(*faces, tol=tol, history=history, name=name).wrapped
6161 )
6162 ]
6163
6164 rvs = [builder.SolidFromShell(sh) for sh in shells]
6165
6166 return tcast(Compound | Solid, _compound_or_shape(rvs))
6167
6168
6169@multidispatch

Callers 4

sweepFunction · 0.85
loftFunction · 0.85
test_sewingFunction · 0.85
test_solidFunction · 0.85

Calls 7

_getFunction · 0.85
shellFunction · 0.85
_compound_or_shapeFunction · 0.85
_get_oneFunction · 0.85
_combine_opsFunction · 0.85
_shapeFunction · 0.85
popMethod · 0.45

Tested by 2

test_sewingFunction · 0.68
test_solidFunction · 0.68