[Paraview] calculator filter via python

Peter Brady petertbrady at gmail.com
Fri Jan 2 12:04:05 EST 2009


Hello all,

I am trying to do calculations based on coordinate locations.  In the
GUI I can simply select 'coordsX', 'coordsY', 'coordsZ'.  From python
things seem to be more complicated.  I've tried the snippet below with
several variations and keep getting errors

calc_radius = servermanager.filters.Calculator(Input=g_cont)
calc_radius.AddCoordinateScalarVariable('coordsX', 0)
calc_radius.Function =
'sqrt((coordsX-center[i][0])^2+(coordsY-center[i][1])^2+(coordsZ-center[i][2])^2)'
calc_radius.UpdatePipeline()

I've also tried
calc_radius.AddCoordinateScalarVariable('coordsX')
but I get the error:
     calc_radius.AddCoordinateScalarVariable('coordsX')
TypeError: __call__() takes exactly 1 argument (2 given)

I've also tried using the scalar array name ('G' in this case) in
place of coordsX but have met the same error message.

What is the correct way of doing this?

Also, I've tried using the PV-Dump.py script that was suggested to me
previously but am met with the error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "<string>", line 33, in allToPython
  File "<string>", line 48, in proxiesToPython
  File "<string>", line 149, in __orderProxies
AttributeError: 'NoneType' object has no attribute 'groups'

The offending lines are:
def __orderProxies( proxies ):
    """Returns an array, where each entry contains the names of the proxies that
    depend on the previous array entry."""
    patternName   = re.compile(' *XMLName: *(.*)')
    patternValues = re.compile(' *Values: *(.*)')
    patternHex    = re.compile('^0x[0-9a-f]+$')
    pmanager      = servermanager.ProxyManager()

    dependencies  = {}                                        # COLLECT DEPS
    for group in proxies:                                     # For each proxy
      for name in proxies[group]:
        dependencies[group+':'+name] = {}                     # Init its depend.
        proxy = proxies[group][name]

        for prop in proxy:
148          match     = patternName.search( str(prop) )
149          propName  = match.groups()[0]

I was hoping that this script would be very helpful.  Anyone else have
similar problems?

Thanks in advance for your help,
Peter.


More information about the ParaView mailing list