Closed MenachemBerkovich closed 1 month ago
The first argument in Trimesh
constructor must be of shape (V, 3)
with V
being the number of vertices.
You provided a flat list x_1 y_1 z_1 ... x_n y_n z_n
, of shape (V*3,)
.
(the operator +
between a list an a tuple appends its content at the end of the list)
Also you will need to get the vertex indices of the triangles and arrange them in a (T, 3)
fashion.
Then:
vertices = np.asarray(arr).reshape(-1,3) # your vertices but in a (V, 3) shape
faces = ... # faces in a (T, 3) fashion
mesh = trimesh.Trimesh(vertices, faces)
Yeah @kiord is right you need to pass (n, 3) float
vertices and (m, 3) int
faces which are indexes of vertices. As a higher level note you may want to export the solid to a temporary file (i.e. a .GLB
) and load that into trimesh, it is likely to be easier.
I have cadquery.occ_impl.shapes.Solid object that is extracted from some step file loading. I can create a trimesh object with my cadquery object data [like its vertices centers, faces ...]?
I tried this way but without success...
But then:
gives an error: