Hello,
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
group_1cgns=[]
group_1cgnsDisplay=[]
for file in os.listdir(dir_path):
# check only text files
if file.endswith('.cgns'):
fileName.append(file)
numOfFile=int(fileName[-1].split('.')[0].split('Group_')[1])
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
regards