Read a .stl in grasshopper

I need to read .stl files in grasshopper what is the most robust method to do this without loading it into Rhino.

Many thanks!
Kevin

Did you look to that ?

Hi Laurent,

Thanks for your response. I actually already came across that post and did a lot of testing on it and it unfortunately too 6 minutes to open some files and may of them had issues. Any other thoughts?

Regards,
Kevin

For sure this tool just read asci STL files. Sometimes they are binary …
Strange that nobody has done an importer ?

I have found some in my search but none that works in a robust manor

have you example files thats fails ?
Is it a format problem or a reader problem ?

I’m hoping someone much smarter then I am has or knows how to and can lead me in the right direction

Just in case
Here a 15 minutes code to read STL binary
tell me if it is OK
See next for a good version

Hey Laurent,

Just came off a call to see this! Thanks so much I’ll test it now!

Regards,
Kevin

Hi Laurent,

I’ve attached the two options which I are both working. Your importer works great, but as you mentioned it only works for Binary files. The importer which works for ASCII files works, but takes between 2-6 minutes for full size files (the binary import is almost instantaneous). Unfortunately, I will be using both file types and most of them are binary. I guess the fast Binary and ASCII importer I’m looking for is much more complicated than first expected. I’ve attached a copy of auto-generated ASCII/Binary test mesh I’m working with and the combined .gh (one for ASCII stls and one for Binary) just in case anyone can shed some light. Thanks again for the help. It’s very much appreciated!

Regards
Kevin

Simplified_Binary_MESH.stl (1.9 MB)

Simplified_ASCII_MESH.stl (12.1 MB)

STL_reader_BINARY or ASCII.gh (6.2 KB) ,

I will make a ASCII reader but it must be robust to many situations as you mentioned … I began it and it is good to have different stl file to test.
In 1 or 2 days I must have something
From Wikipedia I understand that ASCII files have different delimiters …

Here a STL reader that read both types of files. It opened all my STL. It open 200 Mo file in 4s.
Hope it is useful
Updated the 22/06/2019, some imporvements, I found on may hard disk others STL that didn’t work. ASCII files have often quite subtilities. For sure there could be some more robust way to handle that.
image
The file here try to put all the model on a square. It was useful for me to test the abilities of the tool.
STL_reader_LEGACY.gh (17.2 KB)
You can also open multiple file without problem. If you find a STL that didn’t work I will be curious to test it.

78 Meshes, 3.9 million of pixels , 24 second to open, no invalid mesh if “cure” set to true
image

6 Likes

Hi Laurent,

Sounds amazing. Thanks so much for helping me out on this! I’ll test it out now!

Regards,
Kevin

Sometimes problem are inside rhino so you could set cure to true

All is workign as intended thanks!

Here a new version that handles STL files with many solids inside.
STL_reader_LEGACY.gh (24.4 KB)


It works with the file showed in this dicussion. it is also possible to bake the name of the objects using adequate plugin.

18 seconds for 84 meshes and 23 millions of vertexes.

3 Likes