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

Method key

cadquery/selectors.py:522–537  ·  view source on GitHub ↗
(self, obj: Shape)

Source from the content-addressed store, hash-verified

520 """
521
522 def key(self, obj: Shape) -> float:
523 if obj.ShapeType() in ("Face", "Shell", "Solid"):
524 return obj.Area()
525 elif obj.ShapeType() == "Wire":
526 try:
527 from cadquery.occ_impl.shapes import Face, Wire
528
529 return abs(Face.makeFromWires(cast(Wire, obj)).Area())
530 except Exception as ex:
531 raise ValueError(
532 f"Can not compute area of the Wire: {ex}. AreaNthSelector supports only closed planar Wires."
533 )
534 else:
535 raise ValueError(
536 f"AreaNthSelector supports only Wires, Faces, Shells and Solids, not {type(obj).__name__}"
537 )
538
539
540class BinarySelector(Selector):

Callers

nothing calls this directly

Calls 3

ShapeTypeMethod · 0.45
AreaMethod · 0.45
makeFromWiresMethod · 0.45

Tested by

no test coverage detected