how you use python script to hide a block selected

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)

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

Here is an example script:

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

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’

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

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

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

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

It is from xmdf reader

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.

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