I am using matlab for a university project to create a simulation of an aerial package drop using 3d models that I made in Blender. I am exporting from blender in ~.stl format (binary form) and importing the file using a matlab script to use in a 3d graph.

Now comes the part I need help with. Rhe script I'm using in matlab can also extract colour data (if any) from the file and apply it to the model. However, a standard stl file only contains info on vertices and faces, but I know from a little research that it is pssible to create ~.stl files with colour data included.

While I could either artificially create the colour data in matlab or just give each model one colour, I'd like to be able to just import the data from blender. Therefore, I've come up with a couple of ideas and was wondering if anyone knows the method/related scripts to achieving one of these solutions? They are:

  1. export model in a different file type that contains colour, to do this I would (probably) need a different matlab import script relating specifically to that file type;

  2. find the correct settings or find a python script that allows blender to attach colour data to an exported ~.stl file; and,

  3. export each different coloured part of each model as it's own model and relate their position to each other in matlab. this I know how to do, but it's tedius and would slow down the simulation unnecessarily.

Also, two other quick things. I'm currently creating the models using cycles engine, in terms of exporting (colour) model data would it be easier to switch to blender render? Also, out of curiosity, to what extent can the material effect from blender be exported? Obviously diffuse can be exported cause it's just applying model colour, but what about effects like gloss, transparency, reflections, etc?

Thank you for your time.


1 Answer 1


According to wikipedia there are two different schemes in use for including color data in an stl file. Unfortunately, they differ significantly from each other, and there is no way to specify which is in use in a file.

So first, I would determine which format matlab exects. This script says it can save in VisCam/SolidView format, so it would be reasonable to expect it to import this format as well, but you'd better check. The problem here is that blender doesn't support the colored format, so you'll have to modify blender's export script...

Since all you're doing is exporting it to view with matlab, a different format that supports textures would probably be a better choice. STL is meant for 3d prototyping, where color typically doesn't matter.

As for the other questions, I'm not sure. Usually it's better to put each question in it's own post.

  • $\begingroup$ thanks for the advice. regarding your suggestion about using another format, which export formats that blender provides can contain colour data? I look it up a little on the blender info website and I think the .ply format can contain colour but I'm not certain. Also, in regardes to your mention all i'm doing is exporting to view in matlab, I didn't properly explain in my original question. When I said i'm exporting it to use in in a 3d graph, I meant that the graph is used as an enviroment to visualise an aircraft dropping an object on a designated target, while avoiding (the package, that is $\endgroup$
    – user3343
    May 1, 2014 at 1:33
  • $\begingroup$ Hard to say, I don't really know which formats matlab supports, and I haven't done much with formats other than stl. I don't want to give a super broad answer, but nearly anything other than stl should do. $\endgroup$
    – user2699
    May 5, 2014 at 16:42
  • $\begingroup$ you might want to try .obj $\endgroup$
    – Vader
    Feb 25, 2015 at 8:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .