diff --git a/src/Mod/PartDesign/App/CMakeLists.txt b/src/Mod/PartDesign/App/CMakeLists.txt index ea4bb76980..844edfa281 100644 --- a/src/Mod/PartDesign/App/CMakeLists.txt +++ b/src/Mod/PartDesign/App/CMakeLists.txt @@ -158,6 +158,7 @@ SET(PartDesign_Scripts PartDesignTests/TestShapeBinder.py PartDesignTests/TestPad.py PartDesignTests/TestPocket.py + PartDesignTests/TestHole.py PartDesignTests/TestRevolve.py PartDesignTests/TestLoft.py PartDesignTests/TestPipe.py diff --git a/src/Mod/PartDesign/CMakeLists.txt b/src/Mod/PartDesign/CMakeLists.txt index 2874268cab..4beafbfa1e 100644 --- a/src/Mod/PartDesign/CMakeLists.txt +++ b/src/Mod/PartDesign/CMakeLists.txt @@ -38,6 +38,7 @@ INSTALL( PartDesignTests/TestShapeBinder.py PartDesignTests/TestPad.py PartDesignTests/TestPocket.py + PartDesignTests/TestHole.py PartDesignTests/TestRevolve.py PartDesignTests/TestLoft.py PartDesignTests/TestPipe.py diff --git a/src/Mod/PartDesign/PartDesignTests/TestHole.py b/src/Mod/PartDesign/PartDesignTests/TestHole.py new file mode 100644 index 0000000000..addf1b2e3c --- /dev/null +++ b/src/Mod/PartDesign/PartDesignTests/TestHole.py @@ -0,0 +1,72 @@ +# Copyright (c) Kurt Kremitzki 2017 * +# * +# This file is part of the FreeCAD CAx development system. * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU Lesser General Public License (LGPL) * +# as published by the Free Software Foundation; either version 2 of * +# the License, or (at your option) any later version. * +# for detail see the LICENCE text file. * +# * +# FreeCAD is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU Library General Public License for more details. * +# * +# You should have received a copy of the GNU Library General Public * +# License along with FreeCAD; if not, write to the Free Software * +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# USA * +#************************************************************************** +from math import pi +import unittest + +import FreeCAD +import TestSketcherApp + +App = FreeCAD + + +class TestHole(unittest.TestCase): + def setUp(self): + self.Doc = FreeCAD.newDocument("PartDesignTestBoolean") + + def testPlainHole(self): + self.Body = self.Doc.addObject('PartDesign::Body','Body') + self.Box = self.Doc.addObject('PartDesign::AdditiveBox','Box') + self.Box.Length=10 + self.Box.Width=10 + self.Box.Height=10 + self.Body.addObject(self.Box) + self.Doc.recompute() + self.HoleSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchHole') + self.HoleSketch.Support = (self.Doc.XY_Plane, ['']) + self.HoleSketch.MapMode = 'FlatFace' + self.HoleSketch.MapReversed = True + self.Body.addObject(self.HoleSketch) + TestSketcherApp.CreateCircleSketch(self.HoleSketch, (-5, 5), 1) + self.Doc.recompute() + self.Hole = self.Doc.addObject("PartDesign::Hole", "Hole") + self.Hole.Profile = self.HoleSketch + self.Body.addObject(self.Hole) + self.Doc.recompute() + self.Hole.Diameter = 6 + self.Hole.Depth = 10 + # self.Hole.DrillPointAngle = 118.000000 + # self.Hole.TaperedAngle = 90 + self.Hole.ThreadType = 0 + self.Hole.HoleCutType = 0 # 1 = Counterbore, 2 = Countersink + # self.Hole.HoleCutDiameter = 5 + # self.Hole.HoleCutCountersinkAngle = 90 + # self.Hole.HoleCutDepth = 2 # Counterbore + self.Hole.DepthType = 0 # 1 = Through all + self.Hole.DrillPoint = 0 # 1 = Angled + self.Hole.Tapered = 0 # On/off + self.Doc.recompute() + self.assertAlmostEqual(self.Hole.Shape.Volume, 10**3 - pi * 3**2 * 10) + + def tearDown(self): + #closing doc + FreeCAD.closeDocument("PartDesignTestBoolean") + #print ("omit closing document for debugging") + diff --git a/src/Mod/PartDesign/TestPartDesignApp.py b/src/Mod/PartDesign/TestPartDesignApp.py index ebe8c02c83..659495bbe2 100644 --- a/src/Mod/PartDesign/TestPartDesignApp.py +++ b/src/Mod/PartDesign/TestPartDesignApp.py @@ -30,6 +30,7 @@ from PartDesignTests.TestShapeBinder import TestShapeBinder # additive/subtractive features & primitives from PartDesignTests.TestPad import TestPad from PartDesignTests.TestPocket import TestPocket +from PartDesignTests.TestHole import TestHole from PartDesignTests.TestRevolve import TestRevolve from PartDesignTests.TestPipe import TestPipe from PartDesignTests.TestLoft import TestLoft