# how you use python script to hide a block selected

**URL:** https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874
**Category:** In Situ Support
**Tags:** python
**Created:** [September 15, 2023, 8:29pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874 "2023-09-15T20:29:51Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![ntian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@ntian](https://discourse.paraview.org/u/ntian)
#### Post date: [September 15, 2023, 8:29pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/1 "2023-09-15T20:29:51Z")

</div>

With the blocks created, could i use python script to hide a selected block.  
I am using the following code to find the block 0, and do not know how to hide it. Thank you for the help

active\_source = paraview.simple.GetActiveSource()

data = paraview.servermanager.Fetch(active\_source)

Solid\_block = data.GetBlock(0).GetBlock(0)

Solid\_block\_component = Solid\_block.GetBlock(0)

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [September 18, 2023, 9:41am UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/2 "2023-09-18T09:41:45Z")

</div>

Hi,

Visibility is controlled at the representation level (object returned by the `Show` method). For multiblock, you have `BlockSelectors` property to check which blocks should be visible.

Also note that `Fetch` is not recommended if you are connected to a remote server (specially with big datasets), as it transfer data over network. And in your case this is not needed.

Some doc about display (with python examples): [4. Displaying data — ParaView Documentation 5.11.0 documentation](https://docs.paraview.org/en/latest/UsersGuide/displayingData.html#)

Here is an example script:

```python
rep1 = Show(active_source)
info = active_source.GetDataInformation().DataInformation
        assembly = info.GetDataAssembly()
        if assembly != None:
            rep1.BlockSelectors = [assembly.GetNodePath(assembly.GetChild(0,0))]

```

---

<div class="post-metadata">

### Author: ![ntian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@ntian](https://discourse.paraview.org/u/ntian)
#### Post date: [September 18, 2023, 12:51pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/3 "2023-09-18T12:51:07Z")

</div>

> [@nicolas.vuaille](#):
>
> ```auto
> assembly = info.GetDataAssembly()
> if assembly != None:
> 
> ```

Thank you Nicolas for your kind help. I got the following message from the example script  
File “”, line 37, in   
AttributeError: ‘paraview.modules.vtkRemotingCore.vtkPVDataInformat’ object has no attribute ‘GetDataAssembly’

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [September 18, 2023, 1:09pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/4 "2023-09-18T13:09:41Z")

</div>

This was added in ParaView 5.10.  
Can you check which version of ParaView are you using ?

---

<div class="post-metadata">

### Author: ![ntian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@ntian](https://discourse.paraview.org/u/ntian)
#### Post date: [September 18, 2023, 1:13pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/5 "2023-09-18T13:13:20Z")

</div>

Mine version is 5.9. I will install the newer version. I saw a version 5.11

---

<div class="post-metadata">

### Author: ![ntian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@ntian](https://discourse.paraview.org/u/ntian)
#### Post date: [September 18, 2023, 7:06pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/6 "2023-09-18T19:06:35Z")

</div>

> [@nicolas.vuaille](#):
>
> ```auto
> info = active_source.GetDataInformation().DataInformation
> assembly = info.GetDataAssembly()
> 
> ```

Hi Nicolas, I installed 5.11. I can see the vtkMulitBlockDataSet in MultiBlock Inpsector, but assembly = info.GetDataAssembly(), here is None.  
Anything i did wrong?  
Thanks

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [September 20, 2023, 11:22am UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/7 "2023-09-20T11:22:12Z")

</div>

What is your current active source ? Which kind of data?

---

<div class="post-metadata">

### Author: ![ntian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@ntian](https://discourse.paraview.org/u/ntian)
#### Post date: [September 20, 2023, 12:47pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/8 "2023-09-20T12:47:41Z")

</div>

It is from xmdf reader

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [September 20, 2023, 12:57pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/9 "2023-09-20T12:57:03Z")

</div>

Well, I’m not sure to understand here …

You can try to manually hide block in the interface and use the python trace to record your actions:

- menu `Tools`, `Start Trace`
- menu `View`, `Multiblock Inspector`
- in the inspector, hide some blocks
- `Tools / Stop Trace`

This will show you the corresponding python script.

---

<div class="post-metadata">

### Author: ![ntian](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@ntian](https://discourse.paraview.org/u/ntian)
#### Post date: [September 20, 2023, 1:00pm UTC](https://discourse.paraview.org/t/how-you-use-python-script-to-hide-a-block-selected/12874/10 "2023-09-20T13:00:56Z")

</div>

Thank you for your kindly help, Nicolas. All the best
