2 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
7 from salome.geom import geomBuilder
10 class ExportFeature(ModelAPI.ModelAPI_Feature):
12 "Feature to create a box by drawing a sketch and extruding it"
15 ModelAPI.ModelAPI_Feature.__init__(self)
22 return ExportFeature.ID()
24 # This feature is action: has no property pannel and executes immideately
28 def initAttributes(self):
29 # This feature has no attributes, but should perfore some actions on initialization
30 aSession = ModelAPI.ModelAPI_Session.get()
31 aPart = aSession.activeDocument()
33 kResultBodyType = "ResultBody"
34 aPartSize = aPart.size(kResultBodyType)
36 print "No results in the active document"
39 aResultList = [aPart.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
40 for idx, aResult in enumerate(aResultList):
41 aBodyResult = modelAPI_ResultBody(aResult)
44 aShape = aBodyResult.shape()
45 aDump = aShape.getShapeStream()
46 # Load shape to SALOME Geom
47 geompy = geomBuilder.New(salome.myStudy)
48 aBrep = geompy.RestoreShape(aDump)
49 geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx))
52 # Nothing to execute: all logic would be in the initAttributes
57 if __name__=='__main__':
58 session = ModelAPI.ModelAPI_Session.get()
59 part = session.activeDocument()
60 session.startOperation()
61 feature = part.addFeature('Box')
62 feature.real('box_width').setValue(10)
63 feature.real('box_length').setValue(10)
64 feature.real('box_height').setValue(10)
66 session.finishOperation()