STL file to a readable text file
Asked Answered
C

5

8

I am now studying 3d models (stl files and etc) and how it is made from scratch. What software do I need to use to see what's inside the stl file like this:

solid dart
    facet normal 0.00000E+000 0.00000E+000 -1.00000E+000
        outer loop
            vertex 3.10000E+001 4.15500E+001 1.00000E+000
            vertex 3.10000E+001 1.00000E+001 1.00000E+000
            vertex 1.00000E+000 2.50000E-001 1.00000E+000
        endloop
    endfacet
endsolid dart

I have been searching for those kinds of software but so far, no luck.

Cle answered 4/12, 2018 at 7:47 Comment(2)
Just type "stl viewer" in your preferred search engine.Lacour
I've been searching like that for like eternity @MichaelA.SchaffrathCle
D
5

MeshLab (http://www.meshlab.net) is a widely used open source viewer for 3D models that handles well all the STL variants (and many other 3D files). Available for mac/win/linux

There is also an online version that runs in your browser http://www.meshlabjs.net

Dartmouth answered 4/12, 2018 at 21:18 Comment(5)
Could I really see the text file inside the .stl file using this?Cle
You can't use this tool to convert .stl binary files to ASCII textChalk
If you just want to see the coords of the file you can easily use meshlabjs.net to convert .stl binary to ASCII text format, by saving it into .off formatDartmouth
Yes, you can use this to convert to stl ASCII - just unclick "use binary encoding" when exporting the file.Diseuse
He says : " I am now studying 3d models " , He asks " STL file to a readable text file" in stackoverflow. You advertise a viewer. I inspect the website no conversion possible. let alone viewing 3d visual while modifying file.Officious
M
4

STL files are available in ASCII format as well as in binary format. Most STL files are in binary format and can not be opened as text. To change the format, a CAD program can be used (change options in "Save as").

In ASCII format, the representation is as follows:

solid dart
    facet normal 0.00000E+000 0.00000E+000 -1.00000E+000
        outer loop
            vertex 3.10000E+001 4.15500E+001 1.00000E+000
            vertex 3.10000E+001 1.00000E+001 1.00000E+000
            vertex 1.00000E+000 2.50000E-001 1.00000E+000
        endloop
    endfacet
endsolid dart

Thus, only the ASCII format allows manual checking of the coordinates of the vertices.

Maureenmaureene answered 30/4, 2019 at 11:59 Comment(0)
F
4

numpy-stl does what you want:

import stl
from stl import mesh

your_mesh = mesh.Mesh.from_file('INPUT.stl')
your_mesh.save('OUTPUT.stl',mode=stl.Mode.ASCII)

However if you want it to do by binary conversion, use this program I wrote in Python3 using this reference.

import struct
def ffb(x): 
    return str(round(struct.unpack('f',x)[0],6))
f=open('3dtest.stl','rb')
print(f.read(84))
temp=''
for j in range(4):
    temp='facet normal: '
    for i in range(3):
        temp=temp+ffb(f.read(4))+' '
    print (temp)

    for n in range(3):
        temp='vertex: ' 
        for i in range(3): 
            temp=temp+ffb(f.read(4))+' ' 
        print (temp) 
    attr=f.read(2)
    print('###################################')
   
f.close()
temp=temp[:-1]
print(temp)

Result:

b'MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH\n\x0c\x00\x00\x00'
facet normal: 0.0 1.0 0.0 
vertex: 12.671906 11.296659 0.0 
vertex: -11.984282 11.296659 0.0 
vertex: -11.984282 11.296659 10.0 
###################################
facet normal: 0.0 1.0 -0.0 
vertex: 12.671906 11.296659 0.0 
vertex: -11.984282 11.296659 10.0 
vertex: 12.671906 11.296659 10.0 
###################################
facet normal: 1.0 0.0 0.0 
vertex: 12.671906 -10.8055 0.0 
vertex: 12.671906 11.296659 0.0 
vertex: 12.671906 11.296659 10.0 
###################################
facet normal: 1.0 0.0 0.0 
vertex: 12.671906 -10.8055 0.0 
vertex: 12.671906 11.296659 10.0 
vertex: 12.671906 -10.8055 10.0 
###################################

Same binary STL converted to text via numpy-stl:

solid MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH-MESH
facet normal 0,000000 246,561890 0,000000
  outer loop3
    vertex 12,671906 11,296659 0,000000
    vertex -11,984282 11,296659 0,000000
    vertex -11,984282 11,296659 10,000000
  endloop
endfacet
facet normal 0,000000 246,561890 -0,000000
  outer loop
    vertex 12,671906 11,296659 0,000000
    vertex -11,984282 11,296659 10,000000
    vertex 12,671906 11,296659 10,000000
  endloop
endfacet
facet normal 221,021591 0,000000 0,000000
  outer loop
    vertex 12,671906 -10,805500 0,000000
    vertex 12,671906 11,296659 0,000000
    vertex 12,671906 11,296659 10,000000
  endloop
endfacet
facet normal 221,021591 0,000000 0,000000
  outer loop
    vertex 12,671906 -10,805500 0,000000
    vertex 12,671906 11,296659 10,000000
    vertex 12,671906 -10,805500 10,000000
  endloop
endfacet

numpy-stl code:

import stl
from stl import mesh
your_mesh = mesh.Mesh.from_file('INPUT.stl')
your_mesh.save('OUTPUT.stl',mode=stl.Mode.ASCII)

I advise you to put 3d plotting on a loop via any language or renderer. Forward errors to /dev/null and edit the file seeing what happens in realtime. I think that would be the best possible study. Of course while checking out sample output of the various geometry in another window.

Felder answered 1/3, 2022 at 11:41 Comment(0)
W
1

Download MeshLab, Import your stl file, Export it as an stl file when you uncheck binary encoding

OR

Download FreeCAD, Import your stl file, Export it as an ast file

Open the exported file with a text editor

Weksler answered 3/6, 2023 at 23:39 Comment(0)
A
0

You can use the open-source STL-Viewer software I made. It supports both Binary and ASCII formatted STL files. Here is the link: https://github.com/batu92k/STL-Viewer

Amplification answered 7/3, 2020 at 16:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.