]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Extrusion uses fill_attribute
authorspo <sergey.pokhodenko@opencascade.com>
Mon, 26 Oct 2015 11:49:10 +0000 (14:49 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Mon, 26 Oct 2015 11:49:55 +0000 (14:49 +0300)
src/PythonAPI/Test/TestFeaturesExtrusion.py
src/PythonAPI/model/extrusion.py
src/PythonAPI/model/tools.py

index 007bd0763992cb6ae4560b2f7199d37dddccd37a..2cfec0b048b489fa9930dcfdce98331b5b2c9376 100644 (file)
@@ -28,8 +28,9 @@ class FeaturesExtrusionFixture(FeaturesAddExtrusionFixture):
         # Create extrusion
         sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
         circle = sketch.addCircle(0, 0, 10)
-        self.extrusion = model.addExtrusion(self.part,
-                                            sketch.selectFace(circle.result()),
+
+        base = [sketch.selectFace(circle.result())]
+        self.extrusion = model.addExtrusion(self.part, base,
                                             10, 0)
         model.do()
 
@@ -51,8 +52,9 @@ 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)
-        extrusion = model.addExtrusion(self.part,
-                                       sketch.selectFace(circle.result()),
+
+        base = [sketch.selectFace(circle.result())]
+        extrusion = model.addExtrusion(self.part, base,
                                        10, 0)
 
         self.assertEqual(extrusion.getCreationMethod().value(), "BySizes")
@@ -81,8 +83,8 @@ class FeaturesAddExtrusionTestCase(FeaturesAddExtrusionFixture):
         from_circle = from_sketch.addCircle(0, 0, 10)
         from_sketch.selectFace(from_circle.result())
 
-        extrusion = model.addExtrusion(self.part,
-                                       base_sketch,
+        base = [base_sketch]
+        extrusion = model.addExtrusion(self.part, base,
                                        to_sketch, 15,
                                        from_sketch, 20)
 
index b513b2151e1d4348eed3886d76125fca50691fb3..88ab847114f523abe34558cd6936a26015a14a63 100644 (file)
@@ -5,7 +5,6 @@ Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 """
 
 from .roots import Interface
-from .sketcher.sketch import Sketch
 
 
 def addExtrusion(part, *args):
@@ -71,52 +70,34 @@ class Extrusion(Interface):
         pass
 
     def __setBase(self, base):
-        """Initialize base attribute of the feature.
-
-        Expected arguments:
-        base -- could be object of this types:
-        - string - topology name of object
-        - Sketch - sketch object
-        - iterable - list or tuple with string and/or Sketch objects
-        """
-        self._base.clear()
-        if isinstance(base, basestring):
-            self._base.append(base)
-        elif isinstance(base, Sketch):
-            self._base.append(base.result(), base.buildShape())
-        else:
-            for item in base:
-                if isinstance(item, basestring):
-                    self._base.append(item)
-                else:
-                    self._base.append(item.result(), item.buildShape())
+        self._fill_attribute(self._base, base)
         pass
 
     def __clear(self):
         self._CreationMethod.setValue("BySizes")
-        self._to_size.setValue(0)
-        self._from_size.setValue(0)
-        self._to_object.setValue(None, None)
-        self._to_offset.setValue(0)
-        self._from_object.setValue(None, None)
-        self._from_offset.setValue(0)
+        self._fill_attribute(self._to_size, 0)
+        self._fill_attribute(self._from_size, 0)
+        self._fill_attribute(self._to_object, None)
+        self._fill_attribute(self._to_offset, 0)
+        self._fill_attribute(self._from_object, None)
+        self._fill_attribute(self._from_offset, 0)
         pass
 
     def __createBySizes(self, to_size, from_size):
         self.__clear()
         self._CreationMethod.setValue("BySizes")
-        self._to_size.setValue(to_size)
-        self._from_size.setValue(from_size)
+        self._fill_attribute(self._to_size, to_size)
+        self._fill_attribute(self._from_size, from_size)
         pass
 
     def __createByPlanesAndOffsets(self, to_object, to_offset,
                                    from_object, from_offset):
         self.__clear()
         self._CreationMethod.setValue("ByPlanesAndOffsets")
-        self._to_object.setValue(to_object.result(), to_object.buildShape())
-        self._to_offset.setValue(to_offset)
-        self._from_object.setValue(from_object.result(), from_object.buildShape())
-        self._from_offset.setValue(from_offset)
+        self._fill_attribute(self._to_object, to_object)
+        self._fill_attribute(self._to_offset, to_offset)
+        self._fill_attribute(self._from_object, from_object)
+        self._fill_attribute(self._from_offset, from_offset)
         pass
 
     def __execute(self):
index 2a4a6ed73fac25a94b6c9fb74a9bb0f399755663..71c2df66025c86f0d205118e8b8ec462d4b4ba45 100644 (file)
@@ -78,6 +78,9 @@ 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)
 
@@ -86,6 +89,9 @@ 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)