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 a Placement feature to the Part.
12 .. function:: addPlacement(part, objects_list, start_shape, end_shape, reverse_direction, centering)
15 part (ModelAPI_Document): part document
16 objects_list (list of Selection): solid objects
17 start_shape (Selection): start face, edge or vertex
18 end_shape (Selection): end face, edge or vertex
19 reverse_direction (boolean): reverse placement direction
20 centering (boolean): center faces under placement
23 Placement: placement object
26 feature = part.addFeature("Placement")
27 return Placement(feature, *args)
30 class Placement(Interface):
31 """Interface class for Placement feature.
33 .. function:: Placement(feature)
35 Create interface for the feature without initialization.
37 .. function:: Placement(feature, objects_list, start_shape, end_shape, reverse_direction, centering)
39 Create interface for the feature and initialize the feature with arguments.
42 def __init__(self, feature, *args):
43 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
44 Interface.__init__(self, feature)
45 assert(self._feature.getKind() == "Placement")
47 self._objects_list = self._feature.data().selectionList("placement_objects_list")
48 self._start_shape = self._feature.data().selection("placement_start_shape")
49 self._end_shape = self._feature.data().selection("placement_end_shape")
50 self._reverse_direction = self._feature.data().boolean("placement_reverse_direction")
51 self._centering = self._feature.data().boolean("placement_centering")
53 assert(self._objects_list)
54 assert(self._start_shape)
55 assert(self._end_shape)
56 assert(self._reverse_direction)
57 assert(self._centering)
62 assert(len(args) == 5)
63 self.setObjectList(args[0])
64 self.setStartShape(args[1])
65 self.setEndShape(args[2])
66 self.setReverseDirection(args[3])
67 self.setCentering(args[4])
72 def setObjectList(self, objects_list):
73 """Modify placement_objects_list attribute of the feature.
77 self._fillAttribute(self._objects_list, objects_list)
80 def setStartShape(self, start_shape):
81 """Modify start_shape attribute of the feature.
85 self._fillAttribute(self._start_shape, start_shape)
88 def setEndShape(self, end_shape):
89 """Modify end_shape attribute of the feature.
93 self._fillAttribute(self._end_shape, end_shape)
96 def setReverseDirection(self, reverse_direction):
97 """Modify reverse_direction attribute of the feature.
101 self._fillAttribute(self._reverse_direction, reverse_direction)
104 def setCentering(self, centering):
105 """Modify centering attribute of the feature.
109 self._fillAttribute(self._centering, centering)