Hello,
I would like to create a ParaView python script to compute volumes of specific sub regions of the mesh (obtained via Threshold), and then print the volume to a file.
Currently, I am able to use Threshold, followed by Integrate Variables to generate a spreadsheet, which can be exported using the ExportView function. However, this exports the entire spreadsheet generated by Integrate Variables, whereas I would like to only print out the ‘Volume’.
I attempted to use spreadSheetView1.GetCellData().GetArray(‘Volume’).GetValue(0), but it appears that the spreadSheetView class does not have those functions.
Any help in extracting the Volume directly data from the spreadsheet object without resorting to bash commands would be appreciated.
Thanks Mathieu. I attempted to use the servermanager to extract the desired data, using the following code:
%%% Create the integrate variables object
integrateVariables1 = IntegrateVariables(Input=threshold1)
%%% Create a server manager object
iv_data = paraview.servermanager.Fetch(integrateVariables1)
%%% Use the server manager object to extract the requisite data
U1.append(iv_data.GetCellData().GetArray('Volume').GetValue(0))
Traceback (most recent call last):
File "script_5.py", line 172, in <module>
U1.append(iv_data.GetCellData().GetArray('Volume').GetValue(0))
AttributeError: 'NoneType' object has no attribute 'GetValue'
My apologies. The array ‘Volume’ did not exist in the integrateVariables1 object. In fact, it appears that it belongs to the spreadSheet object. A combination of passArrays and serverManager Fetch acting on the spreadSheet worked for me.
# create a new 'Integrate Variables'
integrateVariables1 = IntegrateVariables(Input=threshold1)
# Create a new 'SpreadSheet View'
spreadSheetView1 = CreateView('SpreadSheetView')
# create a new 'Pass Arrays'
passArrays1 = PassArrays(Input=integrateVariables1)
passArrays1.CellDataArrays = ['Volume', 'temperature(K)']
# Properties modified on passArrays1
passArrays1.CellDataArrays = ['Volume']
# update the view to ensure updated data information
spreadSheetView1.Update()
ss_data = paraview.servermanager.Fetch(passArrays1)
U1.append(ss_data.GetCellData().GetArray('Volume').GetValue(0))