From 7d7f035606187db86fbfbe7eb537cbbac0bcbbca Mon Sep 17 00:00:00 2001 From: Renaud NEDELEC Date: Tue, 20 Oct 2015 17:24:58 +0200 Subject: [PATCH] [PythonAPI / sketcher] added setFillet method --- src/PythonAPI/CMakeLists.txt | 1 + src/PythonAPI/Test/TestSketcherSetFillet.py | 14 ++++++++++++++ src/PythonAPI/model/sketcher/sketch.py | 18 +++++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/PythonAPI/Test/TestSketcherSetFillet.py diff --git a/src/PythonAPI/CMakeLists.txt b/src/PythonAPI/CMakeLists.txt index ae884173e..75c42711c 100644 --- a/src/PythonAPI/CMakeLists.txt +++ b/src/PythonAPI/CMakeLists.txt @@ -23,4 +23,5 @@ ADD_UNIT_TESTS( TestSketcherSetRadius.py TestSketcherSetAngle.py TestSketcherSetEqual.py + TestSketcherSetFillet.py ) diff --git a/src/PythonAPI/Test/TestSketcherSetFillet.py b/src/PythonAPI/Test/TestSketcherSetFillet.py new file mode 100644 index 000000000..f84b67a4e --- /dev/null +++ b/src/PythonAPI/Test/TestSketcherSetFillet.py @@ -0,0 +1,14 @@ +import unittest +import model +from TestSketcher import SketcherTestCase + +class SketcherSetFillet(SketcherTestCase): + def runTest(self): + l1 = self.sketch.addLine(0, 0, 0, 1) + l2 = self.sketch.addLine(0, 1, 1, 1) + self.sketch.setCoincident(l1.endPointData(), l2.startPointData()) + self.sketch.setFillet(l1.result(), l2.result(), 10.0) + model.do() + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/src/PythonAPI/model/sketcher/sketch.py b/src/PythonAPI/model/sketcher/sketch.py index 7ef6af552..a5a909d4f 100644 --- a/src/PythonAPI/model/sketcher/sketch.py +++ b/src/PythonAPI/model/sketcher/sketch.py @@ -187,6 +187,16 @@ class Sketch(): constraint.data().real("ConstraintValue").setValue(angle) self._feature.execute() return constraint + + def setFillet(self, line_1, line_2, radius): + """Set a fillet constraint between the 3 given lines with the given + filleting radius.""" + constraint = self._feature.addFeature("SketchConstraintFillet") + constraint.data().refattr("ConstraintEntityA").setObject(line_1) + constraint.data().refattr("ConstraintEntityB").setObject(line_2) + constraint.data().real("ConstraintValue").setValue(radius) + self._feature.execute() + return constraint #------------------------------------------------------------- # @@ -242,8 +252,11 @@ class Sketch(): pg.append(ln) return pg - + #------------------------------------------------------------- + # # Getters + # + #------------------------------------------------------------- def selectFace(self, *args): """Select the geometrical entities of this Sketch on which @@ -252,8 +265,7 @@ class Sketch(): When no entity is given, the face is based on all existing geometry of this Sketch. """ - #self.resultype ="Face" - if len(args) == 0: + if len(args) == 0: self._selection = modelAPI_ResultConstruction( self._feature.firstResult()).shape() elif len(args) == 1: -- 2.39.2