Salome HOME
Merge branch 'python_parametric_api' of https://git.salome-platform.org/git/modules...
[modules/shaper.git] / src / PythonAPI / model / features / rotation.py
1 """Rotation 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 addRotation(part, *args):
10     """Add an Rotation feature to the Part and return Rotation.
11
12     Pass all args to Rotation __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("Rotation")
16     return Rotation(feature, *args)
17
18
19 class Rotation(Interface):
20     """Interface class for Rotation features.
21
22     Rotation(feature) -> feature interface without initialization
23     Rotation(feature, main_objects, axis_object, angle) ->
24         feature interface initialized from arguments:
25         - main_objects
26         - axis_object
27         - angle
28     """
29
30     def __init__(self, feature, *args):
31         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
32         Interface.__init__(self, feature)
33         assert(self._feature.getKind() == "Rotation")
34
35         self._main_objects = self._feature.data().selectionList("main_objects")
36         self._axis_object = self._feature.data().selection("axis_object")
37         self._angle = self._feature.data().real("angle")
38
39         assert(self._main_objects)
40         assert(self._axis_object)
41         assert(self._angle)
42
43         if not args:
44             return
45
46         assert(len(args) == 3)
47         self.setMainObjects(args[0])
48         self.setAxisObject(args[1])
49         self.setAngle(args[2])
50
51         self._execute()
52         pass
53
54     def setMainObjects(self, main_objects):
55         """Modify main_objects attribute of the feature.
56
57         See __init__.
58         """
59         self._fill_attribute(self._main_objects, main_objects)
60         pass
61
62     def setAxisObject(self, axis_object):
63         """Modify axis_object attribute of the feature.
64
65         See __init__.
66         """
67         self._fill_attribute(self._axis_object, axis_object)
68         pass
69
70     def setAngle(self, angle):
71         """Modify angle attribute of the feature.
72
73         See __init__.
74         """
75         self._fill_attribute(self._angle, angle)
76         pass