PDN: Add simple hole test

This commit is contained in:
Kurt Kremitzki
2017-08-07 03:38:08 -05:00
committed by Yorik van Havre
parent 58722a4b27
commit 0639b7f113
4 changed files with 75 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,72 @@
# Copyright (c) Kurt Kremitzki <kkremitzki@gmail.com> 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")

View File

@@ -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