May-09-2024, 05:31 AM
Hi there,
I'm trying to create STL files using python code and found the following sample:
Best regards
I'm trying to create STL files using python code and found the following sample:
from stl import mesh
import math
import numpy
# Create 3 faces of a cube
data = numpy.zeros(6, dtype=mesh.Mesh.dtype)
# Top of the cube
data['vectors'][0] = numpy.array([[0, 1, 1],
[1, 0, 1],
[0, 0, 1]])
data['vectors'][1] = numpy.array([[1, 0, 1],
[0, 1, 1],
[1, 1, 1]])
# Right face
data['vectors'][2] = numpy.array([[1, 0, 0],
[1, 0, 1],
[1, 1, 0]])
data['vectors'][3] = numpy.array([[1, 1, 1],
[1, 0, 1],
[1, 1, 0]])
# Left face
data['vectors'][4] = numpy.array([[0, 0, 0],
[1, 0, 0],
[1, 0, 1]])
data['vectors'][5] = numpy.array([[0, 0, 0],
[0, 0, 1],
[1, 0, 1]])Now I'm wondering what's the exact meaning of dtype=mesh.Mesh.dtype. Looks like it assigns a data type to the list, however, I don't understand its structure. What's the meaning of the fist 'mesh', what's the meaning of the second 'Mesh' and what's the meaning of the 'dtype' in the expression. Could anybody given an explanation, please? I didn't find useful documentation for a beginners level.Best regards
