1 """RevolutionCut and RevolutionFuse Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from .roots import CompositeBoolean
9 def addRevolutionCut(part, *args):
10 """Add a RevolutionCut feature to the Part.
12 .. function:: addRevolutionCut(part, sketch, sketch_selection, boolean_objects, 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 boolean_objects (list of Selection): boolean objects
19 axis_object (Selection): axis object
20 to_size (double): upper size of the extrusion
21 from_size (double): lower size of the extrusion
23 .. function:: addRevolutionCut(part, sketch, sketch_selection, boolean_objects, axis_object, to_object, to_offset, from_object, from_offset)
26 part (ModelAPI_Document): part document
27 sketch (ModelAPI_Object): sketch feature
28 sketch_selection (Selection): sketch objects
29 boolean_objects (list of Selection): boolean objects
30 axis_object (Selection): axis object
31 to_object (Selection): upper plane
32 to_offset (double): offset from upper plane
33 from_object (Selection): lower plane
34 from_offset (double): offset from lower plane
37 RevolutionBoolean: revolution boolean object
40 feature = part.addFeature("RevolutionCut")
41 return RevolutionBoolean(feature, *args)
43 def addRevolutionFuse(part, *args):
44 """Add a RevolutionFuse feature to the Part.
46 .. function:: addRevolutionFuse(part, sketch, sketch_selection, boolean_objects, axis_object, to_angle, from_angle)
49 part (ModelAPI_Document): part document
50 sketch (ModelAPI_Object): sketch feature
51 sketch_selection (Selection): sketch objects
52 boolean_objects (list of Selection): boolean objects
53 axis_object (Selection): axis object
54 to_size (double): upper size of the extrusion
55 from_size (double): lower size of the extrusion
57 .. function:: addRevolutionFuse(part, sketch, sketch_selection, boolean_objects, axis_object, to_object, to_offset, from_object, from_offset)
60 part (ModelAPI_Document): part document
61 sketch (ModelAPI_Object): sketch feature
62 sketch_selection (Selection): sketch objects
63 boolean_objects (list of Selection): boolean objects
64 axis_object (Selection): axis object
65 to_object (Selection): upper plane
66 to_offset (double): offset from upper plane
67 from_object (Selection): lower plane
68 from_offset (double): offset from lower plane
71 Pass all args to RevolutionFuse __init__ function.
74 RevolutionBoolean: revolution boolean object
77 feature = part.addFeature("RevolutionFuse")
78 return RevolutionBoolean(feature, *args)
81 class RevolutionBoolean(CompositeBoolean):
82 """Interface class for RevolutionBoolean features.
89 .. function:: RevolutionBoolean(feature)
91 Create interface for the feature without initialization.
93 .. function:: RevolutionBoolean(feature, sketch, sketch_selection, boolean_objects, axis_object, to_angle, from_angle)
95 Create interface for the feature and initialize the feature with arguments.
97 .. function:: RevolutionBoolean(feature, sketch, sketch_selection, boolean_objects, axis_object, to_object, to_offset, from_object, from_offset)
99 Create interface for the feature and initialize the feature with arguments.
102 def __init__(self, feature, *args):
103 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
104 CompositeBoolean.__init__(self, feature, *args[:3])
107 self._axis_object = self._feature.data().selection("axis_object")
108 self._CreationMethod = self._feature.string("CreationMethod")
109 self._to_angle = self._feature.data().real("to_angle")
110 self._from_angle = self._feature.data().real("from_angle")
111 self._to_object = self._feature.data().selection("to_object")
112 self._to_offset = self._feature.data().real("to_offset")
113 self._from_object = self._feature.data().selection("from_object")
114 self._from_offset = self._feature.data().real("from_offset")
116 assert(self._axis_object)
117 assert(self._CreationMethod)
118 assert(self._to_angle)
119 assert(self._from_angle)
120 assert(self._to_object)
121 assert(self._to_offset)
122 assert(self._from_object)
123 assert(self._from_offset)
128 assert(len(args) in (3, 5))
129 axis_object = args[0]
132 self.setAxisObject(axis_object)
135 self.setPlanesAndOffsets(*args)
137 self.setAngles(*args)
143 self._CreationMethod.setValue("ByAngles")
144 self._fillAttribute(self._to_angle, 0)
145 self._fillAttribute(self._from_angle, 0)
146 self._fillAttribute(self._to_object, None)
147 self._fillAttribute(self._to_offset, 0)
148 self._fillAttribute(self._from_object, None)
149 self._fillAttribute(self._from_offset, 0)
152 def setAxisObject(self, axis_object):
153 """Modify axis_object attribute of the feature.
157 self._fillAttribute(self._axis_object, axis_object)
160 def setAngles(self, to_angle, from_angle):
161 """Modify the to_angle, from_angle attributes of the feature.
166 self._CreationMethod.setValue("ByAngles")
167 self._fillAttribute(self._to_angle, to_angle)
168 self._fillAttribute(self._from_angle, from_angle)
171 def setPlanesAndOffsets(self, to_object, to_offset,
172 from_object, from_offset):
173 """Modify planes and offsets attributes of the feature.
178 self._CreationMethod.setValue("ByPlanesAndOffsets")
179 self._fillAttribute(self._to_object, to_object)
180 self._fillAttribute(self._to_offset, to_offset)
181 self._fillAttribute(self._from_object, from_object)
182 self._fillAttribute(self._from_offset, from_offset)