# Obtain information if proxy is visible

**URL:** https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346
**Category:** ParaView Support
**Created:** [August 1, 2019, 10:39pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346 "2019-08-01T22:39:35Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [August 1, 2019, 10:39pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/1 "2019-08-01T22:39:35Z")

</div>

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 *
paraview.simple._DisableFirstRenderCameraReset()

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?

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [August 1, 2019, 10:46pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/2 "2019-08-01T22:46:15Z")

</div>

> [@bastian](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [August 9, 2019, 12:28pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/3 "2019-08-09T12:28:25Z")

</div>

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:

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](https://discourse.paraview.org/uploads/short-url/8lRyaHswAxlFOypQos2Ty0E819t.pvsm) (189.6 KB)

 ![Screenshot%20from%202019-08-09%2014-10-14](https://discourse.paraview.org/uploads/default/original/2X/c/c324dd958e2f4ca001682e36289fadba5890c79c.png)

Running the following script: [run.py](https://discourse.paraview.org/uploads/short-url/ybWEvH0B93EuOw3qsjNMibgMy9q.py) (507 Bytes)

```auto
#!/usr/bin/env pvpython

from paraview.simple import *

paraview.simple._DisableFirstRenderCameraReset()

LoadState('state.pvsm')

for renderViewName in ['RenderView1', 'RenderView2']:
    renderView = FindViewOrCreate(renderViewName, viewtype='RenderView')
    SetActiveView(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:

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

```

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [September 25, 2019, 8:54pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/4 "2019-09-25T20:54:24Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [December 19, 2019, 11:08am UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/5 "2019-12-19T11:08:57Z")

</div>

The behavior is still present and it’s really annoying when working with multiple render views.

Currently, for every filter you add in one render view, you’ll have to go through all the other render views and manually make the filter visible and then invisible again.  
Otherwise, loading the session in pvbatch, these filters will be visible in the other render views.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [December 19, 2019, 2:34pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/6 "2019-12-19T14:34:52Z")

</div>

Have you encountered this issue, @wascott?

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [December 19, 2019, 4:56pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/7 "2019-12-19T16:56:01Z")

</div>

No, but I haven’t tried. I will run through these examples after our meeting.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [December 20, 2019, 6:55pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/8 "2019-12-20T18:55:18Z")

</div>

Man, this one was interesting. Definately down the rabbit hole for me.

- I had to hack the python slightly. I am sure my crude sollution is due to my not understanding dictionaries. I had to change the GetSources line to be:  
\*\* sources = GetSources()  
\*\* source = FindSource(‘FastUniformGrid1’)
- My users don’t use different layouts (I believe), mainly because I don’t teach them about layouts.
- My users _generally_ don’t use scripting that isn’t created with the trace recorder.
- My users have never complained about this issue.

My $0.02 is that this is a very rare bug with a workaround. Should be fixed, but probably low on the queue. @cory.quammen, you agree? I know how to replicate it now, want me to write it up?

@bastian This is one of the best bug reports I have seen. Thanks for the time writing it, and well done.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [December 20, 2019, 7:04pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/9 "2019-12-20T19:04:06Z")

</div>

> [@wascott](#):
>
> Should be fixed, but probably low on the queue. @cory.quammen, you agree? I know how to replicate it now, want me to write it up?

I agree, it should be cleaned up, but priority is low. If you could write it up @wascott, that would be great.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [December 20, 2019, 8:20pm UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/10 "2019-12-20T20:20:58Z")

</div>

[https://gitlab.kitware.com/paraview/paraview/issues/19552](https://gitlab.kitware.com/paraview/paraview/issues/19552)

---

<div class="post-metadata">

### Author: ![MatsievskiySV](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@MatsievskiySV](https://discourse.paraview.org/u/MatsievskiySV)
#### Post date: [August 18, 2021, 10:31am UTC](https://discourse.paraview.org/t/obtain-information-if-proxy-is-visible/2346/11 "2021-08-18T10:31:59Z")

</div>

I had the same problem. Maybe these will be helpful to someone.

- This line will list only visible sources without triggering initialization.

```python
[(n, s) for n, s in GetSources().items() if servermanager.GetRepresentation(s, v) is not None and GetDisplayProperties(s, view=v).Visibility==1]

```

- This one will initialize and hide uninitialized sources:

```python
[GetDisplayProperties(s, v).Visibility for s in GetSources().values()]

```

after which listing visible sources may be done without any problems

```python
[(n[0], s, GetDisplayProperties(s, v).Visibility==1) for n, s in GetSources().items()]

```
