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

[General] Save Animation via command line

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 4 Post By wyldckat
  • 3 Post By paraJim

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 23, 2013, 07:05
Smile Save Animation via command line
  #1
New Member
 
Join Date: Feb 2013
Posts: 4
Rep Power: 13
paraJim is on a distinguished road
Hi there,

I would like to know how to control ParaView via command line to perform the following tasks:

- Load a 3d model file (like *.stl)
- Set camera to "orbit"
- Save the animation to ogv

I simply want to create a rotating animation from a 3d model to show in a webbrowser.

If I guess correctly I have to use python to accomplish this task?

Thanks in advance
paraJim is offline   Reply With Quote

Old   February 23, 2013, 08:10
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings paraJim and welcome to the forum!

I'm short on time, so I'm only able to give the following hints:
  1. You can use pvpython or pvbatch for using/controlling from the command line. But it will not have an open ParaView window, if I remember correctly.
  2. (Semi-)Official instructions available here: http://www.paraview.org/Wiki/ParaView/Python_Scripting
  3. I don't know the level of web display you want to provide, but there is also ParaViewWeb: http://www.paraview.org/Wiki/ParaViewWeb
Good luck!
Bruno
Pagoda, paraJim, amuzeshi and 1 others like this.
__________________
wyldckat is offline   Reply With Quote

Old   February 24, 2013, 13:39
Lightbulb
  #3
New Member
 
Join Date: Feb 2013
Posts: 4
Rep Power: 13
paraJim is on a distinguished road
Hi wyldckat,

thanks for the fast response.

What I have tried so far:

I opened up ParaView, loaded a STL file and executed the following code in the python shell of ParaView:

Code:
movie = servermanager.animation.AnimationScene()
movie.ViewModules = [GetActiveView()]
movie.NumberOfFrames = 10
movie_writer = servermanager.vtkSMAnimationSceneImageWriter()
movie_writer.SetFileName("C:\movie.avi")
movie_writer.SetFrameRate(1)
movie_writer.SetQuality(2)
movie_writer.SetAnimationScene(movie.SMProxy)
movie_writer.Save()
(i found the code sample in a paraview mailing list)

Which actually creates an avi file.

What I didn't figure out is:
- How to load any 3d Model into the script?
- How to add the animation to the script? I want that the camera orbits around the object.

Here seems to be a solution for setting up the camera to orbit in python but i can't download the python script. http://www.paraview.org/pipermail/pa...ch/011400.html

I think I am getting closer.
paraJim is offline   Reply With Quote

Old   February 24, 2013, 16:05
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi paraJim,

Sorry, I was so focused on the command line that I forgot to mention that you can use the "Python Trace" to help you generate the script that loads the files and so forth: http://www.paraview.org/Wiki/Python_GUI_Tools

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   February 24, 2013, 16:20
Smile
  #5
New Member
 
Join Date: Feb 2013
Posts: 4
Rep Power: 13
paraJim is on a distinguished road
Hi wyldckat,

thanks for your response.

My script is almost finished. This is what I have got so far:

Code:
from paraview.simple import *

movie = servermanager.animation.AnimationScene()
movie.ViewModules = [GetActiveView()]
movie.NumberOfFrames = 48
# find view object
view = GetActiveView()

# Create an animation cue for the camera. This represents the "track" shown in cuethe Animation View.
cue = servermanager.animation.CameraAnimationCue()
cue.AnimatedProxy = [view]

# Add this cue to the scene.
movie.Cues = [cue]

# Now create keyframes. Let's say we are going to orbit around the object.
camera = view.GetActiveCamera()
num_of_keyframes = 10
listKeyframe = []
for i in range(0, num_of_keyframes):
    camera.Azimuth(360.0/num_of_keyframes)
    keyframe = servermanager.animation.CameraKeyFrame()
    # set the value of the key frame to the current camera location.
    keyframe.KeyTime = i*1.0/num_of_keyframes
    keyframe.Position = camera.GetPosition()
    keyframe.FocalPoint = camera.GetFocalPoint()
    keyframe.ViewUp = camera.GetViewUp()
    keyframe.ViewAngle = camera.GetViewAngle()
    listKeyframe.append(keyframe)

#cue.KeyFrames.append(keyframe) because 'append' don't exist for this object
cue.KeyFrames = listKeyframe

movie_writer = servermanager.vtkSMAnimationSceneImageWriter()
movie_writer.SetFileName("C:\movie.avi")
movie_writer.SetFrameRate(24)
movie_writer.SetQuality(2)
movie_writer.SetAnimationScene(movie.SMProxy)
movie_writer.Save()
It successfully creates the orbit animation and saves it to disk as an avi file.

One problem still exists:

- How can I load a file to the python script if I don't know the file type?

If I have a vtk file I need to run:
reader = servermanager.sources.LegacyVTKReader(FileNames='m yFile.vtk')

If I have a stl file I need to run:
reader = STLReader( FileNames=['myFile.stl'] )

Is there a "generic" reader that can read everything?
paraJim is offline   Reply With Quote

Old   February 24, 2013, 16:33
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Not that I'm aware of. You'll probably have to use if statements: http://www.tutorialspoint.com/python/python_if_else.htm
__________________
wyldckat is offline   Reply With Quote

Old   February 24, 2013, 16:35
Thumbs up
  #7
New Member
 
Join Date: Feb 2013
Posts: 4
Rep Power: 13
paraJim is on a distinguished road
Hi wyldckat,

I found another way in the documentation:

Alternatively, starting with ParaView 3.8, you can use OpenDataFile() function to let ParaView pick a reader using the extension of the file.
>>> reader = OpenDataFile(“.../can.ex2”)
Thank you very much for your help.

EDIT:
Do you know how to suppress the preview dialog when running the script with pvpython.exe or pvbatch.exe?
wyldckat, deepinheart and arvindpj like this.

Last edited by paraJim; February 24, 2013 at 16:58.
paraJim is offline   Reply With Quote

Old   February 24, 2013, 17:04
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by paraJim View Post
EDIT:
Do you know how to suppress the preview dialog when running the script with pvpython.exe or pvbatch.exe?
I know I've tested this in the past... but it was on Linux... it's this one I think: Using offscreen rendering post #4
Not sure how it will work on Windows...
__________________
wyldckat is offline   Reply With Quote

Old   February 17, 2017, 11:15
Default
  #9
Member
 
Join Date: Nov 2012
Posts: 83
Rep Power: 14
Henning86 is on a distinguished road
it is possible to load a state file and save it as animation:

Quote:
from paraview.simple import *

servermanager.LoadState("Test.pvsm")
SetActiveView(GetRenderView())
view = GetActiveView()
scene = GetAnimationScene()

view.ViewSize = [1920,1080] # change resolution
#view.StereoRender = 1
#view.UseOffscreenRendering = 1



scene = GetAnimationScene()
scene.EndTime = 0.1
scene.PlayMode = 'Snap To TimeSteps'
scene.AnimationTime = 2.0



# save animation images/movie
WriteAnimation('./Test.ogv', Magnification=1, FrameRate=10.0, Compression=False)


worked with paraview v52 to execute type:

pvbatch FILENAME
Henning86 is offline   Reply With Quote

Reply

Tags
animation, command line


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] Save Animation Settings TomBot ParaView 2 August 26, 2017 08:54
[General] Save Animation using high image resolution doesn't work Omid999 ParaView 0 July 10, 2017 05:49
How to save Tecplot animation as GIF Roule Tecplot 0 January 24, 2016 07:44
How to save an animation to mpeg file jack FLUENT 1 June 25, 2008 14:26
save run animation Anis Phoenics 2 November 26, 2007 22:40


All times are GMT -4. The time now is 16:51.