1

I just started using pymeshlab and am really enjoying it. I am having trouble with one thing, however. I'm trying to use the vertex_attribute_transfer filter, but would rather use a world unit rather than a percentage for the upperbound parameter. I figured I would be able to calculate the correct percentage for the parameter based off my desired world unit divided by diagonal length of the bounding box x100, but I cannot figure out how to get the bounding box info for a mesh in the MeshSet.

I see the compute_geometric_measures tool is supposed to provide bounding box info based off the documentation, but a dictionary with other information related to the mesh is the result (like average edge length, area, etc -- which is still useful info). I also see that there is an entire bounding box class, but I don't know how to use it to get the bounding box info for a specific mesh in the MeshSet.

Could some one please provide an example getting the bounding box info for a mesh in pymeshlab?

Rockcat
  • 3,002
  • 2
  • 14
  • 28
  • 1
    Figured it out -- for anyone wondering, it looks like this: boundingbox = ms.current_mesh().bounding_box() diag = boundingbox.diagonal() – Phil Devine Jan 18 '21 at 01:15
  • Hi Phil, welcome to SO. As you have found the answer by yourself, could you post your code as an answer instead of as a comment? This will help others to find your solution, because won't see this question as unanswered. – Rockcat Jan 18 '21 at 08:59

2 Answers2

1

Figured out how to get bounding box info. For anyone wondering, it looks like this:

boundingbox =  ms.current_mesh().bounding_box()
diag = boundingbox.diagonal()
1

I will extend the original answer given by Phil Devine to give a complete executable example. This example read a mesh and calls the diagonal() method.

import pymeshlab as ml
ms = ml.MeshSet()
ms.load_new_mesh('input.ply')
m = ms.current_mesh()

#Build the Bounding Box and get its diagonal length
diag = m.bounding_box().diagonal()

print('Diagonal of this model:', diag)
Rockcat
  • 3,002
  • 2
  • 14
  • 28