File Exchange Pick of the Week

Writing to STL files 17

Posted by Jiro Doke,

Jiro's pick this week is surf2stl by Bill McDonald.

About a month ago, at a seminar I gave at a university, a graduate student came up to me and asked whether there was a function for writing out 3D model files. Specifically, he was referring to STL files (stereolithography files). It was a topical question because it came soon after I talked about some of the exporting capabilities in MATLAB for graphical file formats.

I knew that we didn't have any built in, but I promptly suggested checking out the File Exchange. I've seen a few functions for reading from STL files, so I figured there would be counterparts. Sure enough, there were a few. Here's a list of entries with a tag of "stl".

From the list, I am highlighting Bill's surf2stl. It has nice help, clean code, good reviews, and has even inspired another entry.

Download and give it a try!

Comments?


Get the MATLAB code

Published with MATLAB® 7.8

17 CommentsOldest to Newest

I have the following question and hope that you may shed some light on it. Thanks in advance
I am working on image, how to recover scale, rotation, shear from projective t-matrix?
For example:
1.6971 1.838 0
-1.314 0.989 0
0 0 1

How,
I have download the code,
but I really don’t know what is x,y,z mean in the file.
My question is, I have a 3D matrix, and how can I use surf2stl() to export a STL file?
Thanks for answering!

Ro,
I can’t really answer that because I don’t know what your 3D matrix represents. First step is to get your matrix in a form that can be visualized using the command SURF. For that, I suggest reading the documentation for SURF. Once that’s done, then you can use surf2stl function highlighted in this blog.

jiro,
My 3D matrix represents many points. I have tried the command Surf. But it only works with the 2D matrix. For example, the 3D matrix represents many points in (x,y,z) format. The command Surf can work the same ‘z’ coordinate, so I can’t figure out how to transfer to 3D STL.

Ro,
I’m sorry but I don’t know how to solve your problem. In order to use surf2stl, you have to represent your data in x,y,z format — the same way it is used in surf(x,y,z). Since your 3D matrix does not work with surf, you have to first convert it to something that does.

One question, what is the SIZE of your 3D matrix. Is it something like m-by-n-by-o ?

I suggest either posting your question in the newsgroup or contacting support.

jiro,
I think I can figure out something.
So the question now is: Asuming I have three points, there coordinates are (x1,y1,z1),(x2,y2,z2)and(x3,y3,z3).
How can I use the command surf2stl() to export a stl file?
Thanks for answering me again!

Hey jiro,
did you write the patch2stl code yourself?
I can’t find anything like that in the other blogs.
You would really help me if you could publish your patch2stl code.
Cheers
Madeleine

Hey jiro,
did you write the patch2stl code yourself?
You would really help me if you could publish your patch2stl code.
:)

hey, hello
could you help me, plese?

i want to know your STL Maltal code
because, I’m studying on making coronal image by using 3d image :P

Dear, could you help me reading stl file in matlab?
thanx alot
Iam drawing a part by AutoCAD and I need to read the part stl file using matlab code, so if you have like that code, please send it to me, and thanx for your help

These postings are the author's and don't necessarily represent the opinions of MathWorks.