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.
12 .. function:: addAxis(part, p1, p2)
15 part (ModelAPI_Document): part document
16 p1 (Selection): first point
17 p2 (Selection): second point
19 .. function:: addAxis(part, face)
22 part (ModelAPI_Document): part document
23 face (Selection): cylindrical face
29 feature = part.addFeature("Axis")
30 return Axis(feature, *args)
33 class Axis(Interface):
34 """Interface class for Axis feature.
36 .. function:: Axis(feature)
38 Create interface for the feature without initialization.
40 .. function:: Axis(feature, p1, p2)
42 Create interface for the feature and initialize the feature with arguments.
44 .. function:: Axis(feature, face)
46 Create interface for the feature and initialize the feature with arguments.
49 def __init__(self, feature, *args):
50 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
51 Interface.__init__(self, feature)
52 assert(self._feature.getKind() == "Axis")
54 self._CreationMethod = self._feature.data().string("CreationMethod")
55 self._FirstPoint = self._feature.data().selection("FirstPoint")
56 self._SecondPoint = self._feature.data().selection("SecondPoint")
57 self._CylindricalFace = self._feature.data().selection("CylindricalFace")
59 assert(self._CreationMethod)
60 assert(self._FirstPoint)
61 assert(self._SecondPoint)
62 assert(self._CylindricalFace)
67 assert(len(args) in (1, 2))
71 self.setCylindricalFace(*args)
77 self._fillAttribute(self._CreationMethod, "AxisByPointsCase")
78 self._fillAttribute(self._FirstPoint, None)
79 self._fillAttribute(self._SecondPoint, None)
80 self._fillAttribute(self._CylindricalFace, None)
82 def setPoints(self, p1, p2):
83 """Modify points attribute of the feature.
88 self._fillAttribute(self._CreationMethod, "AxisByPointsCase")
89 self._fillAttribute(self._FirstPoint, p1)
90 self._fillAttribute(self._SecondPoint, p2)
93 def setCylindricalFace(self, face):
94 """Modify CylindricalFace attribute of the feature.
99 self._fillAttribute(self._CreationMethod, "AxisByCylindricalFaceCase")
100 self._fillAttribute(self._CylindricalFace, face)