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