Displaying only first tier of child blocks in ExtractBlock-like filter plugin

I am trying to create filter via the VTKPythonAlgorithmBase class, and I want this filter to essentially be like the existing ExtractBlock filter, but only display the first level of child blocks in the multiblock data set, not the children of those children.

For example, below I’m showing the GUI input for an ExtractBlock filter on my dataset. The filter I want to design would only show “Solid”, and wouldn’t show “1_part1”, “2_part2”, etc.

image

For me, the difficulty has arisen in how I should set up the @smproperty decorator for this. My first attempt is below, and is basically an exact copy of ExtractBlock.

     @smproperty.xml("""
         <IntVectorProperty clean_command="CleanNames"
             command="AddName"
             name="BlockNames"
             number_of_elements_per_command="1"
             panel_visibility="default"
             repeat_command="1">
             <CompositeTreeDomain name="tree">
                 <RequiredProperties>
                     <Property function="Input" name="Input"/>
                 </RequiredProperties>
             </CompositeTreeDomain>
         </IntVectorProperty>
     """)
     def AddName(self, user_inp):
         self.user_indices.append(user_inp)

If I only wanted to show the first tier of child blocks, can it be done with the same input, and just a different Domain type or modification to the Domain? Or would I have to find a way to trim the input and continue using CompositeTreeDomain?

Hi Cailen,

If I understood correctly, you always need to display only the names from the first level of hierarchy. In this case, it is possible to simplify the task. You can try to use vtkDataArraySelection object, where you load names (“Solid”, …). It is supported directly by decorator in Python plugin:

# Ability for users to choose blocks in GUI from multi-block dataset    
    @smproperty.dataarrayselection(name="Blocks")
    def GetDataArraySelection(self):
        return self._get_array_selection()

, so you will be able to see it’s GUI similarly to this:

vtkDataArraySelection_GUI_example

and user will be able to check some blocks.

More details about plugin’s code for implementing vtkDataArraySelection you can find here: Custom Threshold filter with dropdown selection - #5 by pavel

Hope, this approach is suitable for you.

Best Regards,
Pavel

1 Like

@pavel

This is excellent! Thank you so much for the response. I haven’t had a chance to mess around with it yet, but from my quick readthrough I think it accomplishes exactly what I want.

I only wish I could have had this when I posted the original topic. I had to move forward with a lesser solution, and it has already become a part of several users’ workflows. I will have to wait until I next have time to try and implement this without upsetting existing workflows.

Thank you again so much for the response!