# \`Pointcloud.from\_ply()\` returns Nonetype

**URL:** <https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715>\
**Category:** compas\
**Created:** [July 21, 2023, 2:08pm UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715 "2023-07-21T14:08:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zac\_Zhuo\_Zhang](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/zac_zhuo_zhang/32/433_2.png) [@Zac\_Zhuo\_Zhang](https://forum.compas-framework.org/u/Zac_Zhuo_Zhang)\
**Post date:** [July 21, 2023, 2:08pm UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715/1 "2023-07-21T14:08:19Z")

</div>

Hi,

I was hoping to load `compas.geometry.Pointcloud` in order to view it by view2 and found this problem, even using the official `airplane.ply` file in [https://people.sc.fsu.edu/~jburkardt/data/ply/airplane.ply:](https://people.sc.fsu.edu/~jburkardt/data/ply/airplane.ply:)

```auto
from compas.geometry import Pointcloud

pcd = Pointcloud.from_ply("") # Neither relative nor absolute path works in my case

print (type(pcd))

>>><class 'NoneType'>

```

Thanks in advance for any reply!

---

<div class="post-metadata">

**Author:** ![petrasvestartas](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/petrasvestartas/32/305_2.png) [@petrasvestartas](https://forum.compas-framework.org/u/petrasvestartas)\
**Post date:** [July 24, 2023, 11:47am UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715/2 "2023-07-24T11:47:05Z")

</div>

It seems it is not implemented.  
If you look at the source code you can see only function definition:

```auto
    @classmethod
    def from_ply(cls, filepath):
        """Construct a pointcloud from a PLY file.

        Parameters
        ----------
        filepath : str | bytes | os.PathLike
            Path of the PLY file.

        Returns
        -------
        :class:`~compas.geometry.Pointcloud`

        """
        pass

```

---

<div class="post-metadata">

**Author:** ![petrasvestartas](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/petrasvestartas/32/305_2.png) [@petrasvestartas](https://forum.compas-framework.org/u/petrasvestartas)\
**Post date:** [July 24, 2023, 11:59am UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715/3 "2023-07-24T11:59:44Z")

</div>

You can try ply reader alone. Just a quick check, it reads the ASCII file:

```
ply_object = reader.PLYReader("C:/test0.ply")
ply_object._read_data()
print(ply_object.vertices)

```

---

<div class="post-metadata">

**Author:** ![Zac\_Zhuo\_Zhang](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/zac_zhuo_zhang/32/433_2.png) [@Zac\_Zhuo\_Zhang](https://forum.compas-framework.org/u/Zac_Zhuo_Zhang)\
**Post date:** [July 25, 2023, 7:24am UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715/4 "2023-07-25T07:24:38Z")

</div>

unfortunately, it is still not working in my ASCII file:(

`UnicodeDecodeError: 'gbk' codec can't decode byte 0xfd in position 275: illegal multibyte sequence`

---

<div class="post-metadata">

**Author:** ![petrasvestartas](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/petrasvestartas/32/305_2.png) [@petrasvestartas](https://forum.compas-framework.org/u/petrasvestartas)\
**Post date:** [July 25, 2023, 8:04am UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715/5 "2023-07-25T08:04:06Z")

</div>

The `UnicodeDecodeError` you encountered indicates that there was an issue decoding a byte sequence using the ‘gbk’ codec, which is used for decoding text in the GBK character encoding. The error message specifically points out that byte 0xfd in position 275 of the input cannot be decoded as a valid character in the GBK encoding.

You can try to check the line 275 by opening the files in the text editor or vs code, if there are any weird characters. I have a feeling that you are using binary not ascii.

Can you share the file?  
Normally ply files are just txt files with just an ending of .ply, so as long as you are not using binary you should be even be able to parse it yourself:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/compas_framework1/original/1X/9a1bbc8316fa2e89cfcf7bb900c9c3a89d1819ed.png)

---

<div class="post-metadata">

**Author:** ![Zac\_Zhuo\_Zhang](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/zac_zhuo_zhang/32/433_2.png) [@Zac\_Zhuo\_Zhang](https://forum.compas-framework.org/u/Zac_Zhuo_Zhang)\
**Post date:** [July 25, 2023, 8:43am UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715/6 "2023-07-25T08:43:33Z")

</div>

thanks again for the reply! I just found this example file works,

> [@Zac\_Zhuo\_Zhang](#):
>
> [https://people.sc.fsu.edu/~jburkardt/data/ply/airplane.ply](https://people.sc.fsu.edu/~jburkardt/data/ply/airplane.ply)

I will check my file for sure.

While, since the official document is very missing, I can only run the code you sent me without any operation. Even the `._read_data()` function is not listed in the doc. I wonder is there a way to transfer the `ply_object` into `compas.geometry.Pointcloud`? Thanks!

---

<div class="post-metadata">

**Author:** ![petrasvestartas](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/petrasvestartas/32/305_2.png) [@petrasvestartas](https://forum.compas-framework.org/u/petrasvestartas)\
**Post date:** [July 26, 2023, 5:17pm UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715/7 "2023-07-26T17:17:00Z")

</div>

At the current implementation no.  
But you can read the ply and then assign point list to the pointcloud property. It is a very light implementation of a point list from what I see here, what do you want to use it for ? :  
[compas/src/compas/geometry/pointclouds/pointcloud.py at main · compas-dev/compas (github.com)](https://github.com/compas-dev/compas/blob/main/src/compas/geometry/pointclouds/pointcloud.py)

---

<div class="post-metadata">

**Author:** ![Zac\_Zhuo\_Zhang](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/zac_zhuo_zhang/32/433_2.png) [@Zac\_Zhuo\_Zhang](https://forum.compas-framework.org/u/Zac_Zhuo_Zhang)\
**Post date:** [July 27, 2023, 8:18am UTC](https://forum.compas-framework.org/t/pointcloud-from-ply-returns-nonetype/715/8 "2023-07-27T08:18:22Z")

</div>

awesome! I got what you mean! Actually, I am trying to read the PointCloud and visualize it in `compas_viwe2` as Rhino&GH are not meant for point clouds, view2 is perfect in this role:

as you said, I convert the reader object to `compas.geometry.Pointcloud`:

```auto
from compas.files import PLYReader
from compas.geometry import Pointcloud
ply_object =PLYReader("src\standard_pcd.ply")
ply_object._read_data()

pcd = Pointcloud([[v["x"], v["y"],v["z"]] for v in ply_object.vertices])

print (len(pcd.points))

```

Then I visualize the point cloud:

```auto
from compas_view2.app import App
viewer = App()
viewer.add(pcd)
viewer.show()

```

The visual effect is not the best but it works somehow! thanks for the answer!
