]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/features/translation.py
Salome HOME
Add assertions to set attribute for features.
[modules/shaper.git] / src / PythonAPI / model / features / translation.py
1 """Translation Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from model.roots import Interface
7
8
9 def addTranslation(part, *args):
10     """Add an Translation feature to the Part and return Translation.
11
12     Pass all args to Translation __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("Translation")
16     return Translation(feature, *args)
17
18
19 class Translation(Interface):
20
21     def __init__(self, feature, *args):
22         Interface.__init__(self, feature)
23         assert(self._feature.getKind() == "Translation")
24
25         self._main_objects = self._feature.data().selectionList("main_objects")
26         self._axis_object = self._feature.data().selection("axis_object")
27         self._distance = self._feature.data().real("distance")
28
29         assert(self._main_objects)
30         assert(self._axis_object)
31         assert(self._distance)
32
33         assert(len(args) == 3)
34         self.setMainObjects(args[0])
35         self.setAxisObject(args[1])
36         self.setDistance(args[2])
37         pass
38
39     def setMainObjects(self, main_objects):
40         """Modify main_objects attribute of the feature.
41
42         See __init__.
43         """
44         self._fill_attribute(self._main_objects, main_objects)
45         pass
46
47     def setAxisObject(self, axis_object):
48         """Modify axis_object attribute of the feature.
49
50         See __init__.
51         """
52         self._fill_attribute(self._axis_object, axis_object)
53         pass
54
55     def setDistance(self, distance):
56         """Modify distance attribute of the feature.
57
58         See __init__.
59         """
60         self._fill_attribute(self._distance, distance)
61         pass