ParaView/Python/Screenshot: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
m (added footer)
mNo edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 11: Line 11:
#position camera
#position camera
view = GetActiveView()
view = GetActiveView()
if not view:
    # When using the ParaView UI, the View will be present, not otherwise.
    view = CreateRenderView()
view.CameraViewUp = [0, 0, 1]
view.CameraViewUp = [0, 0, 1]
view.CameraFocalPoint = [0, 0, 0]
view.CameraFocalPoint = [0, 0, 0]
Line 23: Line 26:


#set image size
#set image size
view.RenderWindowSize = [200, 300] #[width, height]
view.ViewSize = [200, 300] #[width, height]


dp = GetDisplayProperties()
dp = GetDisplayProperties()
Line 45: Line 48:
</source>
</source>


Back to [[ParaView/PythonRecipes]].
{{ParaView/Template/Footer}}
{{ParaView/Template/Footer}}

Latest revision as of 18:36, 16 October 2018

<source lang="python">

  1. !/usr/bin/pvpython

from paraview.simple import *

import time

  1. read a vtp

reader = XMLPolyDataReader(FileName="input.vtp")

  1. position camera

view = GetActiveView() if not view:

   # When using the ParaView UI, the View will be present, not otherwise.
   view = CreateRenderView()

view.CameraViewUp = [0, 0, 1] view.CameraFocalPoint = [0, 0, 0] view.CameraViewAngle = 45 view.CameraPosition = [5,0,0]

  1. draw the object

Show()

  1. set the background color

view.Background = [1,1,1] #white

  1. set image size

view.ViewSize = [200, 300] #[width, height]

dp = GetDisplayProperties()

  1. set point color

dp.AmbientColor = [1, 0, 0] #red

  1. set surface color

dp.DiffuseColor = [0, 1, 0] #blue

  1. set point size

dp.PointSize = 2

  1. set representation

dp.Representation = "Surface"

Render()

  1. save screenshot

WriteImage("test.png") </source>

Back to ParaView/PythonRecipes.


ParaView: [Welcome | Site Map]