From: spo Date: Mon, 26 Oct 2015 11:49:10 +0000 (+0300) Subject: Extrusion uses fill_attribute X-Git-Tag: V_2.1.0~206^2~71 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2ce8367455f6c764dff5bacf47e53a4349b15117;p=modules%2Fshaper.git Extrusion uses fill_attribute --- diff --git a/src/PythonAPI/Test/TestFeaturesExtrusion.py b/src/PythonAPI/Test/TestFeaturesExtrusion.py index 007bd0763..2cfec0b04 100644 --- a/src/PythonAPI/Test/TestFeaturesExtrusion.py +++ b/src/PythonAPI/Test/TestFeaturesExtrusion.py @@ -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) diff --git a/src/PythonAPI/model/extrusion.py b/src/PythonAPI/model/extrusion.py index b513b2151..88ab84711 100644 --- a/src/PythonAPI/model/extrusion.py +++ b/src/PythonAPI/model/extrusion.py @@ -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): diff --git a/src/PythonAPI/model/tools.py b/src/PythonAPI/model/tools.py index 2a4a6ed73..71c2df660 100644 --- a/src/PythonAPI/model/tools.py +++ b/src/PythonAPI/model/tools.py @@ -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)