diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index 4e5851c364..0143a72b81 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -192,6 +192,21 @@ private: (pcDoc->addObject("Mesh::Feature", groupName.c_str())); pcFeature->Label.setValue(groupName.c_str()); pcFeature->Mesh.swapMesh(*segm); + + // if colors are set per face + if (mat.binding == MeshCore::MeshIO::PER_FACE && + mat.diffuseColor.size() == mesh.countFacets()) { + App::PropertyColorList* prop = static_cast + (pcFeature->addDynamicProperty("App::PropertyColorList", "VertexColors")); + if (prop) { + std::vector diffuseColor; + diffuseColor.reserve(group.getIndices().size()); + for (const auto& it : group.getIndices()) { + diffuseColor.push_back(mat.diffuseColor[it]); + } + prop->setValues(diffuseColor); + } + } pcFeature->purgeTouched(); } } @@ -271,6 +286,21 @@ private: (pcDoc->addObject("Mesh::Feature", groupName.c_str())); pcFeature->Label.setValue(groupName.c_str()); pcFeature->Mesh.swapMesh(*segm); + + // if colors are set per face + if (mat.binding == MeshCore::MeshIO::PER_FACE && + mat.diffuseColor.size() == mesh.countFacets()) { + App::PropertyColorList* prop = static_cast + (pcFeature->addDynamicProperty("App::PropertyColorList", "VertexColors")); + if (prop) { + std::vector diffuseColor; + diffuseColor.reserve(group.getIndices().size()); + for (const auto& it : group.getIndices()) { + diffuseColor.push_back(mat.diffuseColor[it]); + } + prop->setValues(diffuseColor); + } + } pcFeature->purgeTouched(); } }