get all existing sources on beginning when doing trace in a existing setup

hello,

context: While scripting in paraview, I imagine i am not the only one, if i have a open paraview instance and I want to check how to modify a specific filter or how to call it to create it in paraview. I do, tools/start trace/show incremental trace (normally skip rendering also)

issue/situation for this improvement to take place: once i turn on the trace I click on a filter that was not currently selected, that i want to change or want to apply a new filter over. this will open the trace script window and show something like this:

# trace generated using paraview version 6.0.1
#import paraview
#paraview.compatibility.major = 6
#paraview.compatibility.minor = 0

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# find source
box3 = FindSource('Box3')

# set active source
SetActiveSource(box3)

and if after i apply the desired filter for example Threshold() the trace script will add the following lines:

# create a new 'Threshold'
threshold1 = Threshold(registrationName='Threshold1', Input=box3)

# find source
box1 = FindSource('Box1')

# find source
box2 = FindSource('Box2')

# find source
box4 = FindSource('Box4')

UpdatePipeline(time=0.0, proxy=threshold1)

the issue is, when we have a quite large already constructed pipeline, as paraview will add the FindSource(‘…’) the threshold part (what we want to know) will be lost. even if we are using the filter over the Box3 the others will be get after, even if we do a source filter such as another box.

proposal: My proposal is simply that all the FindSource are placed together in the beigning, that when the script does the box3 = FindSource('Box3') it also does all the others. this way at the end of the script when we apply the threshold we will get simply the lines:

# create a new 'Threshold'
threshold1 = Threshold(registrationName='Threshold1', Input=box3)
UpdatePipeline(time=0.0, proxy=threshold1)

this was a dummy example with 3 boxes, with a existing complete tree of pipeline the ‘interest’ part is completly lost as the FindSource(‘’) and others… currently to get around this i create a dummy source like a sphere, and then I apply what I want to see on the trace, so the sphere filter gets lost, all the FindSource are writed and then everything i do is placed correctly at the end of the script.

While I understand your use case, I have some cons:

  • depending on the further actions, this may lead to a lot of findxxx lines that will be unused by the following code
  • the intent of the trace is to track every GUI action: making a source active may be the thing you want to learn, so the FindSource then SetActiveSource calls should appears at this time I think

While I agree that the function is to trace what one does. The current behavior it affects this “following” and when it adds the extra findsource the user will loose the track of what she/he is doing. Furthermore this lines will still appear anyway, or they appear when one clicks on one source or it appears "randomly"after one applies a source (that is not related to the new findsources).
If one have 5 sphere sources already applied and one begins the trace, select one (sphere3 ) it will find source for sphere3 but after applying a filter to sphere3 (or create a new source) only after that the trace will findsource the other spheres (which are not necessarily used in the new step applied by the user.)

as discussed i created the issue :slight_smile: https://gitlab.kitware.com/paraview/paraview/-/work_items/23412