1 # Copyright (C) 2014-2015 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Macro to show SALOME object in ParaView viewer.
23 # The macro inspects current selection obtained from SALOME GUI
24 # and displays supported objects in the viewer:
36 session = salome.naming_service.Resolve('/Kernel/Session')
38 from pvsimple import *
40 selection = session.getSelection()
42 for entry in selection:
43 sobj = salome.myStudy.FindObjectID(entry)
46 from salome.geom import geomBuilder
47 geompy = geomBuilder.New(salome.myStudy)
48 go = sobj.GetObject()._narrow(GEOM.GEOM_Object)
50 tmpf = tempfile.NamedTemporaryFile(suffix='.vtk')
53 geompy.ExportVTK(go, fname)
55 p = LegacyVTKReader(FileNames=[fname])
56 renderView = GetActiveViewOrCreate('RenderView')
57 pd = Show(p, renderView)
58 renderView.ResetCamera()
66 from salome.smesh import smeshBuilder
67 mesh = smeshBuilder.New(salome.myStudy)
68 mo = sobj.GetObject()._narrow(SMESH.SMESH_Mesh)
70 tmpf = tempfile.NamedTemporaryFile(suffix='.med')
73 mo.ExportToMEDX(fname, True, SMESH.MED_V2_2, True, True)
75 p = MEDReader(FileName=fname)
76 renderView = GetActiveViewOrCreate('RenderView')
77 pd = Show(p, renderView)
78 renderView.ResetCamera()