# Question on vtkParticleTracer Filter using vtkPythonAlgorithmBase

**URL:** https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537
**Category:** ParaView Support
**Tags:** python, vtk
**Created:** [April 28, 2025, 8:31am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537 "2025-04-28T08:31:28Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Oracle\_0](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/o/97f17d/32.png) [@Oracle\_0](https://discourse.paraview.org/u/Oracle_0)
#### Post date: [April 28, 2025, 8:31am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/1 "2025-04-28T08:31:28Z")

</div>

Hi, I have been trying to add vtkParticleTracer in external python script based on vtkPythonAlgorithmBase.

Paraview Version: 5.11.1

So far what I have understood is:

1. vtkParticleTracer requires two inputs: A dataset containing ‘velocity’ field and Seeds.
2. Time related information such as TIME\_STEPS, TIME\_RANGE, UPDATE\_TIME\_STEPS and DATA\_TIME\_STEPS must be present in both inputs.
3. Then Update() method of vtkParticleTracer() should move particles given in the ‘Seed’ object.

What I have done:

1. I have a dataset from which I am manually calculating ‘velocity’ field, copying old dataset onto a vtkPolyData object named ‘output\_velocity\_field’ using ShallowCopy() and then appending ‘velocity’ field to this vtkPolyData object. I am doing same for Seeds with name ‘output\_seeds’.
2. I also set ‘velocity’ field: tracer.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD\_ASSOCIATION\_POINTS, “velocity”).
3. Now, when I ran Update() of vtkParticleTracer(), it gives error: Input Data does not have TIME\_STEPS.
4. So, I manually copy all four above mentioned time related fields to both: using ‘Set’ method which looks like Set(SDSP.TIME\_STEPS(), time\_steps, len(time\_steps)). where SDSP = vtkStreamingDemandDrivenPipeline.
5. I connect input to vtkParticleTracer(): tracer.SetInputData(0, output\_velocity\_field.VTKObject) and tracer.SetInputData(1, output\_seeds) where tracer = vtkParticleTracer(). Particles were not moving.
6. Then after copying, I wrap both of these object in TrivialProducer() objects and also again copy all four time related field onto both producers.
7. Then, I use different method to set input to vtkParticleTracer: self.particle\_tracer.SetInputConnection(0, velocity\_field\_producer.GetOutputPort()) and self.particle\_tracer.SetInputConnection(1, self.seed\_producer.GetOutputPort()).
8. Particles were still not moving.
9. I compared results by manually adding ParticleTracer from Paraview’s Filter menu with the external script and I found that ParticleAge is NOT incrementing at all when I use script but increments when I use filter from Paraview’s menu.
10. I print the output of ‘GetIntegrator()’ method of vtkParticleTracer():  
vtkRungeKutta4 (0x2745fe10)  
Debug: Off  
Modified Time: 8761737  
Reference Count: 2  
Registered Events: (none)  
Function set : 0  
Function values : 0  
Function derivatives: 0  
Initialized: No  
Runge-Kutta 4 function derivatives: 0 0 0

What could be issue here? I want an external filter which applies Particle Tracer filter and then Temporal Particles to Pathlines filter using vtkPythonAlgorithmBase. Both of these filter works perfectly when using Paraview within GUI from filters menu. But I want to apply them using external script.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 28, 2025, 8:35am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/2 "2025-04-28T08:35:09Z")

</div>

Please share your data.

---

<div class="post-metadata">

### Author: ![Oracle\_0](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/o/97f17d/32.png) [@Oracle\_0](https://discourse.paraview.org/u/Oracle_0)
#### Post date: [April 28, 2025, 9:00am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/3 "2025-04-28T09:00:59Z")

</div>

Sure.

Data: [DataSet](https://indianinstituteofscience-my.sharepoint.com/:f:/g/personal/vijayn_iisc_ac_in/Ehc8X74KBl1Au85q88AlBg8BcrOMEyW3FypTccIsjwfFrg?e=BzhyJ8)

Either of the NetCDF file works.

Path Lines Script: [https://pastebin.com/iP6TiURG](https://pastebin.com/iP6TiURG)

I have also uploaded picture of what I want using script and I already got it using Filter from Paraview GUI but I want using external script.

 ![path_lines](https://discourse.paraview.org/uploads/default/original/3X/7/c/7c39560a20abc91e8064b7e8bbbf3a0764efaade.jpeg)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 28, 2025, 9:45am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/4 "2025-04-28T09:45:19Z")

</div>

> [@Oracle\_0](#):
>
> it using Filter from Paraview GUI but I want using external script.

What do you mean by external script ? You mention vtkPythonAlgorithmBase, are you writing a python plugin ?

---

<div class="post-metadata">

### Author: ![Oracle\_0](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/o/97f17d/32.png) [@Oracle\_0](https://discourse.paraview.org/u/Oracle_0)
#### Post date: [April 28, 2025, 10:05am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/5 "2025-04-28T10:05:21Z")

</div>

Yes. I am writing a plugin which I can load from Tools → Manage Plugins menu and then select dataset in the pipeline and apply over it.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 28, 2025, 10:08am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/6 "2025-04-28T10:08:54Z")

</div>

Writing a temporal filter in a python plugin can be really chalenging. If your objective is to simplify the process and reduce the number of clicks, I’d suggest using state files, python macros or default settings instead.

If you want to keep making this work as a python plugin, then please share your full code.

---

<div class="post-metadata">

### Author: ![Oracle\_0](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/o/97f17d/32.png) [@Oracle\_0](https://discourse.paraview.org/u/Oracle_0)
#### Post date: [April 28, 2025, 10:30am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/7 "2025-04-28T10:30:36Z")

</div>

Oh, I see. If possible, I want make a python plugin for this. I did same for vtkStreamTracer and it works perfectly, however it does not involve temporal data I guess.

Here’s the code what I am currently using: [New\_Pathlines.py](https://bitbucket.org/ocean_000/ocean/src/main/filters/New_Pathlines.py)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 28, 2025, 11:37am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/8 "2025-04-28T11:37:30Z")

</div>

```auto
    def RequestInformation(self, request, inInfo, outInfo):
        return 1
    
    def RequestUpdateExtent(self, request, inInfo, outInfo):
        return 1

```

You definitely need to implement these, I dont have an example on hand for temporal implement though.

---

<div class="post-metadata">

### Author: ![Oracle\_0](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/o/97f17d/32.png) [@Oracle\_0](https://discourse.paraview.org/u/Oracle_0)
#### Post date: [April 29, 2025, 3:08am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/9 "2025-04-29T03:08:55Z")

</div>

So, right now I am manually coping TIME\_STEPS, TIME\_RANGE, UPDATE\_TIME\_STEP to the input from dataset.

I believe these functions does that automatically. I tried earlier using these functions before manually copying everything. vtkParticleTracer() still complained Input not having TIME\_STEPS.

---

<div class="post-metadata">

### Author: ![Oracle\_0](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/o/97f17d/32.png) [@Oracle\_0](https://discourse.paraview.org/u/Oracle_0)
#### Post date: [April 29, 2025, 8:22am UTC](https://discourse.paraview.org/t/question-on-vtkparticletracer-filter-using-vtkpythonalgorithmbase/16537/10 "2025-04-29T08:22:29Z")

</div>

Well, I have decided to use Macro. It works perfectly.
