Convert a mesh to asc xyz file

I’m exploring the docofossor plugin (https://www.food4rhino.com/app/docofossor) which is used for terrain analysis. Unfortunately it only accepts xyz asc files in order to import a terrain. Given below is a screenshot of the example file.

Is there a way in Grasshopper to convert a mesh to xyz file?

dfCutFillInPath.gh (6.5 KB) example_DTM.xyz (248.6 KB)

Hi -

Volvox seems to be able to do that.
image
-wim

1 Like

I did exactly as per your instructions.

I do get the xyz file, but docofossor doesn’t read it and gives error.

WEDNESDAY TESTING.XYZ (86.0 KB)

Grasshopper file is the same as the one in original post, therefore I didn’t attach it again.

Hi - I don’t use docofossor and don’t know what that error is about. You could try contacting Ilmar Hurkxkens directly - his eMail address is on the Food4Rhino page.
-wim

1 Like

I believe the error is because the coordinates of each point are not comma delimited

1 Like

How do I convert them to comma delimited?

From the documentation, that does not seem to be the case…

The Import XZY component imports a text file to a df list that has topographic data stored as a list of x, y, and z values separated by whitespace characters. Each point should start at a new line.

docofossor/DOCUMENTATION.md at master · dbt-ethz/docofossor · GitHub

That would be easy enough to test. Open the xyz file in Notepad and replace spaces with a comma.
-wim

This is also a simple way in grasshopper :grinning:
comma delimitation.gh (4.7 KB)

1 Like

Doesn’t work. I copied the data in a notepad file, saved it as xyz and still getting error.

3RD_DEC_TEST FILE.XYZ (143.4 KB)

WIth mesh, comma delimitation.gh (177.0 KB)

Hello,

The error seems to be on the final line 2668 - maybe try deleting the blank line at the end and/or replacing ", " with "," (just a comma and no space)

Good luck !

Graham

2 Likes

Tried it, removed the space after commas and removed the last blank entry of 2669. Exactly the same error. Ditto. No change.

without spaces after commas_3RD_DEC_TEST FILE.XYZ (138.2 KB)

Hi @archz2,

Here’s a custom GHPython component of mine that writes a list of data strings to whatever file you specify. I’ve tested it with your file and it seems to work fine:

If you are using Rhino 5 and don’t have GHPython installed, you need to download it form food4rhino!

WIth mesh, comma delimitation 2.gh (167.1 KB)

1 Like

I think the file has to be a regular uniform grid in x and y - is that the case for your mesh?

I’ve looked up the XYZ-format that I was previously unfamiliar with on wikipedia, and it seems like it should be structured like this:

<number of atoms>
comment line
<element> <X> <Y> <Z>

Tab separation instead of commas and it needs a header containing the maximum number of items.

1 Like

I used your script to generate an xyz file. I have Rhino 6 and 7 installed.

In docofossor plugin you mean?

I’m getting the same error 2668.

3RD_DEC_TEST FILE.XYZ (143.4 KB)

No, I meant that I tested my GHPython component with your Grasshopper file.

Yes, as I mentioned in my previous comment, XYZ-files probably need to be formatted like this:

<number of atoms>
comment line
<element> <X> <Y> <Z>

I’ve quickly added another GHPython component that parses the XYZ-file information,

I don’t know if it works with docofossor, since I don’t have that add-on, however the new output looks promising:

Screenshot 2020-12-04 at 08.31.11

WIth mesh, comma delimitation 3.gh (170.2 KB)

1 Like

Hello again,

Yes I’m afraid it does need to be a regular grid - your grid is not regular. See the comments and questions on the docofossor page:

1 Like

Thanks. This time is error is different.


dfCutFillInPath.gh (9.3 KB)

How do I convert my mesh into a regular grid xyz file?

Sorry, I have no clue, but I guess it was worth a shot.

1 Like

It was indeed. I’m grateful for your efforts. I think from having a 100% error file, now the error is reduced to just 1% that’s causing trouble. Just a gut feeling.

1 Like