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

pat marion pat.marion at kitware.com
Thu Jun 17 15:03:04 EDT 2010


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")
exp.View = GetActiveView()
exp.Write()



Pat


On Thu, Jun 17, 2010 at 2:26 PM, Marcin Sliwowski <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> 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
>>
>> 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
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100617/40c2a78c/attachment.htm>


More information about the ParaView mailing list