File Exchange

image thumbnail

Fast STL import function

version 1.0 (2.16 KB) by

Function to import .stl geometry model files into matlab.

3.83333
6 Ratings

24 Downloads

Updated

View License

This version is currently ASCII only but future revisions will support binary. This function is based off of Luigi Giaccari's STL importer but uses the textscan function to dramatically increase speed, which makes a significant difference for large files.

Comments and Ratings (13)

Viren Mistry

Solution:

I am using Matlab 2013 maybe that's causing all the issues but I replaced "if (C{4}(end)== NAN)" to "if(isnan(C{4}))"
Works great now.
Let me know if that solved the problem.
Cheers !

Viren Mistry

Did anyone find a solution to the "if (C{4}(end)== NAN)" Error. I tried using isnan funtion as well as suggested still didn't work!
Any updates/help will be appreciated.
Thank you

Brian Guthrie

I have the same problems: removed all'\r' in line 47. I get two errors:
>import_stl_fast(filename, 1)
>Error using import_stl_fast (line 31)
>invalid input number /mode setting
and
>> import_stl_fast(filename, 2)
Subscript indices must either be real positive integers or logicals.

Error in import_stl_fast (line 61)
if (C{4}(end)== NAN)

Carlos

Carlos (view profile)

Once I changed line 47 it works great! Super fast!

Solution: in line 47 'fmt = ...' remove all the '\r'. Those might be needed in Windows?

Hello Dear,

You have written a very useful code for stl files.

However, i have one question.

How to display the output after reading an stl file. as i tried patch to display it but it is not displaying the correct model which i gave as input.

can you tell me how to display the output of your function? or do we need any conversion before that?

Andrew Hundt

I too am getting this error. Anyone have a solution?

Fritz

Fritz (view profile)

@Pierrick Bersier: I'm getting the same error.

When I try to load my STL with that script, I get every time the same error. an sombody help ?

Subscript indices must either be real positive integers or logicals.

Error in import_stl_fast (line 59)
if (C{4}(end)== NaN)

Ilkay Meseli

Works OK for ASCII STL files. Thanks.

Eric Trautmann

Eric Trautmann (view profile)

If any current users are interested in a binary stl import, please let me know.

MATLAB Release
MATLAB 7.11 (R2010b)

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

» Watch video