From: spo Date: Tue, 27 Oct 2015 13:55:02 +0000 (+0300) Subject: Add feature translation without tests. X-Git-Tag: V_2.1.0~206^2~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3882b28808475c16e121a458c155447175ebd7e4;p=modules%2Fshaper.git Add feature translation without tests. --- diff --git a/src/PythonAPI/model/features/__init__.py b/src/PythonAPI/model/features/__init__.py index 7b2d341a9..0a937e063 100644 --- a/src/PythonAPI/model/features/__init__.py +++ b/src/PythonAPI/model/features/__init__.py @@ -17,3 +17,4 @@ from revolution_sketch import addRevolutionSketch from placement import addPlacement from rotation import addRotation +from translation import addTranslation diff --git a/src/PythonAPI/model/features/translation.py b/src/PythonAPI/model/features/translation.py new file mode 100644 index 000000000..d36a72239 --- /dev/null +++ b/src/PythonAPI/model/features/translation.py @@ -0,0 +1,57 @@ +"""Translation Interface +Author: Sergey Pokhodenko +Copyright (C) 2014-20xx CEA/DEN, EDF R&D +""" + +from model.roots import Interface + + +def addTranslation(part, *args): + """Add an Translation feature to the Part and return Translation. + + Pass all args to Translation __init__ function. + """ + assert(args) + feature = part.addFeature("Translation") + return Translation(feature, *args) + + +class Translation(Interface): + + def __init__(self, feature, *args): + Interface.__init__(self, feature) + assert(self._feature.getKind() == "Translation") + + self._main_objects = self._feature.data().selectionList("main_objects") + self._axis_object = self._feature.data().selection("axis_object") + self._distance = self._feature.data().real("distance") + + assert(len(args) == 3) + self.setMainObjects(args[0]) + self.setAxisObject(args[1]) + self.setDistance(args[2]) + pass + + def setMainObjects(self, main_objects): + """Modify main_objects attribute of the feature. + + See __init__. + """ + self._fill_attribute(self._main_objects, main_objects) + pass + + def setAxisObject(self, axis_object): + """Modify axis_object attribute of the feature. + + See __init__. + """ + self._fill_attribute(self._axis_object, axis_object) + pass + + def setDistance(self, distance): + """Modify distance attribute of the feature. + + See __init__. + """ + self._fill_attribute(self._distance, distance) + pass