Next phase of cleaning up CQ.py.
This commit is contained in:
		| @ -1652,7 +1652,7 @@ class Workplane(CQ): | |||||||
|         if s: |         if s: | ||||||
|             return s.BoundingBox().DiagonalLength * 5.0 |             return s.BoundingBox().DiagonalLength * 5.0 | ||||||
|         else: |         else: | ||||||
|             return 1000000 |             return -1 | ||||||
|  |  | ||||||
|     def cutEach(self, fcn, useLocalCoords=False): |     def cutEach(self, fcn, useLocalCoords=False): | ||||||
|         """ |         """ | ||||||
| @ -1968,7 +1968,7 @@ class Workplane(CQ): | |||||||
|  |  | ||||||
|     def combine(self): |     def combine(self): | ||||||
|         """ |         """ | ||||||
|         Attempts to combine all of the items on the items on the stack into a single item. |         Attempts to combine all of the items on the stack into a single item. | ||||||
|         WARNING: all of the items must be of the same type! |         WARNING: all of the items must be of the same type! | ||||||
|  |  | ||||||
|         :raises: ValueError if there are no items on the stack, or if they cannot be combined |         :raises: ValueError if there are no items on the stack, or if they cannot be combined | ||||||
|  | |||||||
| @ -185,7 +185,9 @@ class TestCadQuery(BaseTest): | |||||||
|  |  | ||||||
|  |  | ||||||
|     def testPointList(self): |     def testPointList(self): | ||||||
|         "Tests adding points and using them" |         """ | ||||||
|  |         Tests adding points and using them | ||||||
|  |         """ | ||||||
|         c = CQ(makeUnitCube()) |         c = CQ(makeUnitCube()) | ||||||
|  |  | ||||||
|         s = c.faces(">Z").workplane().pushPoints([(-0.3, 0.3), (0.3, 0.3), (0, 0)]) |         s = c.faces(">Z").workplane().pushPoints([(-0.3, 0.3), (0.3, 0.3), (0, 0)]) | ||||||
| @ -197,6 +199,14 @@ class TestCadQuery(BaseTest): | |||||||
|         self.saveModel(body) |         self.saveModel(body) | ||||||
|         self.assertEqual(9, body.faces().size()) |         self.assertEqual(9, body.faces().size()) | ||||||
|  |  | ||||||
|  |         # Test the case when using eachpoint with only a blank workplane | ||||||
|  |         def callback_fn(pnt): | ||||||
|  |             self.assertEqual((0.0, 0.0), (pnt.x, pnt.y)) | ||||||
|  |  | ||||||
|  |         r = Workplane('XY') | ||||||
|  |         r.objects = [] | ||||||
|  |         r.eachpoint(callback_fn) | ||||||
|  |  | ||||||
|  |  | ||||||
|     def testWorkplaneFromFace(self): |     def testWorkplaneFromFace(self): | ||||||
|         s = CQ(makeUnitCube()).faces(">Z").workplane() #make a workplane on the top face |         s = CQ(makeUnitCube()).faces(">Z").workplane() #make a workplane on the top face | ||||||
| @ -260,7 +270,8 @@ class TestCadQuery(BaseTest): | |||||||
|         Test creating a solid using the revolve operation. |         Test creating a solid using the revolve operation. | ||||||
|         :return: |         :return: | ||||||
|         """ |         """ | ||||||
|         #The dimensions of the model. These can be modified rather than changing the shape's code directly. |         # The dimensions of the model. These can be modified rather than changing the | ||||||
|  |         # shape's code directly. | ||||||
|         rectangle_width = 10.0 |         rectangle_width = 10.0 | ||||||
|         rectangle_length = 10.0 |         rectangle_length = 10.0 | ||||||
|         angle_degrees = 360.0 |         angle_degrees = 360.0 | ||||||
| @ -316,12 +327,14 @@ class TestCadQuery(BaseTest): | |||||||
|         Test creating a solid donut shape with square walls |         Test creating a solid donut shape with square walls | ||||||
|         :return: |         :return: | ||||||
|         """ |         """ | ||||||
|         #The dimensions of the model. These can be modified rather than changing the shape's code directly. |         # The dimensions of the model. These can be modified rather than changing the | ||||||
|  |         # shape's code directly. | ||||||
|         rectangle_width = 10.0 |         rectangle_width = 10.0 | ||||||
|         rectangle_length = 10.0 |         rectangle_length = 10.0 | ||||||
|         angle_degrees = 360.0 |         angle_degrees = 360.0 | ||||||
|  |  | ||||||
|         result = Workplane("XY").rect(rectangle_width, rectangle_length, True).revolve(angle_degrees, (20, 0), (20, 10)) |         result = Workplane("XY").rect(rectangle_width, rectangle_length, True)\ | ||||||
|  |             .revolve(angle_degrees, (20, 0), (20, 10)) | ||||||
|         self.assertEqual(4, result.faces().size()) |         self.assertEqual(4, result.faces().size()) | ||||||
|         self.assertEqual(4, result.vertices().size()) |         self.assertEqual(4, result.vertices().size()) | ||||||
|         self.assertEqual(6, result.edges().size()) |         self.assertEqual(6, result.edges().size()) | ||||||
| @ -336,6 +349,24 @@ class TestCadQuery(BaseTest): | |||||||
|         self.assertEqual(2, result.vertices().size()) |         self.assertEqual(2, result.vertices().size()) | ||||||
|         self.assertEqual(3, result.edges().size()) |         self.assertEqual(3, result.edges().size()) | ||||||
|  |  | ||||||
|  |     def testTwistExtrude(self): | ||||||
|  |         """ | ||||||
|  |         Tests extrusion while twisting through an angle. | ||||||
|  |         """ | ||||||
|  |         profile = Workplane('XY').rect(10, 10) | ||||||
|  |         r = profile.twistExtrude(10, 45, False) | ||||||
|  |  | ||||||
|  |         self.assertEqual(6, r.faces().size()) | ||||||
|  |  | ||||||
|  |     def testTwistExtrudeCombine(self): | ||||||
|  |         """ | ||||||
|  |         Tests extrusion while twisting through an angle, combining with other solids. | ||||||
|  |         """ | ||||||
|  |         profile = Workplane('XY').rect(10, 10) | ||||||
|  |         r = profile.twistExtrude(10, 45) | ||||||
|  |  | ||||||
|  |         self.assertEqual(6, r.faces().size()) | ||||||
|  |  | ||||||
|     def testRectArray(self): |     def testRectArray(self): | ||||||
|         NUMX=3 |         NUMX=3 | ||||||
|         NUMY=3 |         NUMY=3 | ||||||
| @ -612,6 +643,20 @@ class TestCadQuery(BaseTest): | |||||||
|                           r.vertices(selectors.NearestToPointSelector((0.0, 0.0, 0.0)))\ |                           r.vertices(selectors.NearestToPointSelector((0.0, 0.0, 0.0)))\ | ||||||
|                           .first().val().Y)) |                           .first().val().Y)) | ||||||
|  |  | ||||||
|  |     def testLargestDimension(self): | ||||||
|  |         """ | ||||||
|  |         Tests the largestDimension function when no solids are on the stack and when there are | ||||||
|  |         """ | ||||||
|  |         r = Workplane('XY').box(1, 1, 1) | ||||||
|  |         dim = r.largestDimension() | ||||||
|  |  | ||||||
|  |         self.assertAlmostEqual(8.66025403784, dim) | ||||||
|  |  | ||||||
|  |         r = Workplane('XY') | ||||||
|  |         dim = r.largestDimension() | ||||||
|  |  | ||||||
|  |         self.assertEqual(-1, dim) | ||||||
|  |  | ||||||
|     def testOccBottle(self): |     def testOccBottle(self): | ||||||
|         """ |         """ | ||||||
|         Make the OCC bottle example. |         Make the OCC bottle example. | ||||||
| @ -771,6 +816,14 @@ class TestCadQuery(BaseTest): | |||||||
|         self.assertEquals(18, c.faces().size()) |         self.assertEquals(18, c.faces().size()) | ||||||
|         self.saveModel(c) |         self.saveModel(c) | ||||||
|  |  | ||||||
|  |         # Tests the case where the depth of the cboreHole is not specified | ||||||
|  |         c2 = CQ(makeCube(3.0)) | ||||||
|  |         pnts = [ | ||||||
|  |             (-1.0, -1.0), (0.0, 0.0), (1.0, 1.0) | ||||||
|  |         ] | ||||||
|  |         c2.faces(">Z").workplane().pushPoints(pnts).cboreHole(0.1, 0.25, 0.25) | ||||||
|  |         self.assertEquals(15, c2.faces().size()) | ||||||
|  |  | ||||||
|     def testCounterSinks(self): |     def testCounterSinks(self): | ||||||
|         """ |         """ | ||||||
|             Tests countersinks |             Tests countersinks | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user