Mon, 01/06/2020 - 11:39
While i triangulate a shape, I explore all the faces and trying to get their colors by using XCAFDoc_ColorTool GetColor method.
Since i updated to OpenCascade 7.4.0, i cannot get colors.
Does anyone know this situation?
myAssembly->GetFreeShapes(labels);
nbS=labels.Length();
for(int i=1;i<=nbS;++i)
{
const TDF_Label& label=labels.Value(i);
myAssembly->GetShape(label,shape);
Triangulate(shape);
}
Handle(XCAFDoc_ColorTool) colors;
Quantity_Color color;
TopoDS_Face face=TopoDS::Face(explorer.current());
if(colors->GetColor(face,XCAfDoc_ColorGen,color)||colors->GetColor(face,XCAfDoc_ColorSurf,color)||colors->GetColor(face,XCAfDoc_ColorCurv,color))
{
// Always it comes false
}
Mon, 01/06/2020 - 11:45
Which file format do you open?
Mon, 01/06/2020 - 11:57
Step File
Mon, 01/06/2020 - 12:16
Colors might be assigned in various ways within STEP file - iterating over shape Faces is only one place where colors might be found.
Have you tried displaying your model in Draw Harness or in CAD Assistant? Are there any colors?
XCAFPrs::CollectStyleSettings() is more reliable way to collect color information within the document.
Tue, 01/07/2020 - 10:36
thanks for your advice. I've done it.
Tue, 09/29/2020 - 09:19
I am also trying to get colors from STEP and set them to a mesh.
What I have by now is following code:
I have tested in on a STEP that I exported from Freecad with assemblies and subassemblies in it.
So for a file with just two colored cubes it works, but for subasemblies it only works for some.
So do I have to collect colorsettings somewhere else as well??
EDIT: I solved it myself. The problem was that I was looking up solids in the stylesettings which did not work, but when i loop over faces to get the color it works as expected