diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index fa274046e0..57ce0be34a 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -25,6 +25,8 @@ #define WNT // avoid conflict with GUID #endif #ifndef _PreComp_ +#include +#include #include #if defined(__clang__) #pragma clang diagnostic push @@ -306,7 +308,20 @@ private: Handle(TDocStd_Document) hDoc; hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc); - Import::ExportOCAF2 ocaf(hDoc); + auto getShapeColors = [partColor](App::DocumentObject* obj, const char* subname) { + std::map cols; + auto it = partColor.find(dynamic_cast(obj)); + if (it != partColor.end() && boost::starts_with(subname, "Face")) { + const auto& colors = it->second; + std::string face("Face"); + for (const auto& element : colors | boost::adaptors::indexed(1)) { + cols[face + std::to_string(element.index())] = element.value(); + } + } + return cols; + }; + + Import::ExportOCAF2 ocaf(hDoc, getShapeColors); if (!legacyExport || !ocaf.canFallback(objs)) { ocaf.setExportOptions(ExportOCAF2::customExportOptions()); ocaf.setExportHiddenObject(exportHidden); diff --git a/src/Mod/Import/App/PreCompiled.h b/src/Mod/Import/App/PreCompiled.h index 1f00597316..0343a3c77b 100644 --- a/src/Mod/Import/App/PreCompiled.h +++ b/src/Mod/Import/App/PreCompiled.h @@ -49,6 +49,10 @@ #include #include +// boost +#include +#include + // OpenCasCade ===================================================================================== // Base #include