|
[Sponsors] |
February 23, 2013, 07:05 |
Save Animation via command line
|
#1 |
New Member
Join Date: Feb 2013
Posts: 4
Rep Power: 13 |
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 |
|
February 23, 2013, 08:10 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings paraJim and welcome to the forum!
I'm short on time, so I'm only able to give the following hints:
Bruno
__________________
|
|
February 24, 2013, 13:39 |
|
#3 |
New Member
Join Date: Feb 2013
Posts: 4
Rep Power: 13 |
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() 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. |
|
February 24, 2013, 16:05 |
|
#4 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
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
__________________
|
|
February 24, 2013, 16:20 |
|
#5 |
New Member
Join Date: Feb 2013
Posts: 4
Rep Power: 13 |
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() 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? |
|
February 24, 2013, 16:33 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Not that I'm aware of. You'll probably have to use if statements: http://www.tutorialspoint.com/python/python_if_else.htm
__________________
|
|
February 24, 2013, 16:35 |
|
#7 |
New Member
Join Date: Feb 2013
Posts: 4
Rep Power: 13 |
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? Last edited by paraJim; February 24, 2013 at 16:58. |
|
February 24, 2013, 17:04 |
|
#8 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Quote:
Not sure how it will work on Windows...
__________________
|
||
February 17, 2017, 11:15 |
|
#9 | |
Member
Join Date: Nov 2012
Posts: 83
Rep Power: 14 |
it is possible to load a state file and save it as animation:
Quote:
pvbatch FILENAME |
||
Tags |
animation, command line |
|
|
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 |