Obtain information if proxy is visible

Can anyone tell me how I can have my paraview batch script find out if an object is visible or not?

Here is a small example:

from paraview.simple import *

renderView1 = GetActiveViewOrCreate('RenderView')
source = FastUniformGrid()
display = Show(source, renderView1) 

I can Hide the source's display with

Hide(source, renderView1)

but where is the objects display status actually stored?

It is stored in the representation associated with the source. The representation controls how the source is displayed in ParaView, and it includes a Visibility property.

You can use display.Visibility to check whether the representation associated with source is visibile.

I had tried that, but it didn’t quite work reliably.

I think that there is a bug and here is how to reproduce it:

  1. Set up a renderView (RenderView1) with some hidden object in the pipeline

  2. Create a second renderView (RenderView2). By default, all objects are hidden.

  3. Execute the following lines and observe how GetDisplayProperties makes the hidden object visible:

    renderView = FindViewOrCreate('RenderView2', viewtype='RenderView')
    name, source = GetSources().items()[0]
    display = GetDisplayProperties(source, view=renderView)

I believe that there is a bug in the initialization of existing objects when creating a new renderView.
Manually switching the visibility of all objects from hidden to visible and back to hidden again after creating a new renderView is a workaround.

Here is a MWE: state.pvsm (189.6 KB)

Running the following script: run.py (507 Bytes)

#!/usr/bin/env pvpython

from paraview.simple import *



for renderViewName in ['RenderView1', 'RenderView2']:
    renderView = FindViewOrCreate(renderViewName, viewtype='RenderView')
    name, source = GetSources().items()[0]
    display = GetDisplayProperties(source, view=renderView) # this makes the object visible!
    print('{} : display.Visibility={}'.format(renderViewName, display.Visibility))

produces this output:

RenderView1 : display.Visibility=0
RenderView2 : display.Visibility=1

Okay, this is a little subtle, and has to do with representations being lazily created.

After you load your state file, the representation in RenderView1 is created, exists, and is not visible. There is no representation created for the FastUniformGrid1 object in RenderView2. When your script processes RenderView2, it invokes GetDisplayProperties() which will create a representation for FastUniformGrid1 (since it does not exist for RenderView2) and shows the representation. Hence, the visibility is on in RenderView2, even though it is off in the first renderview.

The behavior arises because the mechanism for creating a representation is to call Show() (realy ts equivalent deeper in the ParaView libraries). We could potentially separate the representation creation from showing it and call the creation function if needed in GetDisplayProperties(). There may be some technical difficulties doing that that I am not aware of, but it’s a possibility.