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

Method testRadiusNthSelector

tests/test_selectors.py:638–711  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

636 self.assertEqual(1, len(fl))
637
638 def testRadiusNthSelector(self):
639
640 # test the key method behaves
641 rad = 2.3
642 arc = Edge.makeCircle(radius=rad)
643 sel = selectors.RadiusNthSelector(0)
644 self.assertAlmostEqual(rad, sel.key(arc), 3)
645 line = Edge.makeLine(Vector(0, 0, 0), Vector(1, 1, 1))
646 with self.assertRaises(ValueError):
647 sel.key(line)
648 solid = makeUnitCube()
649 with self.assertRaises(ValueError):
650 sel.key(solid)
651
652 part = (
653 Workplane()
654 .box(10, 10, 1)
655 .edges(">(1, 1, 0) and |Z")
656 .fillet(1)
657 .edges(">(-1, 1, 0) and |Z")
658 .fillet(1)
659 .edges(">(-1, -1, 0) and |Z")
660 .fillet(2)
661 .edges(">(1, -1, 0) and |Z")
662 .fillet(3)
663 .faces(">Z")
664 )
665 # smallest radius is 1.0
666 self.assertAlmostEqual(
667 part.edges(selectors.RadiusNthSelector(0)).val().radius(), 1.0
668 )
669 # there are two edges with the smallest radius
670 self.assertEqual(len(part.edges(selectors.RadiusNthSelector(0)).vals()), 2)
671 # next radius is 2.0
672 self.assertAlmostEqual(
673 part.edges(selectors.RadiusNthSelector(1)).val().radius(), 2.0
674 )
675 # largest radius is 3.0
676 self.assertAlmostEqual(
677 part.edges(selectors.RadiusNthSelector(-1)).val().radius(), 3.0
678 )
679 # accessing index 3 should be an IndexError
680 with self.assertRaises(IndexError):
681 part.edges(selectors.RadiusNthSelector(3))
682 # reversed
683 self.assertAlmostEqual(
684 part.edges(selectors.RadiusNthSelector(0, directionMax=False))
685 .val()
686 .radius(),
687 3.0,
688 )
689
690 # test the selector on wires
691 wire_circles = (
692 Workplane()
693 .circle(2)
694 .moveTo(10, 0)
695 .circle(2)

Callers

nothing calls this directly

Calls 15

keyMethod · 0.95
makeUnitCubeFunction · 0.90
VectorClass · 0.85
WorkplaneClass · 0.85
makeLineMethod · 0.80
boxMethod · 0.80
consolidateWiresMethod · 0.80
moveToMethod · 0.80
makeCircleMethod · 0.45
facesMethod · 0.45
filletMethod · 0.45
edgesMethod · 0.45

Tested by

no test coverage detected