# Issues with pymeshlab

**URL:** <https://forum.compas-framework.org/t/issues-with-pymeshlab/642>\
**Category:** Uncategorized\
**Created:** [November 21, 2022, 5:42pm UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642 "2022-11-21T17:42:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![FilipeJSBrandao](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/filipejsbrandao/32/411_2.png) [@FilipeJSBrandao](https://forum.compas-framework.org/u/FilipeJSBrandao)\
**Post date:** [November 21, 2022, 5:42pm UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/1 "2022-11-21T17:42:46Z")

</div>

Hello!

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

```auto
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:

```auto
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?

Thanks,

---

<div class="post-metadata">

**Author:** ![tomvanmele](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/tomvanmele/32/13_2.png) [@tomvanmele](https://forum.compas-framework.org/u/tomvanmele)\
**Post date:** [November 21, 2022, 8:10pm UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/2 "2022-11-21T20:10:34Z")

</div>

the Qt error doesn’t seem to be version related necessarily, but perhaps try to make to separate environments to see if the problem goes away.

related to the PLY thing.  
can you post the PLY file that COMPAS is unable to load?

---

<div class="post-metadata">

**Author:** ![FilipeJSBrandao](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/filipejsbrandao/32/411_2.png) [@FilipeJSBrandao](https://forum.compas-framework.org/u/FilipeJSBrandao)\
**Post date:** [November 22, 2022, 9:29am UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/3 "2022-11-22T09:29:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![FilipeJSBrandao](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/filipejsbrandao/32/411_2.png) [@FilipeJSBrandao](https://forum.compas-framework.org/u/FilipeJSBrandao)\
**Post date:** [November 22, 2022, 9:37am UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/4 "2022-11-22T09:37:37Z")

</div>

Here are some links to two different ply files saved with meshlab:

> **[box.ply](https://www.dropbox.com/s/fo393dcyoyfg677/box.ply?dl=0)**
>
> Shared with Dropbox

> **[convex\_hull.ply](https://www.dropbox.com/s/c9cm0rzr5jkxdjq/convex_hull.ply?dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

**Author:** ![tomvanmele](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/tomvanmele/32/13_2.png) [@tomvanmele](https://forum.compas-framework.org/u/tomvanmele)\
**Post date:** [November 22, 2022, 9:55am UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/5 "2022-11-22T09:55:00Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![tomvanmele](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/tomvanmele/32/13_2.png) [@tomvanmele](https://forum.compas-framework.org/u/tomvanmele)\
**Post date:** [November 22, 2022, 9:55am UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/6 "2022-11-22T09:55:50Z")

</div>

could you try exporting the files in ascii format (text-based PLY) so we can have a look at what is inside?

---

<div class="post-metadata">

**Author:** ![FilipeJSBrandao](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/filipejsbrandao/32/411_2.png) [@FilipeJSBrandao](https://forum.compas-framework.org/u/FilipeJSBrandao)\
**Post date:** [November 22, 2022, 10:23am UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/7 "2022-11-22T10:23:40Z")

</div>

It opens fine in Rhino on my side. Here is a printscreen:

 ![cubo](https://us1.discourse-cdn.com/flex015/uploads/compas_framework1/original/1X/28d2e9d0d553620a83733eb7df8e8518e61d98d6.png)

And here is the same cube but saved in ASCII:

> **[box\_ASCII.ply](https://www.dropbox.com/s/jk9hrzplbgom7iy/box_ASCII.ply?dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

**Author:** ![FilipeJSBrandao](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/filipejsbrandao/32/411_2.png) [@FilipeJSBrandao](https://forum.compas-framework.org/u/FilipeJSBrandao)\
**Post date:** [November 22, 2022, 10:26am UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/8 "2022-11-22T10:26:46Z")

</div>

If you change the above code from binary to ASCII, compas can read the file correctly.

```auto
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 = 'box.ply'
# =============================================================================
# MeshLab meshes
# =============================================================================

ms = pymeshlab.MeshSet()
ms.create_cube()
ms.save_current_mesh(CH, binary=False)

# =============================================================================
# MeshLab to Compas
# =============================================================================

box = Mesh.from_ply(CH)
print(box.number_of_vertices())
print(box.number_of_faces())

```

---

<div class="post-metadata">

**Author:** ![tomvanmele](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/tomvanmele/32/13_2.png) [@tomvanmele](https://forum.compas-framework.org/u/tomvanmele)\
**Post date:** [November 22, 2022, 12:42pm UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/9 "2022-11-22T12:42:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![FilipeJSBrandao](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/filipejsbrandao/32/411_2.png) [@FilipeJSBrandao](https://forum.compas-framework.org/u/FilipeJSBrandao)\
**Post date:** [November 22, 2022, 12:46pm UTC](https://forum.compas-framework.org/t/issues-with-pymeshlab/642/10 "2022-11-22T12:46:19Z")

</div>

Yes, no problem. Thanks
