diff --git a/cadquery/cq.py b/cadquery/cq.py index 799f8c2f..c987c9b4 100644 --- a/cadquery/cq.py +++ b/cadquery/cq.py @@ -2279,14 +2279,15 @@ class Workplane(CQ): how long or wide a feature must be to make sure to cut through all of the material :return: A value representing the largest dimension of the first solid on the stack """ - # TODO: this implementation is naive and returns the dims of the first solid... most of - # TODO: the time this works. but a stronger implementation would be to search all solids. - s = self.findSolid() - if s: - return s.BoundingBox().DiagonalLength * 5.0 - else: + # Get all the solids contained within this CQ object + compound = self.findSolid() + + # Protect against this being called on something like a blank workplane + if not compound: return -1 + return compound.BoundingBox().DiagonalLength + def cutEach(self, fcn, useLocalCoords=False, clean=True): """ Evaluates the provided function at each point on the stack (ie, eachpoint) diff --git a/cadquery/occ_impl/shapes.py b/cadquery/occ_impl/shapes.py index b4405dbe..1b81c916 100644 --- a/cadquery/occ_impl/shapes.py +++ b/cadquery/occ_impl/shapes.py @@ -242,7 +242,7 @@ class Shape(object): @classmethod def cast(cls, obj, forConstruction=False): - "Returns the right type of wrapper, given a FreeCAD object" + "Returns the right type of wrapper, given a OCCT object" tr = None diff --git a/tests/test_cadquery.py b/tests/test_cadquery.py index b0f844d7..8ddba51b 100644 --- a/tests/test_cadquery.py +++ b/tests/test_cadquery.py @@ -1503,7 +1503,12 @@ class TestCadQuery(BaseTest): r = Workplane("XY").box(1, 1, 1) dim = r.largestDimension() - self.assertAlmostEqual(8.7, dim, 1) + self.assertAlmostEqual(1.76, dim, 1) + + r = Workplane("XY").rect(1, 1).extrude(1) + dim = r.largestDimension() + + self.assertAlmostEqual(1.76, dim, 1) r = Workplane("XY") dim = r.largestDimension() @@ -1728,7 +1733,6 @@ class TestCadQuery(BaseTest): # 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 = c2.faces(">Z").workplane().pushPoints(pnts).cboreHole(0.1, 0.25, 0.25) self.assertEqual(15, c2.faces().size())