[Paraview] vtkGL2PSExporter usage from within Paraview's python shell

Marcin Sliwowski ms275 at duke.edu
Thu Jun 17 16:15:18 EDT 2010


  Pat,

Thanks for the explanation on the proper import and how to get at the 
local render window. With your help I was able to do what I wanted.

I'm not a Paraview user, but I am supporting someone that is and he 
needed a way to get good looking .ps files out of Paraview. So after 
some initial reading I thought I would write a plugin, then I stumbled 
across using the python shell. Then I figured working with vtk objects 
directly through the shell might be the quickest way to get it done.

I might now look into writing the proxy xml definition as you suggested.

Once I follow the example that you pointed me to, does Paraview need to 
be recompiled once I put my new proxy xml definition in place and if so 
do I need to stick it in a specific place, such as the utilities.xml you 
pointed out? Or can my xml be sort of be loaded dynamically through 
Paraview's plugin manager as long as I build Paraview with shared libs on?

Thanks Again for Your Help,
Marcin


On 06/17/2010 03:03 PM, pat marion wrote:
> Hi,
>
> If you look at paraview's vtk/__init__.py, you'll see:
>
>     from libvtkRenderingPython import vtkCamera
>
> So that is why vtk.vtkGL2PSExporter() doesn't work- the complete 
> vtkRendering kit has not been imported.  You could do this:
>
> from libvtkRenderingPython import vtkGL2PSExporter
> exporter = vtkGL2PSExporter()
>
> or
>
> import libvtkRenderingPython as vtkrendering
> exporter = vtkrendering.vtkGL2PSExporter()
>
> If you are running this in the paraview gui, you can get the local 
> render window (vtkRenderWindow) by calling:
>
> view = GetActiveView().GetRenderWindow()
>
>
> You should understand that you are working directly with vtk objects 
> here.  The paraview way to handle this is to write a proxy xml 
> definition for the GL2PS exporter.  You can see an example by 
> searching for VRMLExporter in 
> Servers/ServerManager/Resources/utilities.xml   Then your script might 
> be something like:
>
> exporters = servermanager.createModule("exporters")
> exp = exporters.GL2PSExporter(FileName="/tmp/foo.ps <http://foo.ps>")
> exp.View = GetActiveView()
> exp.Write()
>
>
>
> Pat
>
>
> On Thu, Jun 17, 2010 at 2:26 PM, Marcin Sliwowski <ms275 at duke.edu 
> <mailto:ms275 at duke.edu>> wrote:
>
>     Hello Peter,
>
>     I was king of hoping you would reply, I actually saw that post and
>     your method of instantiating an object on vtkGL2PSExporter does
>     work after I do a from paraview.vtk import *
>
>     from paraview.vtk import *
>     exp = vtkInstantiator.CreateInstance("vtkGL2PSExporter")
>
>     I have tried exp.Write() but I get an error indicating:
>     vtkGL2PSExporter: No render windows provided
>
>     Then I did a couple of stabs in the dark with
>     vtk.vtkRenderWindow() to try an get a Render Window object but
>     with no success, I get attribute errors that I think are coming
>     from me mixing up namespaces. I am doing the import line above and
>     from vtk import *, I wonder if that is messing me up. I am going
>     to read up on Python to get to the bottom of this, but a quick
>     hint is also appreciated.
>
>     Thanks,
>     Marcin
>
>
>
>
>     On 06/17/2010 12:30 PM, Peter Brady wrote:
>>     Hello Marcin,
>>
>>     Your question may have already been answered here:
>>     http://markmail.org/message/zd2nwsztxl4xwbhm.
>>
>>     However I think the last time I tried this was in 3.4 so things
>>     may have changed.  In my experience the vtkPostScript writer does
>>     a better job although it has been quite a while since I've tried
>>     gl2ps.
>>
>>     Good luck,
>>     Peter.
>>
>>     On Thu, Jun 17, 2010 at 8:23 AM, Marcin Sliwowski <ms275 at duke.edu
>>     <mailto:ms275 at duke.edu>> wrote:
>>
>>         Hello,
>>
>>         I am trying to figure out how to save a visualization in
>>         Paraview directly to ps/eps format.
>>
>>         I have compiled from source paraview 3.6 with the
>>         configuration option VTK_USE_GL2PS set to ON.
>>
>>         There are many hits in the mailing list archives regarding
>>         trying to use vtkGL2PSExporter to achieve this but I couldn't
>>         find anything that I could make work.
>>
>>         I know that I can just use WriteImage("test.eps",
>>         Writer="vtkPostScriptWriter") in the python shell to get what
>>         I am asking for.
>>
>>         However, I wonder if GL2PS could provide a better looking eps
>>         file, and having spent a couple of hours on this, I would
>>         really like to get to the bottom of this.
>>
>>         I have looked at the vtkGL2PSExporter class reference at
>>         http://www.vtk.org/doc/nightly/html/classvtkGL2PSExporter.html and
>>         from there followed the vtkGL2PSExporter (Tests) link which
>>         provides examples of unit testing that is done on the class.
>>         One example is actually titled "test vector EPS output"
>>
>>         However, even after doing a: from paraview import vtk in the
>>         python shell, when I try to follow the test example and do
>>         exp = vtk.vtkGL2PSExporter() I get the following error:
>>
>>         AttributeError: 'module' object has no attribute
>>         'vtkGL2PSExporter'
>>
>>
>>         Can anyone shine any light on how to actually utilize the
>>         vtkGL2PSExporter in Paraview to export an .eps, my impression
>>         is that it has to be done in the Python Shell, and I am not
>>         very familiar with Python.
>>
>>         Thank You,
>>         Marcin Sliwowski
>>
>>         _______________________________________________
>>         Powered by www.kitware.com <http://www.kitware.com>
>>
>>         Visit other Kitware open-source projects at
>>         http://www.kitware.com/opensource/opensource.html
>>
>>         Please keep messages on-topic and check the ParaView Wiki at:
>>         http://paraview.org/Wiki/ParaView
>>
>>         Follow this link to subscribe/unsubscribe:
>>         http://www.paraview.org/mailman/listinfo/paraview
>>
>>
>
>
>     -- 
>     Marcin Sliwowski
>     Systems Programmer
>     Duke University - Pratt School of Engineering
>     Office: 919-660-8450
>
>
>     _______________________________________________
>     Powered by www.kitware.com <http://www.kitware.com>
>
>     Visit other Kitware open-source projects at
>     http://www.kitware.com/opensource/opensource.html
>
>     Please keep messages on-topic and check the ParaView Wiki at:
>     http://paraview.org/Wiki/ParaView
>
>     Follow this link to subscribe/unsubscribe:
>     http://www.paraview.org/mailman/listinfo/paraview
>
>


-- 
Marcin Sliwowski
Systems Programmer
Duke University - Pratt School of Engineering
Office: 919-660-8450

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100617/d36123e2/attachment-0001.htm>


More information about the ParaView mailing list