PLY export with color with Scalar


I want to export a vtkPolyData Dataset with “color” unsigned char[3] Point Data array as colored PLY data set. The problem is that paraview always uses the color of the lookuptable (as “MapScalars” checkbox would be activated, but isn’t).

Any ideas what to do?


Which format are you trying to export to ?

i want a format which i can import into other 3d toolkits (in my case Unity) since the vtk format is not supported from others. Ply was the only one i saw which can get exported in paraview and in Unity and has color included. I have a triangle mesh with rgb info at each node…

any suggestions?

Is the color wrong in ParaView or in Unity ? Can you share your data ?

When I save it as PLY (ASCI or binary, same results) and reload it with (same) Paraview the “color” point data array is renamed into “RGB” array and has the color values of the lookuptable, not from the “color” array

So didn’t even work for paraview

What if you uncheck “Map Scalars” ?

When i Uncheck it the coloring in visualization is correct, but it has no effect on save data/export in case of PLY

That is expected. For ParaView, the data is just data and can be represented as colors directly, or mapped through a color map, which is the default.

The state of the checkbox is not part of the .ply file.

A solution could be to use the SaveState/LoadState feature in ParaView instead of loading the .ply directly.

i dont know how saveState/LoadState would help of correctly exporting color into a fileformat which can be read by other 3d toolkits? can you explain this a little bit deeper?

When you Open/Save data, ParaView only read/write the data, not the way it has to be represented.

You know that the 3 component vector on your data is actually RGB, but ParaView doesn’t know that, as it could be a velocity vector or a YUV color.

So ParaView uses its default color map representation to represent it.

When you save/load state, paraview save/load the entire state of the application, which includes how the data is represented.

Here is a working workflow for you :

Do only once :

  • Create your test.ply with some tools (unity?)
  • Open your test.ply in ParaView, Apply
  • Uncheck the “Map Scalars” checkbox
  • File -> SaveState -> myState.pvsm
  • Close ParaView

Then always do :

  • Create a test2.ply with some tools (unity?)
  • Open ParaView
  • File -> LoadState -> myState.pvsm
  • Select your test2.ply in the state window, click OK

This is one solution to your problem, they are other, more complex in terms of setup but more easy in terms of usage.

I have created my dataset in Paraview/VTK. I would not need to export it if i could create my dataset in unity…

i have written an application wich is a kind of 3d scanner which is based on VTK/ITK and some other toolktis. I use paraview to edit this data set a little bit (cropping etc.). Then i want to integrate it into unity for virtual reality purposes…

So just uncheck the checkbox when you need to ?

as you already mentioned/explained the checkbox has nothing to do with export, so how should this help when i want to export data from paraview into unity?

your .ply file contains data, not actual color.
How it is represented is down to ParaView, unity, or any other tools you implement.

Did you try opening your .ply with unity to see how it is represented ?

when a vertex node of my trianlge with “color” 50,50,50 is stored as “rgb” 75,90,45, as i see it when i reload the PLY data into paraview using SpreadSheetView, then i do not need to test… how should unity know that 75,90,45 is 50,50,50 in RGB?

Not following here, why would 50,50,50 be changed to 75,90,45, how do you see it ? please share your data.

becaue of the lookuptable mapping of paraview (as you see it in visualization when MapScalars is True)

SmallSubset.vtk (140.2 KB)

Problem description: Convert “SmallSubset.vtk” to “SmallSubset.ply” with correct color data

Steps to reproduce:

  1. Open Paraview
  2. Open SmallSubset.vtk
  3. Disaple “MapScalars” => Data is rendered correctly
  4. Select and press SaveData
  5. Set FileName SmallSubset.ply
  6. Set Enable Coloring
  7. Save
  8. Import SmallSubset.ply
  9. Try getting same vis as in 3, not possible anymore because paraview stored lookuptable data from visualisation and not the raw data

I’m sorry, there is indeed a bug in the .ply Reader, it does not consider the “Map Scalars” checkbox. Thanks for your patience.

I will check for another solution to your usecase.