CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[General] Pvpython animated slice

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 3, 2017, 07:25
Default Pvpython animated slice
  #1
New Member
 
Diego Ferrando
Join Date: Mar 2017
Location: Zaragoza
Posts: 19
Rep Power: 9
dferrando is on a distinguished road
Hello everyone!

I'm trying to write a python scritp in order to animate a slice in paraview. But I have a problem, when I run the script it returns 'slice object has no len()'. The problem is in these lines:
Code:
cue = KeyFrameAnimationCue()
SetActiveSource(slice1)
cue.AnimatedElement= GetActiveSource()
cue.AnimatedPropertyName = 'SliceOffsetValues'
AnimationScene1.Cues=[cue]
I don't know which is failing.

Thanks a lot.
dferrando is offline   Reply With Quote

Old   October 18, 2017, 09:47
Default
  #2
New Member
 
Diego Ferrando
Join Date: Mar 2017
Location: Zaragoza
Posts: 19
Rep Power: 9
dferrando is on a distinguished road
Ok, I have not been successful. Here is the complete script.
Can someone help me please?

Code:
from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

#Abre el archivo de OpenFOAM
foamFile = OpenFOAMReader(FileName = "spalartAllmaras.OpenFOAM")
timeSteps = foamFile.TimestepValues #Time steps en forma de array

#Crea la vista y la camara 
view1=CreateRenderView() #Crea una vista
view1.ViewSize = [800, 700] #Tamano de la vista
view1.CameraPosition = (0.4,-3.5,0.44) #Posicion de la camara 
view1.CameraFocalPoint = (0.4,0,0.44)  #Punto al que enfoca la camara
view1.CameraViewUp = (0,0,1) #Vector unitario para decidir que direccion se muestra hacia arriba
view1.CameraViewAngle = 30 #Angulo de la camara

#Slice
slice1=Slice(foamFile)
slice1.SliceType.Normal=(0,1,0)
slice1.SliceType.Origin = (0.4, 0, 0.44)

#Tiempo y vector velocidad.
view1.ViewTime = timeSteps[20]
annTime = AnnotateTimeFilter(foamFile)
Show(annTime)
annTime.Format="Time Step: %.f"

sliceDisplay = Show(slice1,view1)
sliceDisplay.ColorArrayName = ['POINTS', '']
ColorBy(sliceDisplay, ('POINTS', 'U'))
sliceDisplay.RescaleTransferFunctionToDataRange(True)
velLUT = GetColorTransferFunction('U')
velPWF = GetOpacityTransferFunction('U')

# RANGOS: Mag(0,6.8) X(-2,6.7), Y(-0.05,0.1), Z(-1.7,4.1)
velLUT.VectorMode='Magnitude'
velLUT.VectorComponent=2 #[Mag,U,V,W]
velLUT.RGBPoints = [0, 0, 0, 1, 6.8, 1, 0, 0] #Punto y color rgb

#Color bar
scalarBar = GetScalarBar(velLUT, view1)
scalarBar.Orientation='Horizontal'
scalarBar.Position = [0.3, 0.15]
scalarBar.Title="Velocidad" #Titulo
scalarBar.ComponentTitle="Magnitud" #Componente
scalarBar.LabelFormat="%.2f" #Formato de la escala
scalarBar.RangeLabelFormat="%.2f" #Formato del rango


#Animacion
AnimationScene1 = GetAnimationScene()
AnimationScene1.PlayMode = 'Sequence'
AnimationScene1.NumberOfFrames = 150

cue = KeyFrameAnimationCue() # < ---- ----- ---- ---- NO VA
SetActiveSource(slice1)
cue.AnimatedElement = GetActiveSource()
cue.AnimatedPropertyName = 'SliceOffsetValues'
AnimationScene1.Cues=[cue]

keyFrame0 = CompositeKeyFrame()
keyFrame0.Interpolation = 'Ramp'
keyFrame0.KeyTime = 0
keyFrame0.KeyValues= [-0.1]

keyFrame1 = CompositeKeyFrame()
keyFrame0.KeyTime = 100
keyFrame0.KeyValues= [0.1]

cue.KeyFrames = [keyFrame0, keyFrame1]

AnimationScene1.Play()
dferrando is offline   Reply With Quote

Old   October 19, 2017, 08:09
Default Example
  #3
New Member
 
Join Date: Jan 2017
Location: Austria
Posts: 20
Rep Power: 9
FluidWarrior is on a distinguished road
Hi,
an example of a Python script is here: https://www.researchgate.net/publica...t_and_ParaVIEW

Have Fun!
FluidWarrior is offline   Reply With Quote

Old   October 19, 2017, 12:15
Default
  #4
New Member
 
Diego Ferrando
Join Date: Mar 2017
Location: Zaragoza
Posts: 19
Rep Power: 9
dferrando is on a distinguished road
Quote:
Originally Posted by FluidWarrior View Post
Hi,
an example of a Python script is here: https://www.researchgate.net/publica...t_and_ParaVIEW

Have Fun!
Thank you for the reply, but this is not what I am looking for. There is not paraview scripting with paraview.simple python module.

Can someone tell me about some pvpyhon books? I have already read the paraview guide, but it does not teach how make a animated slice.
dferrando is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[General] Rotation of a slice beral ParaView 3 January 16, 2018 06:01
[OpenFOAM] pvpython TReviol ParaView 1 July 10, 2016 03:55
[General] Extract Slice Plane Dimensions in PvPython AeroJ ParaView 3 November 3, 2015 12:55
Extracting a non-uniform slice from a 3D geometry APSK Visualization & Post-Processing 1 October 30, 2014 15:56
Dragging Slice File = Crash cbritan OpenFOAM Bugs 3 January 6, 2011 03:58


All times are GMT -4. The time now is 13:36.