80 lines
3.4 KiB
Python
80 lines
3.4 KiB
Python
#***************************************************************************
|
|
#* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
|
#* *
|
|
#* 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. *
|
|
#* *
|
|
#* This program 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 this program; if not, write to the Free Software *
|
|
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
|
#* USA *
|
|
#* *
|
|
#***************************************************************************
|
|
|
|
import unittest
|
|
|
|
import FreeCAD
|
|
|
|
class TestShapeBinder(unittest.TestCase):
|
|
def setUp(self):
|
|
self.Doc = FreeCAD.newDocument("PartDesignTestShapeBinder")
|
|
|
|
def testTwoBodyShapeBinderCase(self):
|
|
self.Body = self.Doc.addObject('PartDesign::Body','Body')
|
|
self.Box = self.Doc.addObject('PartDesign::AdditiveBox','Box')
|
|
self.Box.Length=1
|
|
self.Box.Width=1
|
|
self.Box.Height=1
|
|
self.Body.addObject(self.Box)
|
|
self.Doc.recompute()
|
|
self.Body001 = self.Doc.addObject('PartDesign::Body','Body001')
|
|
self.ShapeBinder = self.Doc.addObject('PartDesign::ShapeBinder','ShapeBinder')
|
|
self.ShapeBinder.Support = [(self.Box, 'Face1')]
|
|
self.Body001.addObject(self.ShapeBinder)
|
|
self.Doc.recompute()
|
|
self.assertIn('Box', self.ShapeBinder.OutList[0].Label)
|
|
self.assertIn('Body001', self.ShapeBinder.InList[0].Label)
|
|
|
|
def tearDown(self):
|
|
#closing doc
|
|
FreeCAD.closeDocument("PartDesignTestShapeBinder")
|
|
#print ("omit closing document for debugging")
|
|
|
|
|
|
class TestSubShapeBinder(unittest.TestCase):
|
|
def setUp(self):
|
|
self.Doc = FreeCAD.newDocument("PartDesignTestSubShapeBinder")
|
|
|
|
def tearDown(self):
|
|
FreeCAD.closeDocument("PartDesignTestSubShapeBinder")
|
|
|
|
def testOffsetBinder(self):
|
|
# See PR 7445
|
|
body = self.Doc.addObject('PartDesign::Body','Body')
|
|
box = self.Doc.addObject('PartDesign::AdditiveBox','Box')
|
|
body.addObject(box)
|
|
|
|
box.Length=10.00000
|
|
box.Width=10.00000
|
|
box.Height=10.00000
|
|
|
|
binder = body.newObject('PartDesign::SubShapeBinder','Binder')
|
|
binder.Support=[(box, ("Edge2", "Edge12", "Edge6", "Edge10"))]
|
|
self.Doc.recompute()
|
|
|
|
self.assertAlmostEqual(binder.Shape.Length, 40)
|
|
|
|
binder.OffsetJoinType="Tangent"
|
|
binder.Offset = 5.00000
|
|
self.Doc.recompute()
|
|
|
|
self.assertAlmostEqual(binder.Shape.Length, 80)
|