2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
9 def addAxis(part, *args):
10 """Add an Axis feature to the Part and return Axis.
12 Pass all args to Axis __init__ function.
14 feature = part.addFeature("Axis")
15 return Axis(feature, *args)
18 class Axis(Interface):
19 """Interface on an Axis feature."""
21 def __init__(self, feature, *args):
22 """Initialize an Axis feature with given parameters.
24 Expected arguments for all modes:
25 feature -- a Axis feature
27 For AxisByPointsCase mode (expect 2 arguments):
31 For AxisByCylindricalFaceCase mode (expect 1 argument):
32 face -- CylindricalFace
34 Interface.__init__(self, feature)
35 assert(self._feature.getKind() == "Axis")
37 self._CreationMethod = self._feature.data().string("CreationMethod")
38 self._FirstPoint = self._feature.data().selection("FirstPoint")
39 self._SecondPoint = self._feature.data().selection("SecondPoint")
40 self._CylindricalFace = self._feature.data().selection("CylindricalFace")
45 assert(len(args) == 2 or len(args) == 1)
49 self.setCylindricalFace(*args)
53 self._fill_attribute(self._CreationMethod, "AxisByPointsCase")
54 self._fill_attribute(self._FirstPoint, None)
55 self._fill_attribute(self._SecondPoint, None)
56 self._fill_attribute(self._CylindricalFace, None)
58 def setPoints(self, p1, p2):
59 """Modify points attribute of the feature.
64 self._fill_attribute(self._CreationMethod, "AxisByPointsCase")
65 self._fill_attribute(self._FirstPoint, p1)
66 self._fill_attribute(self._SecondPoint, p2)
69 def setCylindricalFace(self, face):
70 """Modify CylindricalFace attribute of the feature.
75 self._fill_attribute(self._CreationMethod, "AxisByCylindricalFaceCase")
76 self._fill_attribute(self._CylindricalFace, face)