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