[Paraview] SOLVED: TypeError: WriteImage() takes exactly 3 arguments (1 given)

Anton Shterenlikht mexas at bristol.ac.uk
Thu Mar 14 11:49:00 EDT 2013


	From mexas Thu Mar 14 15:28:50 2013
	To: paraview at paraview.org
	Subject: TypeError: WriteImage() takes exactly 3 arguments (1 given)
	Reply-To: mexas at bristol.ac.uk

	I get this error:

	>>> view.WriteImage("z.png")
	Traceback (most recent call last):
	  File "<stdin>", line 1, in <module>
	  File "/usr/local/lib/paraview-3.10/site-packages/paraview/servermanager.py", line 331, in __ConvertArgumentsAndCall
	    retVal = func(*newArgs)
	TypeError: WriteImage() takes exactly 3 arguments (1 given)
	>>> 

	The tutorial suggests that just the filename is enough:

	http://paraview.org/Wiki/ParaView/Python_Scripting

	Anyway, I can see in other examples that the second argument
	is the file format, e.g.:

	view.WriteImage("z.png","vtkPNGWriter")

	but this gives the same error:

	>>> view.WriteImage("z.png","vtkPNGWriter")
	Traceback (most recent call last):
	  File "<stdin>", line 1, in <module>
	  File "/usr/local/lib/paraview-3.10/site-packages/paraview/servermanager.py", line 331, in __ConvertArgumentsAndCall
	    retVal = func(*newArgs)
	TypeError: WriteImage() takes exactly 3 arguments (2 given)
	>>> 

	I cannot find what the third argument must be.

	Please help

	Anton

Answering my own question, it seems different
help is provided in servermanager and in simple
modules. If I load servermanager, I get:

>>> help (WriteImage)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'WriteImage' is not defined
>>> 

But if I load simple, I get:

>>> from paraview.simple import *
paraview version 3.10.1, Date: 2011-01-28
>>> help (WriteImage)
Help on function WriteImage in module paraview.simple:

WriteImage(filename, view=None, **params)
    Saves the given view (or the active one if none is given) as an
    image. Optionally, you can specify the writer and the magnification
    using the Writer and Magnification named arguments. For example:
     WriteImage("foo.mypng", aview, Writer=vtkPNGWriter, Magnification=2)
    If no writer is provided, the type is determined from the file extension.
    Currently supported extensions are png, bmp, ppm, tif, tiff, jpg and jpeg.
    The writer is a VTK class that is capable of writing images.
    Magnification is used to determine the size of the written image. The size
    is obtained by multiplying the size of the view with the magnification.
    Rendering may be done using tiling to obtain the correct size without
    resizing the view.

>>>

So I got it working now.

Anton


More information about the ParaView mailing list