|
[Sponsors] |
[General] Generating isosurface from vtk file with python script |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 25, 2018, 09:53 |
Generating isosurface from vtk file with python script
|
#1 |
New Member
James Schloss
Join Date: Mar 2018
Posts: 1
Rep Power: 0 |
I have a vtk file that is generated via auxiliary code and would like to generate isosurfaces of this (3D) data. I can read this in correctly and create the necessary isosurfaces manually, and can even do the same with the python shell when the gui is up by doing the following:
Code:
import paraview.simple as ps # reads in a vtk file test = ps.OpenDataFile("/path/to/test.vtk") c = ps.Contour(Input=test, Isosurfaces=[0.5]) ps.Show(test) ps.Show(c) ps.Render() ps.WriteImage("/path/to/check.png") The closest solution to this can be found here: https://colorsfordirectors.wordpress...ython-scripts/ Code:
# 1. import the paraview.simple module (here renammed 'pvs') import paraview.simple as pvs # 2. create the filter with desired input my_filter = pvs.FilterName(Input=my_data) # 3. set properties my_filter.PropertyOne = [0, 0, 0] # 4. update the filter (optionnal) my_filter.UpdatePipeline() I will test this out on another paraview installation / linux distribution tomorrow when I get back into the office. I am currently running Arch and paraview 5.4.1 . If anyone has any advice, I would love to hear it! I'm new to paraview python scripting and am having a bit of trouble figuring everything out. Thanks for reading and any help you can provide! |
|
March 26, 2018, 13:33 |
|
#2 |
New Member
Forge Analytics
Join Date: Jan 2018
Posts: 16
Rep Power: 8 |
You'll probably want something like the following:
Code:
import paraview.simple as ps view = ps.GetActiveViewOrCreate('RenderView') # reads in a vtk file test = ps.OpenDataFile("/path/to/test.vtk") test_display = ps.Show(test, view) view.Update() c = ps.Contour(Input=test, Isosurfaces=[0.5]) c_display = ps.Show(c, view) # If you want to hide the original data (or don't show in first place) # ps.Hide(test, view) view.Update() # set camera position... ps.SaveScreenshot('/path/to/img.png', view, ImageResolution=[1920,1080]) # or ps.RenderAllViews() ParaView has a Python script recorder at "Tools >> Start Trace" and "Tools >> Stop Trace" that you'll find useful (if you weren't using it already). Let me know if you have any problems.
__________________
https://forgeanalytics.io/ | Data Management for Scientists and Engineers |
|
Tags |
isosurface, paraview, python, python script |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 04:30 |
OpenFoam "Permission denied" and "command not found" problems. | iyidaniel@yahoo.co.uk | OpenFOAM Running, Solving & CFD | 11 | January 2, 2018 07:47 |
SparceImage v1.7.x Issue on MAC OS X | rcarmi | OpenFOAM Installation | 4 | August 14, 2014 07:42 |
[swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 06:18 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |