1 """ExtrusionCut and ExtrusionFuse Interfaces
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from .roots import CompositeBoolean
9 def addExtrusionCut(part, *args):
10 """Add an ExtrusionCut feature to the Part.
12 .. function:: addExtrusionCut(part, sketch, sketch_selection, boolean_objects, to_size, from_size)
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 to_size (double): upper size of the extrusion
20 from_size (double): lower size of the extrusion
22 .. function:: addExtrusionCut(part, sketch, sketch_selection, boolean_objects, 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 boolean_objects (list of Selection): boolean objects
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 ExtrusionBoolean: extrusion boolean object
38 feature = part.addFeature("ExtrusionCut")
39 return ExtrusionBoolean(feature, *args)
41 def addExtrusionFuse(part, *args):
42 """Add an ExtrusionFuse feature to the Part and return ExtrusionBoolean.
44 .. function:: addExtrusionFuse(part, sketch, sketch_selection, boolean_objects, to_size, from_size)
47 part (ModelAPI_Document): part document
48 sketch (ModelAPI_Object): sketch feature
49 sketch_selection (Selection): sketch objects
50 boolean_objects (list of Selection): boolean objects
51 to_size (double): upper size of the extrusion
52 from_size (double): lower size of the extrusion
54 .. function:: addExtrusionFuse(part, sketch, sketch_selection, boolean_objects, to_object, to_offset, from_object, from_offset)
57 part (ModelAPI_Document): part document
58 sketch (ModelAPI_Object): sketch feature
59 sketch_selection (Selection): sketch objects
60 boolean_objects (list of Selection): boolean objects
61 to_object (Selection): upper plane
62 to_offset (double): offset from upper plane
63 from_object (Selection): lower plane
64 from_offset (double): offset from lower plane
67 ExtrusionBoolean: extrusion boolean object
70 feature = part.addFeature("ExtrusionFuse")
71 return ExtrusionBoolean(feature, *args)
74 class ExtrusionBoolean(CompositeBoolean):
75 """Interface class for ExtrusionBoolean features.
82 .. function:: ExtrusionBoolean(feature)
84 Create interface for the feature without initialization.
86 .. function:: ExtrusionBoolean(feature, sketch, sketch_selection, boolean_objects, to_size, from_size)
88 Create interface for the feature and initialize the feature with arguments.
90 .. function:: ExtrusionBoolean(feature, sketch, sketch_selection, boolean_objects, to_object, to_offset, from_object, from_offset)
92 Create interface for the feature and initialize the feature with arguments.
95 def __init__(self, feature, *args):
96 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
97 CompositeBoolean.__init__(self, feature, *args[:3])
100 self._CreationMethod = self._feature.string("CreationMethod")
101 self._to_size = self._feature.data().real("to_size")
102 self._from_size = self._feature.data().real("from_size")
103 self._to_object = self._feature.data().selection("to_object")
104 self._to_offset = self._feature.data().real("to_offset")
105 self._from_object = self._feature.data().selection("from_object")
106 self._from_offset = self._feature.data().real("from_offset")
108 assert(self._CreationMethod)
109 assert(self._to_size)
110 assert(self._from_size)
111 assert(self._to_object)
112 assert(self._to_offset)
113 assert(self._from_object)
114 assert(self._from_offset)
119 assert(len(args) in (2, 4))
121 self.setPlanesAndOffsets(*args)
129 self._CreationMethod.setValue("BySizes")
130 self._fillAttribute(self._to_size, 0)
131 self._fillAttribute(self._from_size, 0)
132 self._fillAttribute(self._to_object, None)
133 self._fillAttribute(self._to_offset, 0)
134 self._fillAttribute(self._from_object, None)
135 self._fillAttribute(self._from_offset, 0)
138 def setSizes(self, to_size, from_size):
139 """Modify the to_size, from_size attributes of the feature.
144 self._CreationMethod.setValue("BySizes")
145 self._fillAttribute(self._to_size, to_size)
146 self._fillAttribute(self._from_size, from_size)
149 def setPlanesAndOffsets(self, to_object, to_offset,
150 from_object, from_offset):
151 """Modify planes and offsets attributes of the feature.
156 self._CreationMethod.setValue("ByPlanesAndOffsets")
157 self._fillAttribute(self._to_object, to_object)
158 self._fillAttribute(self._to_offset, to_offset)
159 self._fillAttribute(self._from_object, from_object)
160 self._fillAttribute(self._from_offset, from_offset)