1 """Translation Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
9 def addTranslation(part, *args):
10 """Add a Translation feature to the Part.
12 .. function:: addTranslation(part, main_objects, axis_object, distance)
15 part (ModelAPI_Document): part document
16 main_objects (list of Selection): main objects
17 axis_object (Selection): axis objects
18 distance (double): distance
21 Translation: translation object
24 feature = part.addFeature("Translation")
25 return Translation(feature, *args)
28 class Translation(Interface):
29 """Interface class for Translation features.
31 .. function:: Translation(feature)
33 Create interface for the feature without initialization.
35 .. function:: Translation(feature, main_objects, axis_object, distance)
37 Create interface for the feature and initialize the feature with arguments.
40 def __init__(self, feature, *args):
41 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
42 Interface.__init__(self, feature)
43 assert(self._feature.getKind() == "Translation")
45 self._main_objects = self._feature.data().selectionList("main_objects")
46 self._axis_object = self._feature.data().selection("axis_object")
47 self._distance = self._feature.data().real("distance")
49 assert(self._main_objects)
50 assert(self._axis_object)
51 assert(self._distance)
56 assert(len(args) == 3)
57 self.setMainObjects(args[0])
58 self.setAxisObject(args[1])
59 self.setDistance(args[2])
64 def setMainObjects(self, main_objects):
65 """Modify main_objects attribute of the feature.
69 self._fillAttribute(self._main_objects, main_objects)
72 def setAxisObject(self, axis_object):
73 """Modify axis_object attribute of the feature.
77 self._fillAttribute(self._axis_object, axis_object)
80 def setDistance(self, distance):
81 """Modify distance attribute of the feature.
85 self._fillAttribute(self._distance, distance)