[Paraview] Determining the ParaView pipeline via Python

Bill Sherman shermanw at indiana.edu
Wed Jul 16 23:58:51 EDT 2014


Andy, Scott,

Thank you for your responses!


Comments embedded:

On 07/16/2014 05:34 PM, Scott Wittenburg wrote:
>
>
>
> On Wed, Jul 16, 2014 at 3:07 PM, Andy Bauer <andy.bauer at kitware.com
> <mailto:andy.bauer at kitware.com>> wrote:
>
>     Hi Bill,
>
>     A couple of hopefully helpful hints:
>
>         * Maybe using a filter's Input object is enough to get the
>           pipeline connections you want (i.e. aa = bb.Input). This
>           though assumes you're working from the sink in the pipeline as
>           opposed to a source.
>
>
> I have recently added something like this to the server side protocols
> for ParaViewWeb, though it's not yet in master. Effectively, it just
> does what you recommended, Andy, but doesn't require starting at the
> sink, and is a complete example. Here's how I got the pipeline connections:
>
> proxies = servermanager.ProxyManager().GetProxiesInGroup("sources")
> proxyList = []
> for key in proxies:
> listElt = {}
> listElt['name'] = key[0]
> listElt['id'] = key[1]
> proxy = proxies[key]
> parentId = '0'
> if hasattr(proxy, 'Input'):
> parentId = proxy.Input.GetGlobalIDAsString()
> listElt['parent'] = parentId
> proxyList.append(listElt)
>
> After this code finishes, proxyList contains all the sources and filters
> in the pipeline and identifies each one's Input proxy id with the key
> 'parent'. The actual source (reader or whatever has no Input), has
> 'parent': '0'. Perhaps modifying this code so it builds a dictionary
> (mapping each proxy id to the appropriate listElt object) instead of a
> list, and then making a note of the proxy which does not have an Input
> property when it is encountered, this would allow Bill to efficiently
> build the ascii map he is looking for?

Yes, very good.  I can definitely work from that to create an ASCII tree
representation.  Thanks for the code.

My initial thought was that: yes, I could work from the sinks on up,
but at some point I have to determine which nodes are the sinks (leaves).
Using the node "0" as the root node, I can follow the branches easily
enough.

> Cheers,
> Scott
>
>         * As for getting the available arrays for a filter, you can do
>           something like:
>
>     for da in range(aa.PointData.NumberOfArrays):
>     bb.PointData.GetArray(da)

Good -- though I presume you mean "aa.PointData.GetArray(da)" on
the last line.

>         * There was work on only writing out Python scripts with
>           non-default values which made the scripts much shorter.
>           Somewhere there was an option to specify whether to write out
>           all values of the objects for trace and python state or just
>           the non-defaults but I can't find it now. It looks like what
>           you have already works but just wanted to mention that.

Yes, good to be aware of I guess.  I suppose as a means of communicating
values to future versions of ParaView, there's always the chance that the
default value may have changed between ParaView versions, and so saving
all the values protects against that.

When trying to evaluate my state files though, I often just want to know
what I changed -- for example if somehow my state is broken/corrupted, and
so I want to start from scratch, I at least want to know what values I'd
gone through and modified.

>     Does this answer your questions?

Yes, thank you both.

The one thing I haven't figured out yet though is how to find out other
objects that got created -- for example a sphere object created to be
the Glyph representation.  The XML of the .pvsm file suggests that it
gets added to the "sources" Proxy group, but it's not listed when
queried.  And I went through all the Proxy groups I could find names
for.

In the meantime, I can just have some special-case code that knows
that Glyph objects have a "hidden" object that they point to.

>     Regards,
>
>     Andy

	Thanks again,
	Bill


>     On Wed, Jul 16, 2014 at 12:51 AM, Bill Sherman <shermanw at indiana.edu
>     <mailto:shermanw at indiana.edu>> wrote:
>
>         Community,
>
>         I've been creating some simple python scripts that help me see a
>         simple representation of the state of ParaView.
>
>         One thing I wanted was to be able to see what changes had been
>         made such that a value was no longer the default. Then, I'm going
>         to print this out at the beginning of my batch animation jobs, which
>         will then go into the log file generated by the queuing system.
>
>         So here is my function to do that for an object:
>
>         ----------
>         def altered(object):
>         if (object == None):
>         return
>         dup = object.__class__()
>         for prop in dup.ListProperties():
>         if (hasattr(object.GetProperty(__prop), 'GetData')):
>         if (dup.GetProperty(prop).__GetData() !=
>         object.GetProperty(prop).__GetData()):
>         print prop + ": " + str(object.GetProperty(prop))[__:80] + " ["
>         + str(dup.GetProperty(prop)) + "]"
>         del(dup)
>         del(prop)
>         ----------
>
>         And then I can loop over all the sources to get a handy list:
>
>         ----------
>         for src in GetSources():
>         srcp = FindSource(src[0])
>         print "********************"
>         print " " + src[0] + " -- " + srcp.GetXMLLabel()
>         altered(srcp)
>         print " ---------------"
>         print " Representation:"
>         altered(GetDisplayProperties(__srcp))
>         ----------
>
>         So the main missing feature for me is trying to show how the sources
>         are linked together -- basically recreating the pipeline display,
>         except as ASCII text. But I haven't yet figured out how to
>         programmatically determine which "sources" are connected to which.
>
>
>         The other thing I'd like to be able to do is report what other
>         field data is available from a file reader -- I can see by looking
>         in the .pvsm file that that data was saved, so I hope it might
>         be somehow available via the Python interface.
>
>
>
>         So here's some sample output from a state file I'm experimenting
>         with:
>
>         ********************

[removed -- see original post]
>
>         ------------------------------__------------------------------__--------------
>
>
>         Thanks for any advice. I'll report back when I figure out a
>         script that
>         does something more complete.
>
>         Bill
>
>         --
>         Bill Sherman
>         Sr. Technology Advisor
>         Advanced Visualization Lab
>         Pervasive Technology Inst
>         Indiana University
>


More information about the ParaView mailing list