From dd1403332902d0388d153c49bed41ac907ccab26 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 24 Dec 2025 19:48:36 -0600 Subject: [PATCH] PD: For Body get the color from the tip Mostly affects STEP export. --- src/Mod/PartDesign/Gui/ViewProviderBody.cpp | 15 +++++++++++++++ src/Mod/PartDesign/Gui/ViewProviderBody.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index 7b2fcdce2b..e99151ac83 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -349,6 +349,21 @@ void ViewProviderBody::unifyVisualProperty(const App::Property* prop) } } +std::map ViewProviderBody::getElementColors(const char* element) const +{ + // A PartDesign Body doesn't really have element colors on its own: it's a sort of container, + // and its subshapes are the ones that have actual colors. If you query a body's ViewProvider + // for its element colors, what you are really asking for is the element colors of its tip. + PartDesign::Body* body = static_cast(getObject()); + if (App::DocumentObject* tip = body->Tip.getValue()) { + Gui::Document* guiDoc = Gui::Application::Instance->getDocument(tip->getDocument()); + Gui::ViewProvider* vp = guiDoc->getViewProvider(tip); + return vp->getElementColors(element); + } + return ViewProviderPart::getElementColors(element); +} + + void ViewProviderBody::setVisualBodyMode(bool bodymode) { diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.h b/src/Mod/PartDesign/Gui/ViewProviderBody.h index 0c516b9032..4c3d2594b1 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.h +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.h @@ -97,6 +97,9 @@ public: return true; }; + /// Override to return the color of the tip instead of the body, which doesn't really have color + std::map getElementColors(const char* element) const override; + protected: /// Copy over all visual properties to the child features void unifyVisualProperty(const App::Property* prop);