]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/features/placement.py
Salome HOME
Add assertions to set attribute for features.
[modules/shaper.git] / src / PythonAPI / model / features / placement.py
1 """Placement 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 addPlacement(part, *args):
10     """Add an Placement feature to the Part and return Placement.
11
12     Pass all args to Placement __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("Placement")
16     return Placement(feature, *args)
17
18
19 class Placement(Interface):
20
21     def __init__(self, feature, *args):
22         Interface.__init__(self, feature)
23         assert(self._feature.getKind() == "Placement")
24
25         self._objects_list = self._feature.data().selectionList("placement_objects_list")
26         self._start_shape = self._feature.data().selection("placement_start_shape")
27         self._end_shape = self._feature.data().selection("placement_end_shape")
28         self._reverse_direction = self._feature.data().boolean("placement_reverse_direction")
29         self._centering = self._feature.data().boolean("placement_centering")
30
31         assert(self._objects_list)
32         assert(self._start_shape)
33         assert(self._end_shape)
34         assert(self._reverse_direction)
35         assert(self._centering)
36
37         assert(len(args) == 5)
38         self.setObjectList(args[0])
39         self.setStartShape(args[1])
40         self.setEndShape(args[2])
41         self.setReverseDirection(args[3])
42         self.setCentering(args[4])
43         pass
44
45     def setObjectList(self, objects_list):
46         """Modify placement_objects_list attribute of the feature.
47
48         See __init__.
49         """
50         self._fill_attribute(self._objects_list, objects_list)
51         pass
52
53     def setStartShape(self, start_shape):
54         """Modify start_shape attribute of the feature.
55
56         See __init__.
57         """
58         self._fill_attribute(self._start_shape, start_shape)
59         pass
60
61     def setEndShape(self, end_shape):
62         """Modify end_shape attribute of the feature.
63
64         See __init__.
65         """
66         self._fill_attribute(self._end_shape, end_shape)
67         pass
68
69     def setReverseDirection(self, reverse_direction):
70         """Modify reverse_direction attribute of the feature.
71
72         See __init__.
73         """
74         self._fill_attribute(self._reverse_direction, reverse_direction)
75         pass
76
77     def setCentering(self, centering):
78         """Modify centering attribute of the feature.
79
80         See __init__.
81         """
82         self._fill_attribute(self._centering, centering)
83         pass