How to export the color of actor to OBJ model by vtkOBJWriter correctly

I can’t export the color of an actor(without texture, only single color) to OBJ model. The mesh and geometry of OBJ model is correct. But its color is always white instead of its own color. The color is white in many other 3D software, also in my app using vtkOBJReader. I can not find .mtl file or any other material file exported. How can I solve the problem. Thanks in advance.

I use VTK 8.2.0. This is the part of my source code for exporting OBJ models:

vtkSmartPointer<vtkOBJWriter> objWriter = vtkSmartPointer<vtkOBJWriter>::New();
objWriter->SetFileName(filePath.toUtf8().toStdString().c_str());
objWriter->SetInputData(actor->GetMapper()->GetInput());
objWriter->Write();

vtkOBJWriter takes vtkPolyData as input and has no idea about any display settings that you set in actors. It does not even have access to any of the actors or actor properties.

To export OBJ file with colors, you need to use vtkOBJExporter, which takes a render window as input.

Hi, Andras, I want to know when I use vtkOBJExporter, I can get the actor and mapper, and polydata.
Issue 1:But when I want to get the every point’s color(the rgb in the position of point), it can not work. It seem like that I should get the textmap data, then use linear interpolation to get the point’s color.
Can you help me?

Issue 2:When I use the ID of cell of the vtkOBJExporter’s polydata to delet some cells, it works well, but when I try to use the vtkLookupTable(),vtkIntArray() to set the color of cells(polyData.GetCellData().SetScalars), it does not work. What I want is like the geomatic, when I choose some cells, the cell will be red and its original text color.

Thank you.

@yangyang117 I don’t see how your questions are related to vtkOBJWriter. Instead of reviwing a very old topic with a seemingly unrelated question, please submit a new topic. Make sure to give very detailed description instead of just writing “it can not work” or “it does not work”: what did you do (provide minimum reproducing example - code snippet and input data), what you expected to happen, and what happened instead?

Hi, I have write a new topic, but I cannot found it in the lastest tops. here is the link:

thank you