|
[Sponsors] |
October 3, 2017, 08:25 |
Pvpython animated slice
|
#1 |
New Member
Diego Ferrando
Join Date: Mar 2017
Location: Zaragoza
Posts: 19
Rep Power: 9 |
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] Thanks a lot. |
|
October 18, 2017, 10:47 |
|
#2 |
New Member
Diego Ferrando
Join Date: Mar 2017
Location: Zaragoza
Posts: 19
Rep Power: 9 |
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() |
|
October 19, 2017, 09:09 |
Example
|
#3 |
New Member
Join Date: Jan 2017
Location: Austria
Posts: 20
Rep Power: 9 |
Hi,
an example of a Python script is here: https://www.researchgate.net/publica...t_and_ParaVIEW Have Fun! |
|
October 19, 2017, 13:15 |
|
#4 | |
New Member
Diego Ferrando
Join Date: Mar 2017
Location: Zaragoza
Posts: 19
Rep Power: 9 |
Quote:
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. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] Rotation of a slice | beral | ParaView | 3 | January 16, 2018 07:01 |
[OpenFOAM] pvpython | TReviol | ParaView | 1 | July 10, 2016 04:55 |
[General] Extract Slice Plane Dimensions in PvPython | AeroJ | ParaView | 3 | November 3, 2015 13:55 |
Extracting a non-uniform slice from a 3D geometry | APSK | Visualization & Post-Processing | 1 | October 30, 2014 16:56 |
Dragging Slice File = Crash | cbritan | OpenFOAM Bugs | 3 | January 6, 2011 04:58 |