2 Authors: Renaud Nedelec - Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
10 class BoxFeature(model.Feature):
19 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
20 model.Feature.__init__(self)
24 """String constant."""
29 """String constant."""
34 """String constant."""
39 """String constant."""
43 """Override Feature.getKind()"""
44 return BoxFeature.ID()
47 # Creation of the box at default size
49 def initAttributes(self):
50 """Override Feature.initAttributes()"""
51 # Creating the input arguments of the feature
52 self.addRealInput(self.WIDTH_ID())
53 self.addRealInput(self.LENGTH_ID())
54 self.addRealInput(self.HEIGHT_ID())
56 # Creating the base of the box with unit values
57 mypart = model.activeDocument()
58 xoy = model.defaultPlane("XOY")
60 self.base = model.addSketch(mypart, xoy)
67 line = self.base.addPolygon(p1, p2, p3, p4)
69 self.base.setParallel(line[0].result(), line[2].result())
70 self.base.setParallel(line[1].result(), line[3].result())
71 self.base.setPerpendicular(line[0].result(), line[3].result())
73 # Setting the size of the base with default values
74 self.width = self.base.setLength(line[0].result(), 50) # Keeps the constraint for edition
75 self.length = self.base.setLength(line[3].result(), 50) # Keeps the constraint for edition
77 # Creating the extrusion (the box) at default size
78 self.box = model.addExtrusion(mypart, self.base.selectFace(), 50)
81 # Edition of the box at user size
84 """F.execute() -- execute the feature"""
85 # Retrieving the user inputs
86 width = self.getRealInput(self.WIDTH_ID())
87 length = self.getRealInpuut(self.WIDTH_ID())
88 length = self.getRealInt(self.LENGTH_ID())
89 height = self.getRealInput(self.HEIGHT_ID())
92 self.base.setValue(self.width, width)
93 self.base.setValue(self.length, length)
94 self.box.setSize(height)
96 # Publishing the result: not needed for Macro feature
97 # self.addResult( self.box.result() )
100 """Override Feature.initAttributes().
103 Box feature is macro: removes itself on the creation transaction