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

Function _get_one

cadquery/occ_impl/shapes.py:5093–5121  ·  view source on GitHub ↗

Get one shape or raise an error.

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

Source from the content-addressed store, hash-verified

5091
5092
5093def _get_one(s: Shape, ts: Shapes | tuple[Shapes, ...]) -> Shape:
5094 """
5095 Get one shape or raise an error.
5096 """
5097
5098 # convert input into tuple
5099 if isinstance(ts, tuple):
5100 types = ts
5101 else:
5102 types = (ts,)
5103
5104 # validate the underlying shape, compounds are unpacked
5105 t = s.ShapeType()
5106
5107 if t in types:
5108 rv = s
5109 elif t == "Compound":
5110 for el in s:
5111 if el.ShapeType() in ts:
5112 rv = el
5113 break
5114 else:
5115 raise ValueError(
5116 f"Required type(s): {types}, encountered {el.ShapeType()}"
5117 )
5118 else:
5119 raise ValueError(f"Required type(s): {types}; encountered {t}")
5120
5121 return rv
5122
5123
5124def _get_one_wire(s: Shape) -> Wire:

Callers 13

test_utilsFunction · 0.90
_get_one_wireFunction · 0.85
edgeOnFunction · 0.85
faceFunction · 0.85
faceOnFunction · 0.85
solidFunction · 0.85
textFunction · 0.85
capFunction · 0.85
filletFunction · 0.85
chamferFunction · 0.85
offset2DFunction · 0.85
chamfer2DFunction · 0.85

Calls 1

ShapeTypeMethod · 0.45

Tested by 1

test_utilsFunction · 0.72