1 """RevolutionSketch Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from .roots import CompositeSketch
9 def addRevolutionSketch(part, *args):
10 """Add a RevolutionSketch feature to the Part.
12 .. function:: addRevolutionSketch(part, sketch, sketch_selection, axis_object, to_angle, from_angle)
15 part (ModelAPI_Document): part document
16 sketch (ModelAPI_Object): sketch feature
17 sketch_selection (Selection): sketch objects
18 axis_object (Selection): axis object
19 to_size (double): upper size of the extrusion
20 from_size (double): lower size of the extrusion
22 .. function:: addRevolutionSketch(part, sketch, sketch_selection, axis_object, to_object, to_offset, from_object, from_offset)
25 part (ModelAPI_Document): part document
26 sketch (ModelAPI_Object): sketch feature
27 sketch_selection (Selection): sketch objects
28 axis_object (Selection): axis object
29 to_object (Selection): upper plane
30 to_offset (double): offset from upper plane
31 from_object (Selection): lower plane
32 from_offset (double): offset from lower plane
35 RevolutionSketch: revolution sketch object
38 feature = part.addFeature("RevolutionSketch")
39 return RevolutionSketch(feature, *args)
42 class RevolutionSketch(CompositeSketch):
43 """Interface class for RevolutionSketch features.
45 .. function:: RevolutionSketch(feature)
47 Create interface for the feature without initialization.
49 .. function:: RevolutionSketch(feature, sketch, sketch_selection, to_size, from_size)
51 Create interface for the feature and initialize the feature with arguments.
53 .. function:: RevolutionSketch(feature, sketch, sketch_selection, to_object, to_offset, from_object, from_offset)
55 Create interface for the feature and initialize the feature with arguments.
58 def __init__(self, feature, *args):
59 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
60 CompositeSketch.__init__(self, feature, *args[:2])
63 self._axis_object = self._feature.data().selection("axis_object")
64 self._CreationMethod = self._feature.string("CreationMethod")
65 self._to_angle = self._feature.data().real("to_angle")
66 self._from_angle = self._feature.data().real("from_angle")
67 self._to_object = self._feature.data().selection("to_object")
68 self._to_offset = self._feature.data().real("to_offset")
69 self._from_object = self._feature.data().selection("from_object")
70 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 (3, 5))
88 self.setAxisObject(axis_object)
91 self.setPlanesAndOffsets(*args)
99 self._CreationMethod.setValue("ByAngles")
100 self._fillAttribute(self._to_angle, 0)
101 self._fillAttribute(self._from_angle, 0)
102 self._fillAttribute(self._to_object, None)
103 self._fillAttribute(self._to_offset, 0)
104 self._fillAttribute(self._from_object, None)
105 self._fillAttribute(self._from_offset, 0)
108 def setAxisObject(self, axis_object):
109 """Modify axis_object attribute of the feature.
113 self._fillAttribute(self._axis_object, axis_object)
116 def setAngles(self, to_angle, from_angle):
117 """Modify the to_angle, from_angle attributes of the feature.
122 self._CreationMethod.setValue("ByAngles")
123 self._fillAttribute(self._to_angle, to_angle)
124 self._fillAttribute(self._from_angle, from_angle)
127 def setPlanesAndOffsets(self, to_object, to_offset,
128 from_object, from_offset):
129 """Modify planes and offsets attributes of the feature.
134 self._CreationMethod.setValue("ByPlanesAndOffsets")
135 self._fillAttribute(self._to_object, to_object)
136 self._fillAttribute(self._to_offset, to_offset)
137 self._fillAttribute(self._from_object, from_object)
138 self._fillAttribute(self._from_offset, from_offset)