2 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
9 from salome.geom import geomBuilder
12 class ExportFeature(ModelAPI.ModelAPI_Feature):
14 "Feature to create a box by drawing a sketch and extruding it"
17 ModelAPI.ModelAPI_Feature.__init__(self)
24 return ExportFeature.ID()
26 # This feature is action: has no property pannel and executes immideately
30 def isInHistory(self):
33 def initAttributes(self):
34 # This feature has no attributes, but should perfore some actions on initialization
35 aSession = ModelAPI.ModelAPI_Session.get()
36 aPart = aSession.activeDocument()
38 kResultBodyType = "Bodies"
39 aPartSize = aPart.size(kResultBodyType)
41 EventsAPI.Events_Error_send("No results in the active document")
44 anObjList = [aPart.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
45 for idx, anObject in enumerate(anObjList):
46 aResult = ModelAPI.modelAPI_Result(anObject)
47 aBodyResult = ModelAPI.modelAPI_ResultBody(aResult)
50 aShape = aBodyResult.shape()
51 aDump = aShape.getShapeStream()
52 # Load shape to SALOME Geom
53 geompy = geomBuilder.New(salome.myStudy)
54 aBrep = geompy.RestoreShape(aDump)
55 geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx))
58 # Nothing to execute: all logic would be in the initAttributes