MCPcopy Index your code
hub / github.com/CadQuery/cadquery / testAreaNthSelector_Solids

Method testAreaNthSelector_Solids

tests/test_selectors.py:985–1010  ·  view source on GitHub ↗

Selecting 2 of 3 solids by surface area

(self)

Source from the content-addressed store, hash-verified

983 )
984
985 def testAreaNthSelector_Solids(self):
986 """
987 Selecting 2 of 3 solids by surface area
988 """
989
990 sizes_iter = iter([10.0, 20.0, 20.0])
991
992 def next_box(loc):
993 size = next(sizes_iter)
994 return Workplane().box(size, size, size).val().located(loc)
995
996 workplane_solids = Workplane().rarray(30, 1, 3, 1).eachpoint(next_box)
997
998 selected_solids = workplane_solids.solids(selectors.AreaNthSelector(1))
999
1000 self.assertEqual(
1001 len(selected_solids.vals()),
1002 2,
1003 msg="Failed to select two larger solids: wrong N shells",
1004 )
1005 self.assertTupleAlmostEquals(
1006 [20 * 20 * 6] * 2,
1007 [solid.Area() for solid in selected_solids.vals()],
1008 5,
1009 msg="Failed to select two larger solids: wrong area",
1010 )
1011
1012 def testAndSelector(self):
1013 c = CQ(makeUnitCube())

Callers

nothing calls this directly

Calls 7

WorkplaneClass · 0.85
eachpointMethod · 0.80
rarrayMethod · 0.45
solidsMethod · 0.45
valsMethod · 0.45
AreaMethod · 0.45

Tested by

no test coverage detected