1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2014-2016 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 XTPlugin import IXTOperations
24 __libraryName__ = "XTPluginEngine"
26 ## Get XT plugin operations interface
27 # @return an instance of XT plugin operations interface
28 def GetXTPluginOperations(self):
30 Get XT plugin operations interface.
33 An instance of XT plugin operations interface
35 anOp = self.GetPluginOperations(self.myStudyId, __libraryName__)
36 return anOp._narrow(IXTOperations)
38 ## Import a shape from the XT file
39 # @param theFileName The file, containing the shape.
40 # @param theName Object name; when specified, this parameter is used
41 # for result publication in the study. Otherwise, if automatic
42 # publication is switched on, default value is used for result name.
44 # @return New GEOM.GEOM_Object, containing the imported shape.
45 # If material names are imported it returns the list of
46 # objects. The first one is the imported object followed by
48 # @note Auto publishing is allowed for the shape itself. Imported
49 # material groups are not automatically published.
50 def ImportXT(self, theFileName, theName=None):
52 Import a shape from the XT file
55 theFileName The file, containing the shape.
56 theName Object name; when specified, this parameter is used
57 for result publication in the study. Otherwise, if automatic
58 publication is switched on, default value is used for result name.
61 New GEOM.GEOM_Object, containing the imported shape.
62 If material names are imported it returns the list of
63 objects. The first one is the imported object followed by
66 Auto publishing is allowed for the shape itself. Imported
67 material groups are not automatically published.
69 from salome.geom.geomBuilder import RaiseIfFailed
70 anOp = GetXTPluginOperations(self)
71 aListObj = anOp.ImportXT(theFileName)
72 RaiseIfFailed("ImportXT", anOp)
73 aNbObj = len(aListObj)
75 self._autoPublish(aListObj[0], theName, "imported")