Added solid detection and consolidated PathJob Base selection option (removed empty option).

This commit is contained in:
Markus Lampert
2017-06-10 16:30:52 -07:00
parent 71f03bd0bd
commit 1ce3b242f2
6 changed files with 176 additions and 24 deletions

View File

@@ -46,8 +46,7 @@ class PathPostTestCases(unittest.TestCase):
# Create job and setup tool library + default tool
job = self.doc.addObject("Path::FeatureCompoundPython", "Job")
PathScripts.PathJob.ObjectPathJob(job)
job.Base = self.doc.Box
PathScripts.PathJob.ObjectPathJob(job, box, None)
PathScripts.PathToolController.CommandPathToolController.Create(job.Name, False)
tool1 = Path.Tool()
tool1.Diameter = 5.0

View File

@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * *
# * Copyright (c) 2017 sliptonic <shopinthewoods@gmail.com> *
# * *
# * 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 FreeCAD
import Part
import Path
import PathScripts.PathUtil as PathUtil
import Sketcher
import TestSketcherApp
from PathTests.PathTestUtils import PathTestBase
class TestPathUtil(PathTestBase):
def setUp(self):
self.doc = FreeCAD.newDocument("TestPathUtils")
def tearDown(self):
FreeCAD.closeDocument("TestPathUtils")
def test00(self):
'''Check that isSolid detects solids.'''
box = self.doc.addObject('Part::Box', 'Box')
cylinder = self.doc.addObject('Part::Cylinder', 'Cylinder')
self.doc.recompute()
self.assertTrue(PathUtil.isSolid(box))
self.assertTrue(PathUtil.isSolid(cylinder))
def test01(self):
'''Check that isSolid detects PDs.'''
body = self.doc.addObject('PartDesign::Body', 'Body')
box = self.doc.addObject('PartDesign::AdditiveBox', 'Box')
body.addObject(box)
self.doc.recompute()
self.assertTrue(PathUtil.isSolid(body))
def test02(self):
'''Check that isSolid detects compounds.'''
box = self.doc.addObject('Part::Box', 'Box')
box.Length = 10
box.Width = 10
box.Height = 1
box.Placement = FreeCAD.Placement(FreeCAD.Vector(-5,-5,0), FreeCAD.Rotation(FreeCAD.Vector(0,0,1), 0))
cyl = self.doc.addObject('Part::Cylinder', 'Cylinder')
cyl.Radius = 1
cyl.Height = 10
box.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,-5), FreeCAD.Rotation(FreeCAD.Vector(0,0,1), 0))
cut = self.doc.addObject('Part::Cut', 'Cut')
cut.Base = box
cut.Tool = cyl
self.doc.recompute()
self.assertTrue(PathUtil.isSolid(cut))
def test03(self):
'''Check that isSolid ignores sketches.'''
body = self.doc.addObject('PartDesign::Body', 'Body')
sketch = self.doc.addObject('Sketcher::SketchObject', 'Sketch')
body.addObject(sketch)
TestSketcherApp.CreateSlotPlateSet(sketch)
self.doc.recompute()
pad = self.doc.addObject('PartDesign::Pad', 'Pad')
body.addObject(pad)
pad.Profile = sketch
self.doc.recompute()
# the body and the pad are solids
self.assertTrue(PathUtil.isSolid(pad))
self.assertTrue(PathUtil.isSolid(body))
# however, the sketch is no
self.assertFalse(PathUtil.isSolid(sketch))