2 Author: Daniel Brunier-Coulin with contribution by Mikhail Ponikarov
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
10 """Class for Extrusion feature"""
11 def __init__ (self, part, sketch, size):
12 """Inserts an extrusion of the given Sketch to the given Part and executes the operation."""
13 ### Create the feature
14 self.my = part.addFeature("Extrusion")
15 self.my.string("CreationMethod").setValue("BySizes")
16 self.my.data().selectionList("base").append(sketch.result(), sketch.buildShape())
18 self.my.data().real("from_size").setValue(-size)
19 self.my.data().real("to_size").setValue(0)
21 self.my.data().real("to_size").setValue(size)
22 self.my.data().real("from_size").setValue(0)
25 if ModelAPI_Session.get().validators().validate(self.my):
28 raise Exception("cannot make the Extrusion")
31 def setSize (self, size):
32 """Modifies the size of this extrusion according to the given size."""
34 self.my.data().real("from_size").setValue(-size)
35 self.my.data().real("to_size").setValue(0)
37 self.my.data().real("to_size").setValue(size)
38 self.my.data().real("from_size").setValue(0)
43 """Returns the result data of this Feature."""
44 return self.my.firstResult()