Hi Ariel,

As a general rule, I would not advise scripting with the style that you
are employing, i.e. manipulating the pipeline as a tree. This pattern is
very useful if you are writting an application that control the full
state of the pipeline, and the lifecycle of the objects, but when writing
for an interactive scripting environment, where figures and objects come
and go, it give rise to the problems that you are encountering.

Specifically, the following line:

> poly_data_normals = engine.scenes[0].children[0].children[0]

is fragile, as it relies on the exact ordering of the pipeline tree. Let
me try and rewrite the code that you have sent us the way that I would
write it personally. I may get things wrong, as you haven't sent us a
fully executable snippet.

----------------------------------------------------------
from mayavi import mlab as maya

figure = maya.figure()

# Plot some stuff in the figure:
tm = maya.triangular_mesh(x_plot, y_plot, z_plot, faces, scalars=scalars,
                              colormap=cmap, figure=figure)

module_manager = tm.parent
module_manager.scalar_lut_manager.data_range = np.array([vmin, vmax])

----------------------------------------------------------

You probably got this code from the record feature. Unfortunately, the
code generator can only generate such code, that depends on the structure
of the pipeline, as it does not know the origin of the object. For
robustness it should be rewritten a bit

Note that if all that you want is to set the vmin and vmax of the
triangular mesh, you can achieve that by using the vmin and vmax keyword
arguments of triangular_mesh.

Hope this helps,

Gaël

On Fri, Nov 16, 2012 at 01:21:40PM -0800, Ariel Rokem wrote:
> My code looks something like this: 

> ----------------------------------------------------------
> from mayavi import mlab as maya
> import mayavi.tools as maya_tools
> EM = maya_tools.engine_manager.EngineManager()

> engine = EM.new_engine()
> figure = maya.figure(engine)

> # Plot some stuff in the figure:
> tm = maya.triangular_mesh(x_plot, y_plot, z_plot, faces, scalars=scalars,
>                               colormap=cmap, figure=figure)


> poly_data_normals = engine.scenes[0].children[0].children[0]
> module_manager = poly_data_normals.children[0]
> module_manager.scalar_lut_manager.data_range = np.array([vmin, vmax])

> ----------------------------------------------------------


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to