Extract Block python code

I have a problem trying to write the python code for the extract block selector part.
In my company we simulate with a CFD that give us a case.foam nomenclature that we can not predict. We know the baseline of B…_TES…_B…_TES…, but we can not predict the numbers on it (see the image).
In my code i want to do an extract block of only the parts we can not predict, in resume, i want to select with my code the whole boundary block, removing the Boundary box (see the image.)


When i write the code, the way of selecting the properties of the extract block is:

image

If i unselect the boundary boxes, the code is:

So my code doesnt work for my iterations, because in each one, the nomenclature, is different.
There is any way of selecting the block ‘boundary’, and then unselecting the boundary box?
How you will solve my problem?
Thank for your help.

Which version of ParaView are you using ?

5.11.0

You technically cannot unselect a block however you can just not select anything like this:

extractBlock2.Selectors = []

The best I could do for now is:

First select the boundaries, and

extractBlock1.Selectors = ['/Root/boundary']
extractBlock1Display = GetDisplayProperties(extractBlock1, view=renderView1)
renderView1.Update()

Then I managed to get the loaded block names like this:

blocks = []
i=0
while True:
  name = extractBlock1.GetDataInformation().DataInformation.GetBlockName(i)
  if name =='': break
  blocks.append(name)
  i+=1

Then you can do some python list operations to remove vtkMultiBlockDataSet and boundary, and any boundaries you don’t want to select.

Then add the boundary prefix back in and set your Selector using the list

blocks = ['/Root/boundary/' + block  for block in blocks]
extractBlock1.Selectors = blocks