1 """ExtrusionSketch Interfaces
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from .roots import CompositeSketch
9 def addExtrusionSketch(part, *args):
10 """Add an ExtrusionSketch feature to the Part.
12 .. function:: addExtrusionSketch(part, sketch, sketch_selection, to_size, from_size)
15 part (ModelAPI_Document): part document
16 sketch (ModelAPI_Object): sketch feature
17 sketch_selection (Selection): sketch objects
18 to_size (double): upper size of the extrusion
19 from_size (double): lower size of the extrusion
21 .. function:: addExtrusionSketch(part, sketch, sketch_selection, to_object, to_offset, from_object, from_offset)
24 part (ModelAPI_Document): part document
25 sketch (ModelAPI_Object): sketch feature
26 sketch_selection (Selection): sketch objects
27 to_object (Selection): upper plane
28 to_offset (double): offset from upper plane
29 from_object (Selection): lower plane
30 from_offset (double): offset from lower plane
33 ExtrusionSketch: extrusion sketch object
36 feature = part.addFeature("ExtrusionSketch")
37 return ExtrusionSketch(feature, *args)
40 class ExtrusionSketch(CompositeSketch):
41 """Interface class for ExtrusionSketch feature.
43 .. function:: ExtrusionSketch(feature)
45 Create interface for the feature without initialization.
47 .. function:: ExtrusionSketch(feature, sketch, sketch_selection, to_size, from_size)
49 Create interface for the feature and initialize the feature with arguments.
51 .. function:: ExtrusionSketch(feature, sketch, sketch_selection, to_object, to_offset, from_object, from_offset)
53 Create interface for the feature and initialize the feature with arguments.
55 def __init__(self, feature, *args):
56 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
57 CompositeSketch.__init__(self, feature, *args[:2])
60 self._CreationMethod = self._feature.string("CreationMethod")
61 self._to_size = self._feature.data().real("to_size")
62 self._from_size = self._feature.data().real("from_size")
63 self._to_object = self._feature.data().selection("to_object")
64 self._to_offset = self._feature.data().real("to_offset")
65 self._from_object = self._feature.data().selection("from_object")
66 self._from_offset = self._feature.data().real("from_offset")
68 assert(self._CreationMethod)
70 assert(self._from_size)
71 assert(self._to_object)
72 assert(self._to_offset)
73 assert(self._from_object)
74 assert(self._from_offset)
79 assert(len(args) in (2, 4))
81 self.setPlanesAndOffsets(*args)
89 self._CreationMethod.setValue("BySizes")
90 self._fillAttribute(self._to_size, 0)
91 self._fillAttribute(self._from_size, 0)
92 self._fillAttribute(self._to_object, None)
93 self._fillAttribute(self._to_offset, 0)
94 self._fillAttribute(self._from_object, None)
95 self._fillAttribute(self._from_offset, 0)
98 def setSizes(self, to_size, from_size):
99 """Modify the to_size, from_size attributes of the feature.
104 self._CreationMethod.setValue("BySizes")
105 self._fillAttribute(self._to_size, to_size)
106 self._fillAttribute(self._from_size, from_size)
109 def setPlanesAndOffsets(self, to_object, to_offset,
110 from_object, from_offset):
111 """Modify planes and offsets attributes of the feature.
116 self._CreationMethod.setValue("ByPlanesAndOffsets")
117 self._fillAttribute(self._to_object, to_object)
118 self._fillAttribute(self._to_offset, to_offset)
119 self._fillAttribute(self._from_object, from_object)
120 self._fillAttribute(self._from_offset, from_offset)