Skip to content

Instantly share code, notes, and snippets.

@1f0
Created June 2, 2018 03:06
Show Gist options
  • Save 1f0/4cb91467c2f09ab094de527dfbfc5178 to your computer and use it in GitHub Desktop.
Save 1f0/4cb91467c2f09ab094de527dfbfc5178 to your computer and use it in GitHub Desktop.
paraview-python simple code rendering obj
from __future__ import print_function
from paraview.simple import *
import sys
import vtk
if(len(sys.argv) < 3):
print('Usage: ', sys.argv[0], 'input.obj', 'output.png', '[camera.pvcc]')
reader = WavefrontOBJReader(FileName=sys.argv[1])
Show(reader)
SetViewProperties(ViewSize = [512, 512])
# set camera
if len(sys.argv) == 4:
import xml.etree.ElementTree
e = xml.etree.ElementTree.parse(sys.argv[3]).getroot()
camera = GetActiveCamera()
props = e[0]
pos = props[0]
def at(p, i):
return float(p[i].attrib['value'])
camera.SetPosition(at(props[0],0), at(props[0],1), at(props[0],2))
camera.SetFocalPoint(at(props[1],0), at(props[1],1), at(props[1],2))
camera.SetViewUp(at(props[2],0), at(props[2],1), at(props[2],2))
renview = GetActiveView()
renview.OrientationAxesVisibility = 0
disp_props = GetDisplayProperties()
disp_props.Opacity = 0.7
Render()
SaveScreenshot(sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment