iterate through clips; No Error message for non existing sources on Mac

Hey everybody,

I’d like to do some operations on all clips in my states. Their number varies between the different states.
On Windows I address the Clips like this:

i = 1
while 1:
    clipNEW = FindSource("Clip"+str(i))
    if clipNEW is None:
    i += 1

Unfortunately on Mac this doesn’t work because you don’t get an error message when trying to find a Source that doesn’t exist. Instead nothing happens.

How could I do this elsewise?

You can get a dict of all sources using GetSources(). To get a list of all Clip filters:

[s for s in GetSources().values() if s.GetXMLName() == 'Clip']
1 Like

How would I do this in case of IntegrateVariables Filters?
replacing ‘Clip’ by ‘IntegrateVariables’ didn’t work

The “Integrate Variables” filters have IntegrateAttributes as name. It is probably easier to use the label (which are displayed in the paraview GUI) instead:

[s for s in GetSources().values() if s.GetXMLLabel() == 'Integrate Variables']
1 Like

Thank you @lhofmann
Now I have one last problem:
If I use

the order of the filters seems random. What I would need is all values in exactly that order how they are displayed in the Pipeline. How can I achieve that?

If you consistently use .sort() at all steps, it should work. For example:

[s for s in GetSources().values if s.GetXMLLabel() == 'Integrate Variables'].sort()

This will sort in place.

1 Like