PLY importer for Grasshopper

Tree to PLY

It can be useful to use cloudpoints in Grasshopper and therefore having a way import PLY files.

The Binari format is fully readable, meaning that it’s possible to read, filter, and extract any useful information. Let’s dive.

We will start from the photogrammetry from a tree. To test we will use a light version of the cloud point.

Exporting PLY from Meshlab / CloudCompare

First the more important is to understand the PLY’s file header. It can be slightly different depending which software writes it.

Meshlab

Meshlab (https://www.meshlab.net/) is a free software that allows to convert, manipulate and transform many 3D files format. A must have. Exporting PLY from Meshlab give this:

We can here remember that the Header takes 17 lines and points coordinates are lines 5 to 6 and colour + alpha are lines 11 to 14.

After the header we have the points coordinates

CloudCompare

CloudCompare (https://www.danielgm.net/cc/) is another great tool to edit, simplify, transform and export CloudPoints

In CloudCompare it is possible to filter the needed information when importing

The Alpha Channel is not always set. I can be done by hand.

The export gives

We see here that elements are not sorted in the same order. Lines 6 to 8 are for the coordinates and colours are 9 to 11 and there is no Alpha.

We will take that into account in Grasshopper.

Grasshopper

Let’s start by creating a File Path and a Read File

Adding a Panel I can see how my file is structured

Then I will separate the Header from the points coordinates

I use a Split List. Here it has to be cut line 15.

Now I need to break the lines of coordinates to have Points Coordinates, Normals, and Colors into lists.

I use a Text Split

Now I’ve a got my list of points and as sub lists, all the coordinates.

I’ll isolate the point coordinates, the colours and Normals

We add the Index and the Construct Point

For the Colours I kept the Alpha just in case, even if I don’t have it here.

With Index

And Normals

Results

We can see that the cloudpoint is visible in Rhino (I used a very light cloudpoint)

We can create boxes from the points to visualise the colours.

And add colours

And Normals

The definition

Result with 10 000 points. But very fast Rhino and Grasshopper will be overflowed.

Experiment in VR

https://spatial.io/s/The-Old-Tree-6314d2e9ebd6c80001d72158?share=7027727403376370960

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.