2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
9 def addPlacement(part, *args):
10 """Add an Placement feature to the Part and return Placement.
12 Pass all args to Placement __init__ function.
15 feature = part.addFeature("Placement")
16 return Placement(feature, *args)
19 class Placement(Interface):
21 def __init__(self, feature, *args):
22 Interface.__init__(self, feature)
23 assert(self._feature.getKind() == "Placement")
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")
31 assert(self._objects_list)
32 assert(self._start_shape)
33 assert(self._end_shape)
34 assert(self._reverse_direction)
35 assert(self._centering)
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])
50 def setObjectList(self, objects_list):
51 """Modify placement_objects_list attribute of the feature.
55 self._fill_attribute(self._objects_list, objects_list)
58 def setStartShape(self, start_shape):
59 """Modify start_shape attribute of the feature.
63 self._fill_attribute(self._start_shape, start_shape)
66 def setEndShape(self, end_shape):
67 """Modify end_shape attribute of the feature.
71 self._fill_attribute(self._end_shape, end_shape)
74 def setReverseDirection(self, reverse_direction):
75 """Modify reverse_direction attribute of the feature.
79 self._fill_attribute(self._reverse_direction, reverse_direction)
82 def setCentering(self, centering):
83 """Modify centering attribute of the feature.
87 self._fill_attribute(self._centering, centering)