]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/features/extrusion_sketch.py
Salome HOME
bf8ae8fe1fbd6451a2ce6b46443e4a4738ce6de2
[modules/shaper.git] / src / PythonAPI / model / features / extrusion_sketch.py
1 """ExtrusionSketch  Interfaces
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 addExtrusionSketch(part, *args):
10     """Add an ExtrusionSketch feature to the Part and return ExtrusionSketch.
11
12     Pass all args to ExtrusionSketch __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("ExtrusionSketch")
16     return ExtrusionSketch(feature, *args)
17
18
19 class ExtrusionSketch(CompositeSketch):
20
21     def __init__(self, feature, *args):
22         CompositeSketch.__init__(self, feature, *args[:2])
23         args = args[2:]
24
25         self._CreationMethod = self._feature.string("CreationMethod")
26         self._to_size = self._feature.data().real("to_size")
27         self._from_size = self._feature.data().real("from_size")
28         self._to_object = self._feature.data().selection("to_object")
29         self._to_offset = self._feature.data().real("to_offset")
30         self._from_object = self._feature.data().selection("from_object")
31         self._from_offset = self._feature.data().real("from_offset")
32
33         assert(self._CreationMethod)
34         assert(self._to_size)
35         assert(self._from_size)
36         assert(self._to_object)
37         assert(self._to_offset)
38         assert(self._from_object)
39         assert(self._from_offset)
40
41         if not args:
42             return
43
44         assert(len(args) in (2, 4))
45         if len(args) == 4:
46             self.setPlanesAndOffsets(*args)
47         elif len(args) == 2:
48             self.setSizes(*args)
49
50         self._execute()
51         pass
52
53     def __clear(self):
54         self._CreationMethod.setValue("BySizes")
55         self._fill_attribute(self._to_size, 0)
56         self._fill_attribute(self._from_size, 0)
57         self._fill_attribute(self._to_object, None)
58         self._fill_attribute(self._to_offset, 0)
59         self._fill_attribute(self._from_object, None)
60         self._fill_attribute(self._from_offset, 0)
61         pass
62
63     def setSizes(self, to_size, from_size):
64         """Modify the to_size, from_size attributes of the feature.
65
66         See __init__.
67         """
68         self.__clear()
69         self._CreationMethod.setValue("BySizes")
70         self._fill_attribute(self._to_size, to_size)
71         self._fill_attribute(self._from_size, from_size)
72         pass
73
74     def setPlanesAndOffsets(self, to_object, to_offset,
75                             from_object, from_offset):
76         """Modify planes and offsets attributes of the feature.
77
78         See __init__.
79         """
80         self.__clear()
81         self._CreationMethod.setValue("ByPlanesAndOffsets")
82         self._fill_attribute(self._to_object, to_object)
83         self._fill_attribute(self._to_offset, to_offset)
84         self._fill_attribute(self._from_object, from_object)
85         self._fill_attribute(self._from_offset, from_offset)
86         pass
87