]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/features/revolution_boolean.py
Salome HOME
Remove execute() from revolution feature.
[modules/shaper.git] / src / PythonAPI / model / features / revolution_boolean.py
1 """RevolutionCut and RevolutionFuse Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from .roots import CompositeBoolean
7
8
9 def addRevolutionCut(part, *args):
10     """Add an RevolutionCut feature to the Part and return RevolutionBoolean.
11
12     Pass all args to RevolutionCut __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("RevolutionCut")
16     return RevolutionBoolean(feature, *args)
17
18 def addRevolutionFuse(part, *args):
19     """Add an RevolutionFuse feature to the Part and return RevolutionBoolean.
20
21     Pass all args to RevolutionFuse __init__ function.
22     """
23     assert(args)
24     feature = part.addFeature("RevolutionFuse")
25     return RevolutionBoolean(feature, *args)
26
27
28 class RevolutionBoolean(CompositeBoolean):
29
30     def __init__(self, feature, *args):
31         CompositeBoolean.__init__(self, feature, *args)
32
33         self._axis_object = self._feature.data().selection("axis_object")
34         self._CreationMethod = self._feature.string("CreationMethod")
35         self._to_angle = self._feature.data().real("to_angle")
36         self._from_angle = self._feature.data().real("from_angle")
37         self._to_object = self._feature.data().selection("to_object")
38         self._to_offset = self._feature.data().real("to_offset")
39         self._from_object = self._feature.data().selection("from_object")
40         self._from_offset = self._feature.data().real("from_offset")
41
42         assert(self._axis_object)
43         assert(self._CreationMethod)
44         assert(self._to_angle)
45         assert(self._from_angle)
46         assert(self._to_object)
47         assert(self._to_offset)
48         assert(self._from_object)
49         assert(self._from_offset)
50
51         if not args:
52             return
53
54         self.setAxisObject(args[0])
55
56         if len(args) == 4:
57             self.setPlanesAndOffsets(*args[1:])
58         elif len(args) == 2:
59             self.setAngles(*args[1:])
60         pass
61
62     def __clear(self):
63         self._CreationMethod.setValue("ByAngles")
64         self._fill_attribute(self._to_angle, 0)
65         self._fill_attribute(self._from_angle, 0)
66         self._fill_attribute(self._to_object, None)
67         self._fill_attribute(self._to_offset, 0)
68         self._fill_attribute(self._from_object, None)
69         self._fill_attribute(self._from_offset, 0)
70         pass
71
72     def setAxisObject(self, axis_object):
73         """Modify axis_object attribute of the feature.
74
75         See __init__.
76         """
77         self._fill_attribute(self._axis_object, axis_object)
78         pass
79
80     def setAngles(self, to_angle, from_angle):
81         """Modify the to_angle, from_angle attributes of the feature.
82
83         See __init__.
84         """
85         self.__clear()
86         self._CreationMethod.setValue("ByAngles")
87         self._fill_attribute(self._to_angle, to_angle)
88         self._fill_attribute(self._from_angle, from_angle)
89         pass
90
91     def setPlanesAndOffsets(self, to_object, to_offset,
92                             from_object, from_offset):
93         """Modify planes and offsets attributes of the feature.
94
95         See __init__.
96         """
97         self.__clear()
98         self._CreationMethod.setValue("ByPlanesAndOffsets")
99         self._fill_attribute(self._to_object, to_object)
100         self._fill_attribute(self._to_offset, to_offset)
101         self._fill_attribute(self._from_object, from_object)
102         self._fill_attribute(self._from_offset, from_offset)
103         pass
104