Closed odgiv closed 5 years ago
Hi @odgiv , a .stl-file is basically a list of triangles.
your_mesh.vectors
gives you all triangles defined by their vertices.
You can also access the vertices by using:
your_mesh.v0
,your_mesh.v1
and your_mesh.v2
Note that for example your_mesh.v0[0],your_mesh.v1[0],your_mesh.v2[0]
are the vertices of the first triangle (position 0) .
If you only want all vertices of your mesh in one array you could maybe do this:
import numpy as np
from stl import mesh
# Using an existing stl file:
your_mesh = mesh.Mesh.from_file('some_file.stl')
# Creating an array with all vertices of all triangles:
allvertices = np.array([your_mesh.v0,your_mesh.v1,your_mesh.v2])
# Numpy-Concatenate to connect the three arrays with each other
allvertices = np.concatenate(allvertices)
# Removing duplicate vectors
allvertices = np.unique(allvertices,axis=0)
print(allvertices)
maybe this can also help you: https://pythonhosted.org/numpy-stl/usage.html#quickstart
I hope i could help
@biga123 thank you.
I guess the question has been answered. If you need more help feel free to request a reopen or create a new issue.
Hello, I am quite new in this area. I have a .stl file. I want to get vertices of this object. The vertices should be in shape of (Mx3). How to do that?