Get 'Base' property of CGNS format without previous knowledge

I wanted to create a script which imported all CGNS files inside a folder, for this I created an script using the trace function and then modify it.
this works correctly, with one single issue, there is this Base property that in the trace file is defined directly, which i thought was simply a name that we can modify but it is not the case, it looks like the value comes from the CGNS file itself.
and my issue is that if i do not enter the correct value (string) paraview will show two base for that file, one with the correct value and another one with the value that I put in the script, and it will only active the one with the value I entered which is empty (and the one with the correct name which is the data, will not be active). for the moment I solved this issue as an strike of luck as I knew the correct value but I would like to understand how to do this in case that i dont have this extra information.
here is how I code it (sorry for the quality of the script i made it in 5 min yesterday):

import os
# folder path
dir_path = r'C:\\Users\\USER\\Desktop\\testCGNS\\'
# list to store files
fileName = []
# Iterate directory
for file in os.listdir(dir_path):
    # check only text files
    if file.endswith('.cgns'):
        group_1cgns.append(CGNSSeriesReader(registrationName='Group_'+str(numOfFile), FileNames=[dir_path+fileName[-1]]))
        group_1cgns[-1].Bases = ['solid '+str(numOfFile)+' [BLOCK]']
        # get active view
        renderView1 = GetActiveViewOrCreate('RenderView')

the script is longuer here is the complete code as I mentinoned this works correcly because I know that group_1cgns[-1].Bases = ['solid '+str(numOfFile)+' [BLOCK]'] would ‘look’ like that, but if I put for example group_1cgns[-1].Bases = ['block '+str(numOfFile)] when runned, paraview will show for each cgns file two bases with the one with the wrong base active and the other one no:
I thought about getting from the cgns file itself by openning the file as text but it is in binary format

Hello @otaolafr,

I find it strange that you need the line

group_1cgns[-1].Bases = [...]

since the CGNS reader already reads the files and creates the bases itself.
Could you try removing that line and see what happens?

1 Like

Hello Tiffany,
Thanks a lot! It worked perfectly.
Have a nice day

1 Like