Search code examples
matlabprinting3d

Matlab patch - 3D printing format with color


Has anyone had experience in exporting Matlab coloured patches to STL or another format that can be used for 3D printing?

I have a mesh with values associated to each point of the mesh. In this way I can colour the surface and obtain something like in the figures below. I would like to try and print a colour 3D model corresponding to the mesh with the colors. However, I did not manage to use any of the available tools on the Matlab file exchange in order to do this. No matter what I do I do not manage to get the color information in the file.

Do you have any suggestions regarding which format I could use to store the mesh with colours attached to vertices so that the resulting file could be used by 3D printers?

Here's an example of object I'd like to print:

enter image description here


Solution

  • Looks like sometimes it is better to find your own solution. The answer I found was using obj. The obj format is quite straightforward and it is easy to write the file with a little bit of string manipulation.

    Points are written on lines starting with v. The following 3 items are point coordinates and the following three items are colors in the RGB format. Faces are written on lines starting with f followed by three integers representing point indices (roughly the number of the line the vertex is situated).

    v coord1 coord2 coord3 color1 color2 color3
    f n1 n2 n3 
    

    Once you have a valid obj file you can import it into MeshLab (free software) and then export it to whatever format you like: stl, ply, etc.