I’m trying to use pymeshlab with compas in a project. To avoid writing a conversion from meshlab meshes to compas meshes I was just exporting the meshes after processing them with meshlab to a ply file. Strangely, Compas cannot read the faces in a MeshLab meshes saved as ply. It does work with obj files, though.
I also get an error with the viewer. Here is an code example that triggers the error
import compas
import pymeshlab
from compas.geometry import Box
from compas.geometry import Frame
from compas.geometry import Point
from compas.geometry import Line
from compas.datastructures import Mesh
from compas_view2.app import App
CH = 'convex_hull.obj'
mesh = Mesh.from_ply(compas.get('bunny.ply'))
# =============================================================================
# MeshLab meshes
# =============================================================================
ms = pymeshlab.MeshSet()
ms.create_cube()
ms.save_current_mesh(CH)
# =============================================================================
# MeshLab to Compas
# =============================================================================
box = Mesh.from_obj(CH)
print(box.number_of_vertices())
print(box.number_of_faces())
# =============================================================================
# Viz
# =============================================================================
viewer = App()
viewer.view.camera.position = [5, -3, 2]
viewer.view.camera.look_at([0, 0, 0])
viewer.add(mesh)
viewer.add(box)
viewer.show()
This is the console output:
8
6
QObject::moveToThread: Current thread (0x297ea7d7400) is not the object's thread (0x297e371f8d0).
Cannot move to target thread (0x297ea7d7400)
qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: windows, direct2d, minimal, offscreen, webgl.
Might it be the case that pymeshlab and compas.view2 depend on different versions of qt?
It works in the same environment. I just have to separate all the pymeshlab code from the compas code in different scripts.
I’m not allowed to post the PLY file here, but any simple cube will show the issue. For instance, in the above code just changing CH = 'convex_hull.ply will save the cube as PLY. Then changing the line box = Mesh.from_ply(CH) will import the ply file created by Meshlab with a simple cube. You will see that it will print 0 faces.
seems to be something wrong with these files. if i use the PLY reader directly it complains about the encoding, and if i try loading them in Rhino they have no content either…
okay, weird. the reader is supposed to be able to handle binary files so i will check what is going on there. in the meantime, you can work with the ASCII encoding?