File Exchange

image thumbnail

STL File Reader

version 1.2 (1.6 MB) by

STLREAD imports geometry from a binary stereolithography (STL) file into MATLAB.

4.46667
33 Ratings

328 Downloads

Updated

View License

In addition to the STLREAD import function, this submission also includes a small demo that loads an STL model of a human femur bone.

FV = STLREAD(FILENAME) imports triangular faces from the binary STL file
indicated by FILENAME, and returns the patch struct FV, with fields 'faces'
and 'vertices'.

[F,V] = STLREAD(FILENAME) returns the faces F and vertices V separately.

[F,V,N] = STLREAD(FILENAME) also returns the face normal vectors.

The faces and vertices are arranged in the format used by the PATCH plot
object.

Comments and Ratings (41)

Di Zhu

Di Zhu (view profile)

hao li

hao li (view profile)

thank you

Fadi Kahwash

Works well for me. Thanks Eric!!

Trader_Zoe

Hi Eric,

When I run this demo I get an error message "Undefined function or variable 'stlread'."

Is there a toolbox I may be missing to run this stlread function?

Thank you in advance!

Thank you! It worked for me at first attempt!

André Brito

André Brito

AN DUONG HOAI

Brandon Jones

I have been attempting to convert CAD files to MATLAB for the past week. I have gone through a half dozen xml and iges toolboxes and none worked. This program worked the first time I tried it and has an easy to understand interface. Thank you.

Victoria Hung

thank you so much! that's really useful and impressive!

Iñigo Moreno

@Evan That is because the vertices appear one time for each face, try running:

[v, ~, index] = unique(v, 'rows');
f = index(f);

Ron Perrone

Does anyone have any suggestions for any other files that can do this? Can't seem to get this one to work. The demo didn't work either. Looks good, but need one that is a little more user friendly. Any suggestions are greatly appreciated. Im sure this one is 5 stars for those who can get it to work.

Evan Terrell

Great function, but one problem. When I open my stl in a mesh editor, the surface has 55,000 vertices. However, when I read the file into Matlab with this script, there are nearly 330,000 vertices. Any idea what the problem is?

Ron Perrone

Unfortunately this script wouldn't run for me. Keeps saying more input requirements are needed to run, even though I have the correct name of the file.

Great!

Di Zhu

Di Zhu (view profile)

works well

hao gu

hao gu (view profile)

deeply impressed

j p

j p (view profile)

Excellent!! but only support binary format.

Brad Saund

Omar Osama

Michael Volk

How do I get this to work?

James

James (view profile)

Worked like a charm on a very complex SE-translated STL file.

This function is for binary STLs only, and will cause problems when used with ascii STL. The conditional statement against reading ascii STLs is commented out.

Arne

Arne (view profile)

what is meant by faces and vertices?

I want to generate a 3D-array out of my STL-files.. is there a way?

Memory expensive, the script quickly crash because the computer is out of memory. The script extract about a billion points from my STL files. From my calculation, I would need about 100 Gb of ram......

Does someone have a solution for this problem?

negar

negar (view profile)

Hi. thanks for this program. can you send me flowchart?
Best regards.

Saber

Saber (view profile)

Great work!

Great! fast and easy to use.

Héctor Corte

Wonderful submision. I used it to make some geek gif in my blog.
http://thebrickinthesky.wordpress.com/2012/12/23/my-own-death-star/

Patrick

Very helpful

Santosh ARS

i think this gives wrong faces? Please confirm.

Robert

Robert (view profile)

Thanks for your submittal. What units is the model in once I've read the stl file with Matlab. I am using NextEngine's 3D scanner and they are telling me that the units are defined by the reader utility.

Very nice and useful.
Thanks

By ?

By ? (view profile)

very good

Very useful for binary filesl but do not support ascii format

Jveer

Jveer (view profile)

very useful!

can the vertices and faces be arranged such that they can be used with surf??

textures cannot be applied to patch objects. surf is more useful.

alain boyer

Updates

1.2

Updated submission with example script and 3D model.

1.1

None

MATLAB Release
MATLAB 7.7 (R2008b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

STLRead/

STLRead/html/