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

Method testCut

tests/test_cadquery.py:1695–1717  ·  view source on GitHub ↗

Tests the cut function by itself to catch the case where a Solid object is passed.

(self)

Source from the content-addressed store, hash-verified

1693 self.assertEqual(12, t.faces().size())
1694
1695 def testCut(self):
1696 """
1697 Tests the cut function by itself to catch the case where a Solid object is passed.
1698 """
1699 s = Workplane(Plane.XY())
1700 currentS = s.rect(2.0, 2.0).extrude(0.5)
1701 toCut = s.rect(1.0, 1.0).extrude(0.5)
1702
1703 resS = currentS.cut(toCut.val())
1704
1705 self.assertEqual(10, resS.faces().size())
1706
1707 with self.assertRaises(ValueError):
1708 currentS.cut(toCut.faces().val())
1709
1710 # Test syntactic sugar [__sub__ method]
1711 sugar = currentS - toCut.val()
1712 self.assertEqual(resS.faces().size(), sugar.faces().size())
1713
1714 # test ValueError on no solid found
1715 s0 = Workplane().hLine(1).vLine(1).close()
1716 with raises(ValueError):
1717 s0.cut(toCut.val())
1718
1719 def testIntersect(self):
1720 """

Callers

nothing calls this directly

Calls 11

rectMethod · 0.95
WorkplaneClass · 0.85
XYMethod · 0.80
extrudeMethod · 0.80
vLineMethod · 0.80
hLineMethod · 0.80
cutMethod · 0.45
valMethod · 0.45
sizeMethod · 0.45
facesMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected