Cannot import PLY file generated by Rhinos3D 6.0 #78278

Closed
opened 2020-06-25 23:48:18 +02:00 by Ferdy Mercury · 17 comments

System Information
Operating system: Ubuntu 18
Graphics card: Integrated Intel

Blender Version
Broken: 2.79b

Short description of error
Blender can not open a PLY file exported from Rhinos 6.0. Here the file: https://github.com/cnr-isti-vclab/meshlab/files/3330082/Box.ply.zip

When run through console, it reports:

Invalid header ('end_header' line not found!)
Invalid file

I checked with a hex editor, and the end_header line is there. Maybe there is a problem with carriage return vs newline?

Exact steps for others to reproduce the error
Open Blender from a terminal/console. Import into Blender the file linked above. Check the output in the terminal.

Related:
https://github.com/cnr-isti-vclab/meshlab/issues/463
https://github.com/google/draco/issues/613

**System Information** Operating system: Ubuntu 18 Graphics card: Integrated Intel **Blender Version** Broken: 2.79b **Short description of error** Blender can not open a PLY file exported from Rhinos 6.0. Here the file: https://github.com/cnr-isti-vclab/meshlab/files/3330082/Box.ply.zip When run through console, it reports: ``` Invalid header ('end_header' line not found!) Invalid file ``` I checked with a hex editor, and the end_header line is there. Maybe there is a problem with carriage return vs newline? **Exact steps for others to reproduce the error** Open Blender from a terminal/console. Import into Blender the file linked above. Check the output in the terminal. Related: https://github.com/cnr-isti-vclab/meshlab/issues/463 https://github.com/google/draco/issues/613
Author

Added subscriber: @ferdymercury

Added subscriber: @ferdymercury
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Will confirm for now, apparently there is an issue with line termination, yes.
Not sure if it is against the specs, but using line in plyf [plyf is open(filepath, 'rb')] will not separate lines properly.
Tried using plyf.read().splitlines() - that separates them properly - but has issues later on.
Needs more investigation...

Will confirm for now, apparently there is an issue with line termination, yes. Not sure if it is against the specs, but using `line in plyf` [plyf is open(filepath, 'rb')] will not separate lines properly. Tried using `plyf.read().splitlines()` - that separates them properly - but has issues later on. Needs more investigation...
Author

Thanks. In case it helps, Meshlab uses the following chars as possible separators:
" \t\n\r"

a8e87662b6/wrap/ply/plylib.cpp (L987)

Thanks. In case it helps, Meshlab uses the following chars as possible separators: " \t\n\r" https://github.com/cnr-isti-vclab/vcglib/blob/a8e87662b63ee9f4ded5d4699b28d74183040803/wrap/ply/plylib.cpp#L987
Member

Added subscriber: @jesterking

Added subscriber: @jesterking
Member

FWIW: current stable version of Rhino is v6 (SR 27 I believe).

Importing the PLY file into Rhino v6, then re-exporting as PLY, then importing in Blender works just fine. Also an export from a clean Rhino file (with just that a box) work just fine.

Even a complex model exported as PLY with Rhino 6 imports fine in Blender (2.83.1)

box_v6.ply

box_from_v3_reexported.ply

image.png

FWIW: current stable version of Rhino is v6 (SR 27 I believe). Importing the PLY file into Rhino v6, then re-exporting as PLY, then importing in Blender works just fine. Also an export from a clean Rhino file (with just that a box) work just fine. Even a complex model exported as PLY with Rhino 6 imports fine in Blender (2.83.1) [box_v6.ply](https://archive.blender.org/developer/F8645506/box_v6.ply) [box_from_v3_reexported.ply](https://archive.blender.org/developer/F8645507/box_from_v3_reexported.ply) ![image.png](https://archive.blender.org/developer/F8645508/image.png)
Author

Thanks. The files you provided are in ASCII format, whereas the original one is in binary format. Can you see if you can select the export option as binary in 6? Otherwise we do not know if the bug is still there in 6.0. Thanks!

Thanks. The files you provided are in ASCII format, whereas the original one is in binary format. Can you see if you can select the export option as binary in 6? Otherwise we do not know if the bug is still there in 6.0. Thanks!
Member

Right, binary format indeed fails.

Upon a bit further inspection it turns out the PLY file you provided is exported with Rhino 6.

So binary PLY also fails in 2.83.1

Right, binary format indeed fails. Upon a bit further inspection it turns out the PLY file you provided is exported with Rhino 6. So binary PLY also fails in 2.83.1

Added subscriber: @rjg

Added subscriber: @rjg

This comment was removed by @rjg

*This comment was removed by @rjg*
Ferdy Mercury changed title from Cannot import PLY file generated by Rhinos 3.0 to Cannot import PLY file generated by Rhinos 6.0 2020-06-27 21:57:07 +02:00
Ferdy Mercury changed title from Cannot import PLY file generated by Rhinos 6.0 to Cannot import PLY file generated by Rhinos3D 6.0 2020-06-27 21:58:14 +02:00
Author

Thanks Nathan. Sorry, I had a mind shortcut and transformed Rhinos3D 6.0 to Rhinos 3.0. Indeed, it is Rhinos 6.0 the original file.

Thanks Nathan. Sorry, I had a mind shortcut and transformed Rhinos3D 6.0 to Rhinos 3.0. Indeed, it is Rhinos 6.0 the original file.
Author

Concerning line endings:

https://www.graphics.rwth-aachen.de/media/openmesh_static/Documentations/OpenMesh-5.2-Documentation/a00002.html
https://github.com/PointCloudLibrary/pcl/issues/1256
https://github.com/dranjan/python-plyfile

Header line endings
The specification explicitly states that lines in the header must end with carriage returns, but this rule doesn't seem to be followed by anyone, including the C-language PLY implementation by Greg Turk, the author of the format. Here, we stick to common practice and output Unix-style line endings (with no carriage returns) but accept any line ending style in input files.
Concerning line endings: https://www.graphics.rwth-aachen.de/media/openmesh_static/Documentations/OpenMesh-5.2-Documentation/a00002.html https://github.com/PointCloudLibrary/pcl/issues/1256 https://github.com/dranjan/python-plyfile ``` Header line endings The specification explicitly states that lines in the header must end with carriage returns, but this rule doesn't seem to be followed by anyone, including the C-language PLY implementation by Greg Turk, the author of the format. Here, we stick to common practice and output Unix-style line endings (with no carriage returns) but accept any line ending style in input files. ```

Added subscriber: @mont29

Added subscriber: @mont29

Boils down to python expecting only \n as newline char in binary files... Truing to work around the issue currently, but it's a bit tricky :|

Note that it would fail as well with a text version of it if it was not using \n as return char.

Boils down to python expecting only `\n` as newline char in binary files... Truing to work around the issue currently, but it's a bit tricky :| Note that it would fail as well with a text version of it if it was not using `\n` as return char.
Bastien Montagne self-assigned this 2020-08-06 16:58:53 +02:00

This issue was referenced by 04c0573ee7

This issue was referenced by 04c0573ee77cc955cf585a0d7a61163375eb57cd

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#78278
No description provided.