mayavi: reload data from vtk data source

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mayavi: reload data from vtk data source

Robert Cimrman
Hi!

I have a VTK unstructured grid source obtained by:

source = mlab.pipeline.open(filename)

and a pipeline that renders the data.

If I change the source.base_file_name trait to another file name (with same
data sets, but different values), the scene updates correctly. But how do I
force reload of the file, when only the contents of the file changes, not the
file name? I have tried source.update() without success (Mayavi 4.0.0) and
googling did not help either.

The only (stupid) way I found that does what I want:

source.base_file_name = 'aa' # file does not exist, throws error message
source.base_file_name = filename

Thanks!
r.
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: mayavi: reload data from vtk data source

Robert Cimrman
On 03/25/2013 11:22 AM, Robert Cimrman wrote:

> Hi!
>
> I have a VTK unstructured grid source obtained by:
>
> source = mlab.pipeline.open(filename)
>
> and a pipeline that renders the data.
>
> If I change the source.base_file_name trait to another file name (with same
> data sets, but different values), the scene updates correctly. But how do I
> force reload of the file, when only the contents of the file changes, not the
> file name? I have tried source.update() without success (Mayavi 4.0.0) and
> googling did not help either.
>
> The only (stupid) way I found that does what I want:
>
> source.base_file_name = 'aa' # file does not exist, throws error message
> source.base_file_name = filename

Now I have googled better and found a working solution:

source.base_file_name = filename
# Force re-read.
source.reader.modified()
source.update()
# Propagate changes in the pipeline.
source.data_changed = True

Problem solved :)
r.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev