]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/features/placement.py
Salome HOME
ab8ac046fa93553cae5a64867e27c10b62a4f662
[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         if not args:
38             return
39
40         assert(len(args) == 5)
41         self.setObjectList(args[0])
42         self.setStartShape(args[1])
43         self.setEndShape(args[2])
44         self.setReverseDirection(args[3])
45         self.setCentering(args[4])
46
47         self._execute()
48         pass
49
50     def setObjectList(self, objects_list):
51         """Modify placement_objects_list attribute of the feature.
52
53         See __init__.
54         """
55         self._fill_attribute(self._objects_list, objects_list)
56         pass
57
58     def setStartShape(self, start_shape):
59         """Modify start_shape attribute of the feature.
60
61         See __init__.
62         """
63         self._fill_attribute(self._start_shape, start_shape)
64         pass
65
66     def setEndShape(self, end_shape):
67         """Modify end_shape attribute of the feature.
68
69         See __init__.
70         """
71         self._fill_attribute(self._end_shape, end_shape)
72         pass
73
74     def setReverseDirection(self, reverse_direction):
75         """Modify reverse_direction attribute of the feature.
76
77         See __init__.
78         """
79         self._fill_attribute(self._reverse_direction, reverse_direction)
80         pass
81
82     def setCentering(self, centering):
83         """Modify centering attribute of the feature.
84
85         See __init__.
86         """
87         self._fill_attribute(self._centering, centering)
88         pass