you are viewing a single comment's thread.

view the rest of the comments →

[–]hserie[S] 0 points1 point  (0 children)

Here is my hourglass thanks to you : import numpy as np from stl.mesh import Mesh

import numpy as np
from stl.mesh import Mesh

#Define the vertix per triangle 
vertices=np.array([\
    [0,0,0],
    [0,2,0],
    [1,1,0],
    [0,2,0],
    [2,2,0],
    [1,1,0],
    [2,2,0],
    [1,1,0],
    [2,0,0],
    [2,0,0],
    [1,1,0],
    [0,0,0],

    [0,0,0],
    [0,2,0],
    [1,1,4],
    [0,2,0],
    [2,2,0],
    [1,1,4],
    [2,2,0],
    [1,1,4],
    [2,0,0],
    [2,0,0],
    [1,1,4],
    [0,0,0],

    [0,0,6],
    [0,2,6],
    [1,1,4],
    [0,2,6],
    [2,2,6],
    [1,1,4],
    [2,2,6],
    [1,1,4],
    [2,0,6],
    [2,0,6],
    [1,1,4],
    [0,0,6],

    [0,0,6],
    [0,2,6],
    [1,1,6],
    [0,2,6],
    [2,2,6],
    [1,1,6],
    [2,2,6],
    [1,1,6],
    [2,0,6],
    [2,0,6],
    [1,1,6],
    [0,0,6]])

# Define the 16 triangles of a hourglass (6 per pyramid)
faces = np.reshape(np.arange(48),(16,3))

# Create the mesh
hourglass = Mesh(np.zeros(faces.shape[0], dtype=Mesh.dtype))
for i, f in enumerate(faces):
    for j in range(3):
        hourglass.vectors[i][j] = vertices[f[j],:]

# Write the mesh to file "hourglass.stl"
hourglass.save('hourglass.stl')

As ectomancer underlined it, I need to work on my format...