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

[General] Image Paraview with Python

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Swempa

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 21, 2017, 19:15
Arrow Image Paraview with Python
  #1
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10
FlyBob91 is on a distinguished road
Hello to all,
my teacher asked me to find a manner to produce a series of images and to automate this procedure because we have to make different test for the colour etc. After a rapid search i (maybe) understand that this could be made by the use of a python script. First, am i right? Is it possible?
If yes, how can i do that? Unfortunately i have no time to learn a new language because i'm near a deadline, so i ask if there are some scripts available that make this operation or a detailed references.

Thanks for help
FlyBob91 is offline   Reply With Quote

Old   November 22, 2017, 06:03
Default
  #2
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10
FlyBob91 is on a distinguished road
Hello to all,
little update. I found the following example to generate a sphere and save the image

Code:
from paraview.simple import *
simple.Sphere()
simple.Show()
simple.Render()
simple.WriteImage("foo.png")
but, unfortunatley, when i run this script an errorr occurs and it does not load the module.

Code:
 
Traceback (most recent call last):
  File "ciao.py", line 2, in <module>
    from paraview.simple import *
ImportError: No module named 'paraview'
i use python3
What's i'm doing wrong?
FlyBob91 is offline   Reply With Quote

Old   November 22, 2017, 10:44
Default
  #3
Member
 
Swempa's Avatar
 
Join Date: Apr 2015
Posts: 37
Rep Power: 11
Swempa is on a distinguished road
Quote:
Originally Posted by FlyBob91 View Post
Hello to all,
little update. I found the following example to generate a sphere and save the image

Code:
from paraview.simple import *
simple.Sphere()
simple.Show()
simple.Render()
simple.WriteImage("foo.png")
but, unfortunatley, when i run this script an errorr occurs and it does not load the module.

Code:
 
Traceback (most recent call last):
  File "ciao.py", line 2, in <module>
    from paraview.simple import *
ImportError: No module named 'paraview'
i use python3
What's i'm doing wrong?
Hi FlyBob91,

Paraview works perfect to script with python and if you have everything installed correctly its often quite straight forward.

I would start by removing the "simple" syntax on the commands while its already declared in the header.

Code:
from paraview.simple import *
sphere1=Sphere()
sphere1.ThetaResolution = 100
sphere1.PhiResolution = 100
Show()
WriteImage("foo.png")
Good luck with your project.
Cheers
Attached Images
File Type: png sphere.PNG (138.6 KB, 1 views)
FlyBob91 likes this.
Swempa is offline   Reply With Quote

Old   November 27, 2017, 17:53
Default
  #4
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10
FlyBob91 is on a distinguished road
Hi Swempa,
Sorry for my late answer but i'm very busy in this period.
I faced the same problem. Maybe i did not install paraview in the right way to work correctly with python? I installed it with the classic "sudo apt-get install paraview".
Another question: should the script be positioned in some specific forlder?

Many thanks for help
FlyBob91 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] Listing the inputs of a grouped dataset with a programmable python filter in Paraview NadineHS ParaView 3 December 12, 2021 15:54
[OpenFOAM] Paraview from python shell : Glew initialization and VTKcommoncorepython error pradyumnsingh ParaView 0 September 18, 2018 14:40
[General] Loading .stl file with python shell in paraview New-to-CFD ParaView 2 May 23, 2017 13:31
[OpenFOAM.org] OF 2.3.0 compiling Paraview with "-python -mpi" bender.rodriguez OpenFOAM Installation 5 December 14, 2014 13:27
How to get Python Shell into ParaView 3.8.1? blaise OpenFOAM Installation 3 July 24, 2012 05:58


All times are GMT -4. The time now is 18:49.