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

Method testClose

tests/test_cadquery.py:3803–3848  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3801 self.assertAlmostEqual(bb2.zlen, 100.0)
3802
3803 def testClose(self):
3804 # Close without endPoint and startPoint coincide.
3805 # Create a half-circle
3806 a = Workplane(Plane.XY()).sagittaArc((10, 0), 2).close().extrude(2)
3807
3808 # Close when endPoint and startPoint coincide.
3809 # Create a double half-circle
3810 b = (
3811 Workplane(Plane.XY())
3812 .sagittaArc((10, 0), 2)
3813 .sagittaArc((0, 0), 2)
3814 .close()
3815 .extrude(2)
3816 )
3817
3818 # The b shape shall have twice the volume of the a shape.
3819 self.assertAlmostEqual(a.val().Volume() * 2.0, b.val().Volume())
3820
3821 # Testcase 3 from issue #238
3822 thickness = 3.0
3823 length = 10.0
3824 width = 5.0
3825
3826 obj1 = (
3827 Workplane("XY", origin=(0, 0, -thickness / 2))
3828 .moveTo(length / 2, 0)
3829 .threePointArc((0, width / 2), (-length / 2, 0))
3830 .threePointArc((0, -width / 2), (length / 2, 0))
3831 .close()
3832 .extrude(thickness)
3833 )
3834
3835 os_x = 8.0 # Offset in X
3836 os_y = -19.5 # Offset in Y
3837
3838 obj2 = (
3839 Workplane("YZ", origin=(os_x, os_y, -thickness / 2))
3840 .moveTo(os_x + length / 2, os_y)
3841 .sagittaArc((os_x - length / 2, os_y), width / 2)
3842 .sagittaArc((os_x + length / 2, os_y), width / 2)
3843 .close()
3844 .extrude(thickness)
3845 )
3846
3847 # The obj1 shape shall have the same volume as the obj2 shape.
3848 self.assertAlmostEqual(obj1.val().Volume(), obj2.val().Volume())
3849
3850 def testText(self):
3851 global testdataDir

Callers

nothing calls this directly

Calls 9

WorkplaneClass · 0.85
extrudeMethod · 0.80
sagittaArcMethod · 0.80
XYMethod · 0.80
VolumeMethod · 0.80
threePointArcMethod · 0.80
moveToMethod · 0.80
closeMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected