import vtk import time import datetime from pyvtk import * myscreen = VTKScreen() c1 = Cone() s1 = Sphere() cu1 = Cube() a = Arrow() t = Text() cyl=Cylinder() l = Line() p = PointSource(center=(2,3,1), radius=2) pl= Plane() pl.src.SetOrigin(0,0,-1) pl.src.SetPoint1(5,0,-1) pl.src.SetPoint2(0,5,-1) pl.src.SetCenter(0,0,-1) pl.SetColor((1,1,0)) ax = Axes() ax.src.SetScaleFactor(5) t.SetPos( (myscreen.width-200, myscreen.height-30) ) myscreen.addActor(c1) myscreen.addActor(s1) myscreen.addActor(cu1) myscreen.addActor(a) myscreen.addActor(t) myscreen.addActor(cyl) myscreen.addActor(l) myscreen.addActor(p) myscreen.addActor(ax) myscreen.addActor(pl) # screenshot stuff w2if = vtk.vtkWindowToImageFilter() w2if.SetInput(myscreen.renWin) lwr = vtk.vtkPNGWriter() lwr.SetInput( w2if.GetOutput() ) myscreen.render() for n in range(1,360): #te2.SetInput("Frame %d" % n) myscreen.camera.Azimuth( 1 ) t.SetText(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) myscreen.render() w2if.Modified() lwr.SetFileName("frame"+ ('%03d' % n)+".png") lwr.Write() time.sleep(0.01) raw_input("Press Enter to terminate") #----------------------------------------------------------------