]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[PythonAPI / sketcher] added rigid constraint and the corresponding test
authorRenaud NEDELEC <renaud.nedelec@opencascade.com>
Wed, 4 Nov 2015 10:26:57 +0000 (11:26 +0100)
committerRenaud NEDELEC <renaud.nedelec@opencascade.com>
Wed, 4 Nov 2015 10:26:57 +0000 (11:26 +0100)
src/PythonAPI/Test/TestSketcherSetRigid.py [new file with mode: 0644]
src/PythonAPI/model/sketcher/sketch.py

diff --git a/src/PythonAPI/Test/TestSketcherSetRigid.py b/src/PythonAPI/Test/TestSketcherSetRigid.py
new file mode 100644 (file)
index 0000000..4e3e1b6
--- /dev/null
@@ -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
index b787f5e9f636c5d5e1c8c20f34a75205dcffbbdf..98bf39b84a2ec97766565d90b7fa8e90e3c56c0c 100644 (file)
@@ -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