1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2014-2016 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from GEOM import IXAOOperations
24 __libraryName__ = "XAOPluginEngine"
26 def GetXAOPluginOperations(self):
27 anOp = self.GetPluginOperations(self.myStudyId, __libraryName__)
28 return anOp._narrow(IXAOOperations)
30 ## Export a shape to XAO format
31 # @param shape The shape to export
32 # @param groups The list of groups to export
33 # @param fields The list of fields to export
34 # @param author The author of the file
35 # @param fileName The name of the file to export
36 # @param shapeFileName The name of the BRep file to export
37 # @return True if operation is successful or False otherwise
39 # @ingroup l2_import_export
40 def ExportXAO(self, shape, groups, fields, author, fileName, shapeFileName = ""):
42 Export a shape to XAO format
45 shape The shape to export
46 groups The list of groups to export
47 fields The list of fields to export
48 author The author of the file
49 fileName The name of the file to export
52 True if operation is successful or False otherwise
54 from salome.geom.geomBuilder import RaiseIfFailed
55 anOp = GetXAOPluginOperations(self)
56 res = anOp.ExportXAO(shape, groups, fields, author, fileName, shapeFileName)
57 RaiseIfFailed("ExportXAO", anOp)
60 ## Import a shape from XAO format
61 # @param fileName The name of the file to import
62 # @param theName Object name; when specified, this parameter is used
63 # for result publication in the study. Otherwise, if automatic
64 # publication is switched on, default value is used for result name.
66 # @return tuple (\a res, \a shape, \a subShapes, \a groups, \a fields)
67 # \a res Flag indicating if the import was successful
68 # \a shape The imported shape
69 # \a subShapes The list of imported subShapes
70 # \a groups The list of imported groups
71 # \a fields The list of imported fields
73 # @ingroup l2_import_export
74 def ImportXAO(self, fileName, theName=None):
76 Import a shape from XAO format
79 fileName The name of the file to import
80 theName Object name; when specified, this parameter is used
81 for result publication in the study. Otherwise, if automatic
82 publication is switched on, default value is used for result name.
85 A tuple (res, shape, subShapes, groups, fields):
86 - res: Flag indicating if the import was successful
87 - shape: The imported shape
88 - subShapes: The list of imported subShapes
89 - groups: The list of imported groups
90 - fields: The list of imported fields
92 from salome.geom.geomBuilder import RaiseIfFailed
93 anOp = GetXAOPluginOperations(self)
94 res = anOp.ImportXAO(fileName)
95 RaiseIfFailed("ImportXAO", anOp)
96 self._autoPublish(res[1], theName, "imported")