You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating to Mayavi 4.4.3 and VTK 6.3 using Python 2.7.10 on OSX 10.10, I've noticed that coloring triangular meshes by polygon face (as in examples here or here) no longer seems to work. Any attempt to pass a cell_scalars name to set_active_attribute now produces an error of the form:
Traceback (most recent call last):
File "GUItestbed.py", line 35, in <module>
mesh = mlab.pipeline.set_active_attribute(wire_mesh, cell_scalars='Cell data')
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi/tools/pipe_base.py", line 38, in the_function
factory = factory_class(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi/tools/pipe_base.py", line 163, in __init__
self.set(**traits)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi/tools/pipe_base.py", line 180, in set
self._anytrait_changed(trait, value)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi/tools/pipe_base.py", line 198, in _anytrait_changed
setattr(obj, components[-1], value)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi/core/trait_defs.py", line 107, in set_value
value )
traits.trait_errors.TraitError: The 'cell_scalars_name' trait of a SetActiveAttribute instance must be one of [''], but a value of 'Cell data' <type 'str'> was specified.
Is this a bug, or is there now a different way to go about assigning colors using cell data? This method definitely worked in older versions of Mayavi.
Thanks!
Julia
The text was updated successfully, but these errors were encountered:
I found the solution to this problem, it has to do with newer versions of Mayavi and/or VTK updating mlab source datasets slightly differently than older versions. I noticed a change between the current Github atomic orbital example and the version on the Mayavi site. A similar change to mlab dataset updates makes coloring triangulated meshes by polygon using set_active_attribute functional again. Below I'm including a version of the first script linked above in a form that now works with Mayavi 4.4.3 and VTK 6.3.0.
import numpy as np
from mayavi import mlab
# Create cone
n = 8
t = np.linspace(-np.pi, np.pi, n)
z = np.exp(1j*t)
x = z.real.copy()
y = z.imag.copy()
z = np.zeros_like(x)
triangles = [(0, i, i+1) for i in range(n)]
x = np.r_[0, x]
y = np.r_[0, y]
z = np.r_[1, z]
t = np.r_[0, t]
# These are the scalar values for each triangle
f = np.mean(t[np.array(triangles)], axis=1)
# Plot it
mesh = mlab.triangular_mesh(x, y, z, triangles,
representation='wireframe',
opacity=0)
mesh.mlab_source.dataset.cell_data.scalars = f
mesh.mlab_source.dataset.cell_data.scalars.name = 'Cell data'
mesh.mlab_source.update()
mesh2 = mlab.pipeline.set_active_attribute(mesh,
cell_scalars='Cell data')
mlab.pipeline.surface(mesh2)
mlab.show()
Hello,
After updating to Mayavi 4.4.3 and VTK 6.3 using Python 2.7.10 on OSX 10.10, I've noticed that coloring triangular meshes by polygon face (as in examples here or here) no longer seems to work. Any attempt to pass a cell_scalars name to set_active_attribute now produces an error of the form:
Is this a bug, or is there now a different way to go about assigning colors using cell data? This method definitely worked in older versions of Mayavi.
Thanks!
Julia
The text was updated successfully, but these errors were encountered: