]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
sketch.selectFace() returns Selection
authorspo <sergey.pokhodenko@opencascade.com>
Mon, 26 Oct 2015 12:36:34 +0000 (15:36 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Mon, 26 Oct 2015 12:37:50 +0000 (15:37 +0300)
src/PythonAPI/Test/TestFeaturesExtrusion.py
src/PythonAPI/model/roots.py
src/PythonAPI/model/sketcher/sketch.py
src/PythonAPI/model/tools.py

index 2cfec0b048b489fa9930dcfdce98331b5b2c9376..46e6b31fe908c3b330b1bf27bb23bd6debd36f22 100644 (file)
@@ -28,10 +28,10 @@ class FeaturesExtrusionFixture(FeaturesAddExtrusionFixture):
         # Create extrusion
         sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
         circle = sketch.addCircle(0, 0, 10)
+        model.do()
 
         base = [sketch.selectFace(circle.result())]
-        self.extrusion = model.addExtrusion(self.part, base,
-                                            10, 0)
+        self.extrusion = model.addExtrusion(self.part, base, 10, 0)
         model.do()
 
     def tearDown(self):
@@ -52,10 +52,11 @@ class FeaturesAddExtrusionTestCase(FeaturesAddExtrusionFixture):
     def test_add_extrusion_by_face_and_size(self):
         sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
         circle = sketch.addCircle(0, 0, 10)
+        model.do()
 
         base = [sketch.selectFace(circle.result())]
-        extrusion = model.addExtrusion(self.part, base,
-                                       10, 0)
+        extrusion = model.addExtrusion(self.part, base, 10, 0)
+        model.do()
 
         self.assertEqual(extrusion.getCreationMethod().value(), "BySizes")
         self.assertEqual(extrusion.getToSize().value(), 10)
@@ -69,24 +70,25 @@ class FeaturesAddExtrusionTestCase(FeaturesAddExtrusionFixture):
         # base
         base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
         base_circle = base_sketch.addCircle(0, 0, 10)
-        base_sketch.selectFace(base_circle.result())
         # to
         to_plane = model.defaultPlane("XOY")
         to_plane.location().setZ(10)
         to_sketch = model.addSketch(self.part, to_plane)
         to_circle = to_sketch.addCircle(0, 0, 10)
-        to_sketch.selectFace(to_circle.result())
         # from
         from_plane = model.defaultPlane("XOY")
         from_plane.location().setZ(-10)
         from_sketch = model.addSketch(self.part, from_plane)
         from_circle = from_sketch.addCircle(0, 0, 10)
-        from_sketch.selectFace(from_circle.result())
 
-        base = [base_sketch]
+        model.do()
+
+        base = [base_sketch.selectFace(base_circle.result())]
+        to_object = to_sketch.selectFace(to_circle.result())
+        from_object = from_sketch.selectFace(from_circle.result())
         extrusion = model.addExtrusion(self.part, base,
-                                       to_sketch, 15,
-                                       from_sketch, 20)
+                                       to_object, 15,
+                                       from_object, 20)
 
         self.assertEqual(extrusion.getCreationMethod().value(), "ByPlanesAndOffsets")
         self.assertEqual(extrusion.getToSize().value(), 0)
@@ -135,24 +137,22 @@ class FeaturesExtrusionTestCase(FeaturesExtrusionFixture):
         self.assertEqual(self.extrusion.getFromOffset().value(), 0)
 
     def test_extrusion_set_planes_and_offsets(self):
-        # base
-        base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
-        base_circle = base_sketch.addCircle(0, 0, 10)
-        base_sketch.selectFace(base_circle.result())
         # to
         to_plane = model.defaultPlane("XOY")
         to_plane.location().setZ(10)
         to_sketch = model.addSketch(self.part, to_plane)
         to_circle = to_sketch.addCircle(0, 0, 10)
-        to_sketch.selectFace(to_circle.result())
         # from
         from_plane = model.defaultPlane("XOY")
         from_plane.location().setZ(-10)
         from_sketch = model.addSketch(self.part, from_plane)
         from_circle = from_sketch.addCircle(0, 0, 10)
-        from_sketch.selectFace(from_circle.result())
 
-        self.extrusion.setPlanesAndOffsets(to_sketch, 15, from_sketch, 20)
+        model.do()
+
+        to_object = to_sketch.selectFace(to_circle.result())
+        from_object = from_sketch.selectFace(from_circle.result())
+        self.extrusion.setPlanesAndOffsets(to_object, 15, from_object, 20)
 
 
 if __name__ == "__main__":
index 798f4dac388bce30f7de459b30e0347d14d7504c..a5ac3c2014234874c733336619b588704301eca1 100644 (file)
@@ -63,9 +63,9 @@ class Interface():
         """Return ModelAPI_Feature."""
         return self._feature
 
-    def _fill_attribute(self, attribute, value, *args):
+    def _fill_attribute(self, attribute, value):
         """Fill ModelAPI_Attribute* with value."""
-        tools.fill_attribute(attribute, value, *args)
+        tools.fill_attribute(attribute, value)
 
     def setRealInput(self, inputid, value):
         self._feature.data().real(inputid).setValue(value)
index 8123ab979e30c20bbcef34eb94a263359fcd0d8b..c865651c24e70211740ec9d3063d341f76f587bb 100644 (file)
@@ -12,6 +12,8 @@ from model.sketcher.line import Line
 from model.sketcher.circle import Circle
 from model.sketcher.arc import Arc
 from model.roots import Interface
+from model.tools import Selection
+
 
 def addSketch(doc, plane):
     """Add a Sketch feature to the Part or PartSet and return an interface
@@ -283,6 +285,7 @@ class Sketch(Interface):
                 self._feature.firstResult()).shape()
         elif len(args) == 1:
             self._selection = args[0].shape()
+            return Selection(self.result(), self.buildShape())
         else:
             raise Exception("not yet implemented")
         return self
index 71c2df66025c86f0d205118e8b8ec462d4b4ba45..8626b823b3ea651b1513a5fb16429f5f1ad0063b 100644 (file)
@@ -55,15 +55,16 @@ class Selection:
 #             ,
 #                    "args[1] should be str (%s given)." %
 #                    type(args[1]))
-        elif isinstance(args[0], ModelAPI.ModelAPI_Result):
+        elif isinstance(args[0], ModelAPI.ModelAPI_Result) or args[0] is None:
             assert(isinstance(args[1], GeomAPI.GeomAPI_Shape))
+
 #                    ,
 #                    "args[1] should be GeomAPI_Shape (%s given)." %
 #                    type(args[1]))
         self.args = args
 
 
-def fill_attribute(attribute, value, *args):
+def fill_attribute(attribute, value):
     """Set value to attribure.
 
     This function processes complex cases.
@@ -78,9 +79,6 @@ def fill_attribute(attribute, value, *args):
 
         assert(isinstance(value, collections.Iterable))
         for item in value:
-            attribute.append(item.result(), item.buildShape())
-            continue
-
             assert(isinstance(item, Selection))
             attribute.append(*item.args)
 
@@ -89,9 +87,6 @@ def fill_attribute(attribute, value, *args):
             attribute.setValue(None, None)
             return
 
-        attribute.setValue(value.result(), value.buildShape())
-        return
-
         assert(isinstance(value, Selection))
         attribute.setValue(*value.args)