Bonjour j'utilise paraview pour visualiser des fichiers de simulation mécanique
Afin d'automatiser l'ouverture et le traitement des images j'ai réalisé un script fonctionnel :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pvsimple
pvsimple.ShowParaviewView()
# trace generated using paraview version 5.9.0
 
#### import the simple module from the paraview
from pvsimple import *
#### disable automatic camera reset on 'Show'
pvsimple._DisableFirstRenderCameraReset()
i = 0
# create a new 'MED Reader'
bassin0med = MEDReader(registrationName='bassin' + str(i) + '.med', FileName='/media/vesvard211/Crucial X8/resultat_FSI/0.6S/maillage (1)/bassin' + str(i) + '.med')
 
# get animation scene
animationScene1 = GetAnimationScene()
 
# update animation scene based on data timesteps
animationScene1.UpdateAnimationUsingDataTimeSteps()
 
# Properties modified on bassin0med
bassin0med.AllArrays = ['TS0/bassin/ComSup0/Velocity@@][@@P0']
 
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
 
# show data in view
bassin0medDisplay = Show(bassin0med, renderView1, 'UnstructuredGridRepresentation')
 
# trace defaults for the display properties.
bassin0medDisplay.Representation = 'Surface'
 
# reset view to fit data
renderView1.ResetCamera()
 
# get the material library
materialLibrary1 = GetMaterialLibrary()
 
# update the view to ensure updated data information
renderView1.Update()
 
# set scalar coloring
ColorBy(bassin0medDisplay, ('CELLS', 'Velocity', 'Magnitude'))
 
# rescale color and/or opacity maps used to include current data range
bassin0medDisplay.RescaleTransferFunctionToDataRange(True, False)
 
# show color bar/color legend
bassin0medDisplay.SetScalarBarVisibility(renderView1, True)
 
# get color transfer function/color map for 'Velocity'
velocityLUT = GetColorTransferFunction('Velocity')
 
# get opacity transfer function/opacity map for 'Velocity'
velocityPWF = GetOpacityTransferFunction('Velocity')
 
#### saving camera placements for all active views
 
# current camera placement for renderView1
renderView1.CameraPosition = [0.12, 0.0, 1.7787239526758387]
renderView1.CameraFocalPoint = [0.12, 0.0, 0.1500000000000064]
renderView1.CameraParallelScale = 0.4215447781671621
Mais quand je tente de créer une boucle afin d'ouvrir plusieurs images il ne fonctionne plus
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import pvsimple
pvsimple.ShowParaviewView()
# trace generated using paraview version 5.9.0
 
#### import the simple module from the paraview
from pvsimple import *
#### disable automatic camera reset on 'Show'
pvsimple._DisableFirstRenderCameraReset()
b = [None]
d = [None]
for i in range(0 ,2, 30 ):
# create a new 'MED Reader'
b.append("bassin/%s" % i)
d.append("bassin/%s" % i + "Display" )
b[i] = MEDReader(registrationName='bassin' + str(i) + '.med', FileName='/media/vesvard211/Crucial X8/resultat_FSI/0.6S/maillage (1)/bassin' + str(i) + '.med')
 
# get animation scene
animationScene1 = GetAnimationScene()
 
# update animation scene based on data timesteps
animationScene1.UpdateAnimationUsingDataTimeSteps()
 
# Properties modified on bassin0med
b[i].AllArrays = ['TS0/bassin/ComSup0/Velocity@@][@@P0']
 
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
 
# show data in view
d[i] = Show(b[i], renderView1, 'UnstructuredGridRepresentation')
 
# trace defaults for the display properties.
d[i].Representation = 'Surface'
 
# reset view to fit data
renderView1.ResetCamera()
 
# get the material library
materialLibrary1 = GetMaterialLibrary()
 
# update the view to ensure updated data information
renderView1.Update()
 
# set scalar coloring
ColorBy(d[i], ('CELLS', 'Velocity', 'Magnitude'))
 
# rescale color and/or opacity maps used to include current data range
d[i].RescaleTransferFunctionToDataRange(True, False)
 
# show color bar/color legend
d[i].SetScalarBarVisibility(renderView1, True)
 
# get color transfer function/color map for 'Velocity'
velocityLUT = GetColorTransferFunction('Velocity')
 
# get opacity transfer function/opacity map for 'Velocity'
velocityPWF = GetOpacityTransferFunction('Velocity')
 
#### saving camera placements for all active views
 
# current camera placement for renderView1
renderView1.CameraPosition = [0.12, 0.0, 1.7787239526758387]
renderView1.CameraFocalPoint = [0.12, 0.0, 0.1500000000000064]
renderView1.CameraParallelScale = 0.4215447781671621
Si quelqu'un à une idée cela m'aiderait grandement