From: Renaud NEDELEC Date: Wed, 4 Nov 2015 10:26:57 +0000 (+0100) Subject: [PythonAPI / sketcher] added rigid constraint and the corresponding test X-Git-Tag: V_2.1.0~206^2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3b9bfdf9f81e8baeaace4214fb2f7519b78bbeb2;p=modules%2Fshaper.git [PythonAPI / sketcher] added rigid constraint and the corresponding test --- diff --git a/src/PythonAPI/Test/TestSketcherSetRigid.py b/src/PythonAPI/Test/TestSketcherSetRigid.py new file mode 100644 index 000000000..4e3e1b666 --- /dev/null +++ b/src/PythonAPI/Test/TestSketcherSetRigid.py @@ -0,0 +1,15 @@ +import unittest +import model +from TestSketcher import SketcherTestCase + +class SketcherSetRigid(SketcherTestCase): + def runTest(self): + circle = self.sketch.addCircle(0, 10, 20) + self.sketch.setRigid(circle.result()) + model.do() + with self.assertRaises(Exception): + circle.setCenter(0, 0) + model.do() + +if __name__ == "__main__": + unittest.main(verbosity=2) \ No newline at end of file diff --git a/src/PythonAPI/model/sketcher/sketch.py b/src/PythonAPI/model/sketcher/sketch.py index b787f5e9f..98bf39b84 100644 --- a/src/PythonAPI/model/sketcher/sketch.py +++ b/src/PythonAPI/model/sketcher/sketch.py @@ -249,7 +249,13 @@ class Sketch(Interface): constraint.data().refattr("ConstraintEntityA").setObject(line_1) constraint.data().reflist("ConstraintEntityB").clear constraint.data().reflist("ConstraintEntityB").append(line_1) - + self.execute() + return constraint + + def setRigid(self, object_): + """Set a rigid constraint on a given object.""" + constraint = self._feature.addFeature("SketchConstraintRigid") + constraint.data().refattr("ConstraintEntityA").setObject(object_) self.execute() return constraint