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

Method testCutThroughAll

tests/test_cadquery.py:1821–1877  ·  view source on GitHub ↗

Tests a model that uses more than one workplane

(self)

Source from the content-addressed store, hash-verified

1819 self.assertAlmostEqual(bb_enlarged.zmax, bb.zmax + enlarge_tol, 2)
1820
1821 def testCutThroughAll(self):
1822 """
1823 Tests a model that uses more than one workplane
1824 """
1825 # base block
1826 s = Workplane(Plane.XY())
1827 r = (
1828 s.rect(2.0, 2.0)
1829 .rect(1.3, 1.3, forConstruction=True)
1830 .vertices()
1831 .circle(0.125)
1832 .extrude(0.5)
1833 )
1834
1835 # thru all without explicit face selection
1836 t = r.circle(0.5).cutThruAll()
1837 self.assertEqual(11, t.faces().size())
1838
1839 # side hole, thru all
1840 t = (
1841 t.faces(">Y")
1842 .workplane(centerOption="CenterOfMass")
1843 .circle(0.125)
1844 .cutThruAll()
1845 )
1846 self.saveModel(t)
1847 self.assertEqual(13, t.faces().size())
1848
1849 # no planar faces
1850 sphere_r = 10.0
1851
1852 r = (
1853 Workplane()
1854 .sphere(sphere_r)
1855 .workplane()
1856 .circle(sphere_r / 2.0)
1857 .cutThruAll()
1858 .workplane()
1859 .transformed(rotate=(90, 0, 0))
1860 .circle(sphere_r / 2.0)
1861 .cutThruAll()
1862 .workplane()
1863 .transformed(rotate=(0, 90, 0))
1864 .circle(sphere_r / 2.0)
1865 .cutThruAll()
1866 )
1867
1868 self.assertTrue(r.val().isValid())
1869 self.assertEqual(r.faces().size(), 7)
1870
1871 # test errors
1872 box0 = Workplane().box(1, 1, 1).faces(">Z").workplane().hLine(1)
1873 with raises(ValueError):
1874 box0.cutThruAll()
1875 no_box = Workplane().hLine(1).vLine(1).close()
1876 with raises(ValueError):
1877 no_box.cutThruAll()
1878

Callers

nothing calls this directly

Calls 15

rectMethod · 0.95
saveModelMethod · 0.95
WorkplaneClass · 0.85
XYMethod · 0.80
extrudeMethod · 0.80
cutThruAllMethod · 0.80
workplaneMethod · 0.80
transformedMethod · 0.80
sphereMethod · 0.80
isValidMethod · 0.80
hLineMethod · 0.80
boxMethod · 0.80

Tested by

no test coverage detected