CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [General] Listing the inputs of a grouped dataset with a programmable python filter in Paraview (https://www.cfd-online.com/Forums/paraview/214354-listing-inputs-grouped-dataset-programmable-python-filter-paraview.html)

NadineHS January 28, 2019 19:16

Listing the inputs of a grouped dataset with a programmable python filter in Paraview
 
Is there a way to list the names of the inputs in a Group Dataset filter with a programmable python filter?

I have a lot of point sources that I have grouped in paraview. Then I applied "Merge Blocks" and then the Programmable Python filter.

This is the code so far in the programmable filter:

Code:

pdi = self.GetInput()

npts = pdi.GetNumberOfPoints()
print npts

for i in range(0, npts):
        coord1 = pdi.GetPoint(i)
        print coord1

This code prints the coordinates of each point source. I would also like to print the names of the point sources, something like this:
PointSource1
PointSource5 etc.

I would appreciate your help.

tkarabela February 7, 2019 18:51

It is possible to do it from the Python console in Paraview:

Code:

group_datasets = GetActiveSource()
for input_obj in group_datasets.Input:
    for (name, _), obj in GetSources().items():
        if obj == input_obj:
            print name
            break

However, this refers to the Paraview proxies, not the underlying VTK objects which you get in a programmable filter. If you just need to see which points come from different sources, you could use the programmable filter right after the Group Dataset filter and iterate over the vtkMultiBlockDataSet yourself and add a point array to each block containing index of the block. Perhaps not the best solution, but it could work :)

NadineHS February 9, 2019 16:41

Thanks tkarabela!

haniamalik7244 December 12, 2021 14:54

I am trying to setup best tennis stringing machines but prefix is now working properly.


All times are GMT -4. The time now is 04:08.