[Python] 'numpy.ndarray' object has no attribute 'vertices' despite using this attribute...

Discussão em 'Python' iniciado por Stack, Junho 24, 2025.

  1. Stack

    Stack Membro Participativo

    I used this code to crop an OBJ file. These lines make a mask and apply it. For some reason numpy has randomly started to give me these errors. This code has worked for over 200 files and suddenly does not work for any new ones. I know numpy has this attribute because I've been using it for days. I've tried restarting the kernel, restarting my computer, and editing the code but then it gives me the error that numpy doesn't have the attribute 'show' which I've also been using for days. Has anyone experienced this before?

    min_bound = np.array([x_min, y_min, z_min])
    max_bound = np.array([x_max, y_max, z_max])

    # Get mask of vertices inside the bounding box
    inside_mask = np.all((mesh.vertices >= min_bound) & (mesh.vertices <= max_bound), axis=1)

    # Keep faces where all three vertices are inside the bounding box
    face_mask = np.all(inside_mask[mesh.faces], axis=1)

    # Create new mesh with only those faces
    cropped_mesh = mesh.submesh([face_mask], append=True)

    # get vertices and faces of cropped
    cropped_vertices = cropped_mesh.vertices
    cropped_faces = cropped_mesh.faces

    print('Currently displaying mesh ' + OBJ_Path)
    cropped_mesh.show()

    Continue reading...

Compartilhe esta Página