From f27884ba973ff789aac39ec3092729901d85dd47 Mon Sep 17 00:00:00 2001 From: Jeremy Mack Wright Date: Wed, 28 Feb 2018 23:07:36 -0500 Subject: [PATCH] Added tests and fixed bugs related to some of the more esoteric Shape functions. --- cadquery/freecad_impl/shapes.py | 2 +- tests/TestCadObjects.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/cadquery/freecad_impl/shapes.py b/cadquery/freecad_impl/shapes.py index 5657564..e68fbab 100644 --- a/cadquery/freecad_impl/shapes.py +++ b/cadquery/freecad_impl/shapes.py @@ -656,7 +656,7 @@ def makeRuledSurface(cls, edgeOrWire1, edgeOrWire2, dist=None): Create a ruled surface out of two edges or wires. If wires are used then these must have the same """ - return Shape.cast(FreeCADPart.makeRuledSurface(edgeOrWire1.obj, edgeOrWire2.obj, dist)) + return Shape.cast(FreeCADPart.makeRuledSurface(edgeOrWire1.wrapped, edgeOrWire2.wrapped)) def cut(self, faceToCut): "Remove a face from another one" diff --git a/tests/TestCadObjects.py b/tests/TestCadObjects.py index ce92072..18cccde 100644 --- a/tests/TestCadObjects.py +++ b/tests/TestCadObjects.py @@ -364,6 +364,39 @@ def testTranslate(self): self.assertTupleAlmostEquals((1.0, 2.0, 4.0), e2.Center().toTuple(), 3) + def testScale(self): + """ + Tests scaling a shape and whether the dimensions are correct afterwards + """ + e = Shape.cast(Part.makeCircle(2.0, FreeCAD.Base.Vector(1, 2, 3))) + e2 = e.scale(0.5) + + self.assertAlmostEquals(2.0, e2.BoundingBox().xlen) + self.assertAlmostEquals(2.0, e2.BoundingBox().ylen) + + def testCopy(self): + """ + Tests making a copy of a shape object and whether the new one has the + same properties as the original. + """ + e = Shape.cast(Part.makeCircle(2.0, FreeCAD.Base.Vector(1, 2, 3))) + e2 = e.copy() + + self.assertEquals(e.BoundingBox().xlen, e2.BoundingBox().xlen) + self.assertEquals(e.BoundingBox().ylen, e2.BoundingBox().ylen) + + def testRuledSurface(self): + """ + Tests making a ruled surface from two edges/wires. + """ + edge1 = Shape(Part.makeLine((0, 0, 5), (0, 10, 5))) + edge2 = Shape(Part.makeLine((5, 5, 0), (10, 10, 0))) + + surf1 = Face.makeRuledSurface(edge1, edge2) + + self.assertEquals(surf1.ShapeType(), 'Face') + self.assertTrue(surf1.isValid()) + def testVertices(self): e = Shape.cast(Part.makeLine((0, 0, 0), (1, 1, 0))) self.assertEqual(2, len(e.Vertices()))