Salome HOME
Remove execute() from revolution feature.
[modules/shaper.git] / src / PythonAPI / model / features / extrusion_sketch.py
1 """ExtrusionSketch  Interfaces
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from .roots import CompositeSketch
7
8
9 def addExtrusionSketch(part, *args):
10     """Add an ExtrusionSketch feature to the Part and return ExtrusionSketch.
11
12     Pass all args to ExtrusionSketch __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("ExtrusionSketch")
16     return ExtrusionSketch(feature, *args)
17
18
19 class ExtrusionSketch(CompositeSketch):
20
21     def __init__(self, feature, *args):
22         CompositeSketch.__init__(self, feature, *args)
23
24         self._CreationMethod = self._feature.string("CreationMethod")
25         self._to_size = self._feature.data().real("to_size")
26         self._from_size = self._feature.data().real("from_size")
27         self._to_object = self._feature.data().selection("to_object")
28         self._to_offset = self._feature.data().real("to_offset")
29         self._from_object = self._feature.data().selection("from_object")
30         self._from_offset = self._feature.data().real("from_offset")
31
32         assert(self._CreationMethod)
33         assert(self._to_size)
34         assert(self._from_size)
35         assert(self._to_object)
36         assert(self._to_offset)
37         assert(self._from_object)
38         assert(self._from_offset)
39
40         if not args:
41             return
42
43         assert(len(args) == 4 or len(args) == 2)
44         if len(args) == 4:
45             self.setPlanesAndOffsets(*args)
46         elif len(args) == 2:
47             self.setSizes(*args)
48         pass
49
50     def __clear(self):
51         self._CreationMethod.setValue("BySizes")
52         self._fill_attribute(self._to_size, 0)
53         self._fill_attribute(self._from_size, 0)
54         self._fill_attribute(self._to_object, None)
55         self._fill_attribute(self._to_offset, 0)
56         self._fill_attribute(self._from_object, None)
57         self._fill_attribute(self._from_offset, 0)
58         pass
59
60     def setSizes(self, to_size, from_size):
61         """Modify the to_size, from_size attributes of the feature.
62
63         See __init__.
64         """
65         self.__clear()
66         self._CreationMethod.setValue("BySizes")
67         self._fill_attribute(self._to_size, to_size)
68         self._fill_attribute(self._from_size, from_size)
69         pass
70
71     def setPlanesAndOffsets(self, to_object, to_offset,
72                             from_object, from_offset):
73         """Modify planes and offsets attributes of the feature.
74
75         See __init__.
76         """
77         self.__clear()
78         self._CreationMethod.setValue("ByPlanesAndOffsets")
79         self._fill_attribute(self._to_object, to_object)
80         self._fill_attribute(self._to_offset, to_offset)
81         self._fill_attribute(self._from_object, from_object)
82         self._fill_attribute(self._from_offset, from_offset)
83         pass
84