diff --git a/src/Mod/PartDesign/App/FeatureExtrude.cpp b/src/Mod/PartDesign/App/FeatureExtrude.cpp index 70b1f66543..d0ea1a748c 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.cpp +++ b/src/Mod/PartDesign/App/FeatureExtrude.cpp @@ -625,7 +625,7 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt } if (faceCount == 1) { - getUpToFace(upToShape, base, supportface, sketchshape, method, dir); + getUpToFace(upToShape, base, sketchshape, method, dir); addOffsetToFace(upToShape, dir, Offset.getValue()); } else{ diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index bc88cf4faa..baf36b1e00 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -848,7 +848,6 @@ void ProfileBased::getUpToFace(TopoDS_Face& upToFace, void ProfileBased::getUpToFace(TopoShape& upToFace, const TopoShape& support, - const TopoShape& supportface, const TopoShape& sketchshape, const std::string& method, gp_Dir& dir) @@ -887,13 +886,11 @@ void ProfileBased::getUpToFace(TopoShape& upToFace, TopoDS_Face face = TopoDS::Face(upToFace.getShape()); // Check that the upToFace does not intersect the sketch face and - // is not parallel to the extrusion direction (for simplicity, supportface is used instead of - // sketchshape) - BRepAdaptor_Surface adapt1(TopoDS::Face(supportface.getShape())); - BRepAdaptor_Surface adapt2(face); + // is not parallel to the extrusion direction + BRepAdaptor_Surface adapt(face); - if (adapt2.GetType() == GeomAbs_Plane) { - if (adapt1.Plane().Axis().IsNormal(adapt2.Plane().Axis(), Precision::Confusion())) { + if (adapt.GetType() == GeomAbs_Plane) { + if (dir.IsNormal(adapt.Plane().Axis().Direction(), Precision::Confusion())) { throw Base::ValueError( "SketchBased: Up to face: Must not be parallel to extrusion direction!"); } diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index b2e2c308ff..dfeba5a349 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -173,7 +173,6 @@ protected: /// Find a valid face to extrude up to static void getUpToFace(TopoShape& upToFace, const TopoShape& support, - const TopoShape& supportface, const TopoShape& sketchshape, const std::string& method, gp_Dir& dir); diff --git a/src/Mod/PartDesign/PartDesignTests/TestPad.py b/src/Mod/PartDesign/PartDesignTests/TestPad.py index 7e5b4f3f2d..54c5e08a50 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestPad.py +++ b/src/Mod/PartDesign/PartDesignTests/TestPad.py @@ -22,6 +22,7 @@ import unittest import FreeCAD +from FreeCAD import Base import TestSketcherApp class TestPad(unittest.TestCase): @@ -211,35 +212,52 @@ class TestPad(unittest.TestCase): self.Doc.recompute() self.assertAlmostEqual(self.Pad.Shape.Volume, 2208.0963, places=4) - def testPadToShapeCase(self): - self.Body = self.Doc.addObject('PartDesign::Body','Body') - # Make first offset cube Pad - self.PadSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad') - self.Body.addObject(self.PadSketch) - TestSketcherApp.CreateRectangleSketch(self.PadSketch, (0, 1), (1, 1)) - self.Doc.recompute() - self.Pad = self.Doc.addObject("PartDesign::Pad", "Pad") - self.Body.addObject(self.Pad) - self.Pad.Profile = self.PadSketch - self.Pad.Length = 1 - self.Doc.recompute() - # Make second pad on different plane and pad to first - self.PadSketch1 = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad1') - self.Body.addObject(self.PadSketch1) - self.PadSketch1.MapMode = 'FlatFace' - self.PadSketch1.AttachmentSupport = (self.Doc.XZ_Plane, ['']) - self.PadSketch1.AttachmentOffset.Rotation.Axis = App.Vector(0,1,0) - self.PadSketch1.AttachmentOffset.Rotation.Angle = 0.436332 # 25° - self.PadSketch1.AttachmentOffset.Base.z = 1 - self.Doc.recompute() - TestSketcherApp.CreateRectangleSketch(self.PadSketch1, (1, 0), (1, 1)) - self.Doc.recompute() - self.Pad1 = self.Doc.addObject("PartDesign::Pad", "Pad1") - self.Body.addObject(self.Pad1) - self.Pad1.Profile = self.PadSketch1 - self.Pad1.Type = 5 - self.Doc.recompute() - self.assertAlmostEqual(self.Pad1.Shape.Volume, 2.58787, places=4) + def testPadToShapeCase(self): + self.Body = self.Doc.addObject('PartDesign::Body','Body') + # Make first offset cube Pad + self.PadSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad') + self.Body.addObject(self.PadSketch) + TestSketcherApp.CreateRectangleSketch(self.PadSketch, (0, 1), (1, 1)) + self.Doc.recompute() + self.Pad = self.Doc.addObject("PartDesign::Pad", "Pad") + self.Body.addObject(self.Pad) + self.Pad.Profile = self.PadSketch + self.Pad.Length = 1 + self.Doc.recompute() + # Make second pad on different plane and pad to first + self.PadSketch1 = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad1') + self.Body.addObject(self.PadSketch1) + self.PadSketch1.MapMode = 'FlatFace' + self.PadSketch1.AttachmentSupport = (self.Doc.XZ_Plane, ['']) + self.PadSketch1.AttachmentOffset.Rotation.Axis = Base.Vector(0,1,0) + self.PadSketch1.AttachmentOffset.Rotation.Angle = 0.436332 # 25° + self.PadSketch1.AttachmentOffset.Base.z = 1 + self.Doc.recompute() + TestSketcherApp.CreateRectangleSketch(self.PadSketch1, (1, 0), (1, 1)) + self.Doc.recompute() + self.Pad1 = self.Doc.addObject("PartDesign::Pad", "Pad1") + self.Body.addObject(self.Pad1) + self.Pad1.Profile = self.PadSketch1 + self.Pad1.Type = 5 + self.Doc.recompute() + self.assertAlmostEqual(self.Pad1.Shape.Volume, 2.58787, places=4) + + def testPadToPlaneCustomDir(self): + self.Body = self.Doc.addObject('PartDesign::Body','Body') + # Make first offset cube Pad + self.PadSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad') + self.Body.addObject(self.PadSketch) + TestSketcherApp.CreateRectangleSketch(self.PadSketch, (0, 1), (1, 1)) + self.Doc.recompute() + self.Pad = self.Doc.addObject("PartDesign::Pad", "Pad") + self.Body.addObject(self.Pad) + self.Pad.Profile = self.PadSketch + self.Pad.Type = 3 + self.Doc.Pad.UseCustomVector = True + self.Doc.Pad.Direction = Base.Vector(0,1,1) + self.Pad.UpToFace = (self.Doc.XZ_Plane, ['']) + self.Doc.recompute() + self.assertAlmostEqual(self.Pad.Shape.Volume, 1.5) def tearDown(self): #closing doc