From f8e836221c5e177c8fc2405645104829f72fa6e0 Mon Sep 17 00:00:00 2001 From: Sergo Date: Mon, 20 Feb 2017 00:58:36 -0500 Subject: [PATCH] fix pd tools from running when no active parts --- src/Mod/PartDesign/Gui/Command.cpp | 33 ++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index d16354ad8..af28798c9 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -1612,6 +1612,14 @@ CmdPartDesignMirrored::CmdPartDesignMirrored() void CmdPartDesignMirrored::activated(int iMsg) { Q_UNUSED(iMsg); + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + // No PartDesign feature without Body past FreeCAD 0.16 + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; + Gui::Command* cmd = this; auto worker = [this, cmd](std::string FeatName, std::vector features) { @@ -1666,6 +1674,14 @@ CmdPartDesignLinearPattern::CmdPartDesignLinearPattern() void CmdPartDesignLinearPattern::activated(int iMsg) { Q_UNUSED(iMsg); + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + // No PartDesign feature without Body past FreeCAD 0.16 + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; + Gui::Command* cmd = this; auto worker = [this, cmd](std::string FeatName, std::vector features) { @@ -1722,6 +1738,14 @@ CmdPartDesignPolarPattern::CmdPartDesignPolarPattern() void CmdPartDesignPolarPattern::activated(int iMsg) { Q_UNUSED(iMsg); + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + // No PartDesign feature without Body past FreeCAD 0.16 + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; + Gui::Command* cmd = this; auto worker = [this, cmd](std::string FeatName, std::vector features) { @@ -1819,8 +1843,13 @@ CmdPartDesignMultiTransform::CmdPartDesignMultiTransform() void CmdPartDesignMultiTransform::activated(int iMsg) { Q_UNUSED(iMsg); - PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */false); - //if (!pcActiveBody) return; + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + // No PartDesign feature without Body past FreeCAD 0.16 + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; std::vector features;