4 class PythonFeaturesPlugin_Box(ModelAPI.ModelAPI_Feature):
5 "Feature to create a box by drawing a sketch and extruding it"
7 ModelAPI.ModelAPI_Feature.__init__(self)
26 return PythonFeaturesPlugin_Box.ID()
28 def initAttributes(self):
29 # C++ static methods (in example "type()" of the ModelAPI_AttributeDouble
30 # should be called like this: moduleName.ClassName_staticMethod()
31 self.data().addAttribute(PythonFeaturesPlugin_Box.WIDTH_ID(), ModelAPI.ModelAPI_AttributeDouble_type())
32 self.data().addAttribute(PythonFeaturesPlugin_Box.LENGTH_ID(), ModelAPI.ModelAPI_AttributeDouble_type())
33 self.data().addAttribute(PythonFeaturesPlugin_Box.HEIGHT_ID(), ModelAPI.ModelAPI_AttributeDouble_type())
36 aWidth = self.real(PythonFeaturesPlugin_Box.WIDTH_ID()).value()
37 aLength = self.real(PythonFeaturesPlugin_Box.LENGTH_ID()).value()
38 aHeight = self.real(PythonFeaturesPlugin_Box.HEIGHT_ID()).value()
39 print ("Box W:{0} L:{1} H:{2}".format(aWidth, aLength, aHeight))
40 aResultBody = self.document().createBody(self.data())
41 aResult = examples.makeBox(aLength, aWidth, aHeight)
42 #aShape = modelAPI_ResultConstruction(aResult).shape()
43 #aResultBody.store(aShape)
44 self.setResult(aResultBody)
48 if __name__=='__main__':
49 session = ModelAPI.ModelAPI_Session.get()
50 part = session.activeDocument()
51 session.startOperation()
52 feature = part.addFeature('Box')
53 feature.real('box_width').setValue(10)
54 feature.real('box_length').setValue(10)
55 feature.real('box_height').setValue(10)
57 session.finishOperation()