From bb86ed32066fafc114725c287196f58bd2ef07eb Mon Sep 17 00:00:00 2001 From: CalligaroV Date: Sat, 3 Aug 2024 15:24:38 +0200 Subject: [PATCH] Part/Toponaming: import code for TopoShape::prepareProfiles() from LS3 * add test for issue #15735 Signed-off-by: CalligaroV --- src/Mod/Part/parttests/regression_tests.py | 76 +++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/src/Mod/Part/parttests/regression_tests.py b/src/Mod/Part/parttests/regression_tests.py index b383b01508..426f5417d6 100644 --- a/src/Mod/Part/parttests/regression_tests.py +++ b/src/Mod/Part/parttests/regression_tests.py @@ -20,6 +20,81 @@ class RegressionTests(unittest.TestCase): with self.assertRaises(IndexError): result.pop() + def test_issue_15735(self): + """ + 15735: Point in sketch as loft profile won't work in dev, but works in stable + The following test is a simplified version of the issue, but the outcome is the same + """ + + # Arrange + from FreeCAD import Base + import Sketcher + + self.Doc = newDocument("TestLoftWithPointSketch") + + ArcSketch = self.Doc.addObject("Sketcher::SketchObject", "ArcSketch") + ArcSketch.Placement = Base.Placement( + Base.Vector(0.000000, 0.000000, 0.000000), + Base.Rotation(0.500000, 0.500000, 0.500000, 0.500000), + ) + ArcSketch.MapMode = "Deactivated" + + geoList = [] + geoList.append( + Part.ArcOfCircle( + Part.Circle( + Base.Vector(0.000000, 0.000000, 0.000000), + Base.Vector(0.000000, 0.000000, 1.000000), + 10.000000, + ), + 3.141593, + 6.283185, + ) + ) + ArcSketch.addGeometry(geoList, False) + del geoList + + constraintList = [] + ArcSketch.addConstraint(Sketcher.Constraint("Radius", 0, 10.000000)) + constraintList.append(Sketcher.Constraint("Coincident", 0, 3, -1, 1)) + constraintList.append(Sketcher.Constraint("PointOnObject", 0, 2, -1)) + constraintList.append(Sketcher.Constraint("PointOnObject", 0, 1, -1)) + ArcSketch.addConstraint(constraintList) + del constraintList + + self.Doc.recompute() + + PointSketch = self.Doc.addObject("Sketcher::SketchObject", "PointSketch") + PointSketch.Placement = Base.Placement( + Base.Vector(-10.000000, 0.000000, 0.000000), + Base.Rotation(0.500000, 0.500000, 0.500000, 0.500000), + ) + PointSketch.MapMode = "Deactivated" + + PointSketch.addGeometry(Part.Point(Base.Vector(0.000000, 0.000000, 0))) + PointSketch.toggleConstruction(0) + + PointSketch.addConstraint(Sketcher.Constraint("Coincident", 0, 1, -1, 1)) + + self.Doc.recompute() + + Loft = self.Doc.addObject("Part::Loft", "Loft") + Loft.Sections = [ + ArcSketch, + PointSketch, + ] + Loft.Solid = False + Loft.Ruled = False + Loft.Closed = False + + # Act + self.Doc.recompute() + + # Assert + self.assertTrue(Loft.isValid()) + if Loft.isValid(): + closeDocument(self.Doc.Name) + def test_OptimalBox(self): box = Part.makeBox(1, 1, 1) self.assertTrue(box.optimalBoundingBox(True, False).isValid()) @@ -46,4 +121,3 @@ class RegressionTests(unittest.TestCase): # Put me in def tearDown(self): ? closeDocument(self.Doc.Name) -