1 """Revolution Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
9 def addRevolution(part, *args):
10 """Add a Revolution feature to the Part.
12 .. function:: addRevolution(part, base, axis_object, to_angle, from_angle)
15 part (ModelAPI_Document): part document
16 base (list of Selection): base objects
17 axis_object (Selection): axis object
18 to_angle (double): to angle
19 from_angle (double): from angle
21 .. function:: addRevolution(feature, base, axis_object, to_object, to_offset, from_object, from_offset)
24 part (ModelAPI_Document): part document
25 base (list of Selection): base objects
26 axis_object (Selection): axis object
27 to_object (plane): upper plane
28 to_offset (double): offset from upper object
29 from_object (plane): lower plane
30 from_offset (double): offset from lower plane
33 Revolution: revolution object
35 assert(len(args) > 0 and args[0] is not None)
36 feature = part.addFeature("Revolution")
37 return Revolution(feature, *args)
40 class Revolution(Interface):
41 """Interface class for Revolution features.
43 .. function:: Revolution(feature)
45 Create interface for the feature without initialization.
47 .. function:: Revolution(feature, base, axis_object, to_angle, from_angle)
49 Create interface for the feature and initialize the feature with arguments.
51 .. function:: Revolution(feature, base, axis_object, to_object, to_offset, from_object, from_offset)
53 Create interface for the feature and initialize the feature with arguments.
56 def __init__(self, feature, *args):
57 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
58 Interface.__init__(self, feature)
59 assert(self._feature.getKind() == "Revolution")
61 self._base = self._feature.data().selectionList("base")
62 self._axis_object = self._feature.data().selection("axis_object")
63 self._CreationMethod = self._feature.string("CreationMethod")
64 self._to_angle = self._feature.data().real("to_angle")
65 self._from_angle = self._feature.data().real("from_angle")
66 self._to_object = self._feature.data().selection("to_object")
67 self._to_offset = self._feature.data().real("to_offset")
68 self._from_object = self._feature.data().selection("from_object")
69 self._from_offset = self._feature.data().real("from_offset")
72 assert(self._axis_object)
73 assert(self._CreationMethod)
74 assert(self._to_angle)
75 assert(self._from_angle)
76 assert(self._to_object)
77 assert(self._to_offset)
78 assert(self._from_object)
79 assert(self._from_offset)
84 assert(len(args) in (4, 6))
86 base, axis_object = args[:2]
90 self.setAxisObject(axis_object)
93 self.setPlanesAndOffsets(*args)
101 self._CreationMethod.setValue("ByAngles")
102 self._fillAttribute(self._to_angle, 0)
103 self._fillAttribute(self._from_angle, 0)
104 self._fillAttribute(self._to_object, None)
105 self._fillAttribute(self._to_offset, 0)
106 self._fillAttribute(self._from_object, None)
107 self._fillAttribute(self._from_offset, 0)
110 def setBase(self, base):
111 """Modify base attribute of the feature.
115 self._fillAttribute(self._base, base)
118 def setAxisObject(self, axis_object):
119 """Modify axis_object attribute of the feature.
123 self._fillAttribute(self._axis_object, axis_object)
126 def setAngles(self, to_angle, from_angle):
127 """Modify the to_angle, from_angle attributes of the feature.
132 self._CreationMethod.setValue("ByAngles")
133 self._fillAttribute(self._to_angle, to_angle)
134 self._fillAttribute(self._from_angle, from_angle)
137 def setPlanesAndOffsets(self, to_object, to_offset,
138 from_object, from_offset):
139 """Modify planes and offsets attributes of the feature.
144 self._CreationMethod.setValue("ByPlanesAndOffsets")
145 self._fillAttribute(self._to_object, to_object)
146 self._fillAttribute(self._to_offset, to_offset)
147 self._fillAttribute(self._from_object, from_object)
148 self._fillAttribute(self._from_offset, from_offset)