]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/features/revolution_sketch.py
Salome HOME
Improve PythonAPI documentstion.
[modules/shaper.git] / src / PythonAPI / model / features / revolution_sketch.py
1 """RevolutionSketch Interface
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 addRevolutionSketch(part, *args):
10     """Add an RevolutionSketch feature to the Part and return RevolutionSketch.
11
12     Pass all args to RevolutionSketch __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("RevolutionSketch")
16     return RevolutionSketch(feature, *args)
17
18
19 class RevolutionSketch(CompositeSketch):
20     """Interface class for RevolutionSketch features.
21
22     RevolutionSketch(feature) -> feature interface without initialization
23     RevolutionSketch(feature,
24                      sketch, sketch_selection,
25                      to_angle, from_angle) ->
26         feature interface initialized from arguments:
27         - sketch
28         - sketch_selection
29         - to_angle
30         - from_angle
31     RevolutionSketch(feature,
32                      sketch, sketch_selection,
33                      to_object, to_offset, from_object, from_offset) ->
34         feature interface initialized from arguments:
35         - sketch
36         - sketch_selection
37         - to_object
38         - to_offset
39         - from_object
40         - from_offset
41     """
42
43     def __init__(self, feature, *args):
44         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
45         CompositeSketch.__init__(self, feature, *args[:2])
46         args = args[2:]
47
48         self._axis_object = self._feature.data().selection("axis_object")
49         self._CreationMethod = self._feature.string("CreationMethod")
50         self._to_angle = self._feature.data().real("to_angle")
51         self._from_angle = self._feature.data().real("from_angle")
52         self._to_object = self._feature.data().selection("to_object")
53         self._to_offset = self._feature.data().real("to_offset")
54         self._from_object = self._feature.data().selection("from_object")
55         self._from_offset = self._feature.data().real("from_offset")
56
57         assert(self._axis_object)
58         assert(self._CreationMethod)
59         assert(self._to_angle)
60         assert(self._from_angle)
61         assert(self._to_object)
62         assert(self._to_offset)
63         assert(self._from_object)
64         assert(self._from_offset)
65
66         if not args:
67             return
68
69         assert(len(args) in (3, 5))
70         axis_object = args[0]
71         args = args[1:]
72
73         self.setAxisObject(axis_object)
74
75         if len(args) == 4:
76             self.setPlanesAndOffsets(*args)
77         elif len(args) == 2:
78             self.setAngles(*args)
79
80         self._execute()
81         pass
82
83     def __clear(self):
84         self._CreationMethod.setValue("ByAngles")
85         self._fill_attribute(self._to_angle, 0)
86         self._fill_attribute(self._from_angle, 0)
87         self._fill_attribute(self._to_object, None)
88         self._fill_attribute(self._to_offset, 0)
89         self._fill_attribute(self._from_object, None)
90         self._fill_attribute(self._from_offset, 0)
91         pass
92
93     def setAxisObject(self, axis_object):
94         """Modify axis_object attribute of the feature.
95
96         See __init__.
97         """
98         self._fill_attribute(self._axis_object, axis_object)
99         pass
100
101     def setAngles(self, to_angle, from_angle):
102         """Modify the to_angle, from_angle attributes of the feature.
103
104         See __init__.
105         """
106         self.__clear()
107         self._CreationMethod.setValue("ByAngles")
108         self._fill_attribute(self._to_angle, to_angle)
109         self._fill_attribute(self._from_angle, from_angle)
110         pass
111
112     def setPlanesAndOffsets(self, to_object, to_offset,
113                             from_object, from_offset):
114         """Modify planes and offsets attributes of the feature.
115
116         See __init__.
117         """
118         self.__clear()
119         self._CreationMethod.setValue("ByPlanesAndOffsets")
120         self._fill_attribute(self._to_object, to_object)
121         self._fill_attribute(self._to_offset, to_offset)
122         self._fill_attribute(self._from_object, from_object)
123         self._fill_attribute(self._from_offset, from_offset)
124         pass
125