Closed ClarkDinh closed 3 years ago
The stl format has no support for color at all. It only consists of a list of triangles and a list of combinations of those triangles to build the structures.
The plot appears to be basing the color on the z height.
Thanks for your feedback.
The stl format has no support for color at all. It only consists of a list of triangles and a list of combinations of those triangles to build the structures.
Binary STL does have limited (RGB) color support, though it is not standardized.
That's an interesting new addition. If there's enough interest I can add it to the library but it looks like it would break most STL software
it would break most STL software
No, it uses the 2 attr
bytes which are normally unused anyway — you are already reading and writing them, too :
https://github.com/WoLpH/numpy-stl/blob/6f2b6f831f3e372878fb2d19bbfe6c029a2001aa/stl/base.py#L175
I read this and assumed it could be problematic:
in the standard format, this should be zero because most software does not understand anything else.
But you're right, many libraries probably won't care about it.
Dear Rick van Hattem, I would like to ask you how can I save the stl file with color. I have vertices and faces. I save the mesh in the same way as your description: ---Create the mesh cube = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype)) for i, f in enumerate(faces): for j in range(3): cube.vectors[i][j] = vertices[f[j],:] --- Write the mesh to file "cube.stl" cube.save('cube.stl')
However, it just saves the grey stl file as the following attachment.
How can I save the stl with color as produced by plot_trisurf.
Thank you very much for your support.