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

Function _get

cadquery/occ_impl/shapes.py:5065–5090  ·  view source on GitHub ↗

Get desired shapes or raise an error.

(s: Shape, ts: Shapes | tuple[Shapes, ...])

Source from the content-addressed store, hash-verified

5063
5064
5065def _get(s: Shape, ts: Shapes | tuple[Shapes, ...]) -> Iterable[Shape]:
5066 """
5067 Get desired shapes or raise an error.
5068 """
5069
5070 # convert input into tuple
5071 if isinstance(ts, tuple):
5072 types = ts
5073 else:
5074 types = (ts,)
5075
5076 # validate the underlying shape, compounds are unpacked
5077 t = s.ShapeType()
5078
5079 if t in types:
5080 yield s
5081 elif t == "Compound":
5082 for el in s:
5083 if el.ShapeType() in ts:
5084 yield el
5085 else:
5086 raise ValueError(
5087 f"Required type(s): {types}; encountered {el.ShapeType()}"
5088 )
5089 else:
5090 raise ValueError(f"Required type(s): {types}; encountered {t}")
5091
5092
5093def _get_one(s: Shape, ts: Shapes | tuple[Shapes, ...]) -> Shape:

Callers 6

test_utilsFunction · 0.90
shellFunction · 0.85
solidFunction · 0.85
extrudeFunction · 0.85
revolveFunction · 0.85
_offsetFunction · 0.85

Calls 1

ShapeTypeMethod · 0.45

Tested by 1

test_utilsFunction · 0.72