diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index d3ceff6740..80b43bb852 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -870,6 +870,14 @@ CmdPartDesignPad::CmdPartDesignPad() void CmdPartDesignPad::activated(int 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 = [cmd](Part::Feature* profile, std::string FeatName) { @@ -919,6 +927,14 @@ CmdPartDesignPocket::CmdPartDesignPocket() void CmdPartDesignPocket::activated(int 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 = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -956,6 +972,14 @@ CmdPartDesignRevolution::CmdPartDesignRevolution() void CmdPartDesignRevolution::activated(int 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 = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -999,6 +1023,13 @@ CmdPartDesignGroove::CmdPartDesignGroove() void CmdPartDesignGroove::activated(int iMsg) { + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -1042,6 +1073,12 @@ CmdPartDesignAdditivePipe::CmdPartDesignAdditivePipe() void CmdPartDesignAdditivePipe::activated(int iMsg) { + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true); + + // No PartDesign feature without Body past FreeCAD 0.13 + if (!pcActiveBody) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -1082,6 +1119,12 @@ CmdPartDesignSubtractivePipe::CmdPartDesignSubtractivePipe() void CmdPartDesignSubtractivePipe::activated(int iMsg) { + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true); + + // No PartDesign feature without Body past FreeCAD 0.13 + if (!pcActiveBody) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -1122,6 +1165,12 @@ CmdPartDesignAdditiveLoft::CmdPartDesignAdditiveLoft() void CmdPartDesignAdditiveLoft::activated(int iMsg) { + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true); + + // No PartDesign feature without Body past FreeCAD 0.13 + if (!pcActiveBody) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -1162,6 +1211,12 @@ CmdPartDesignSubtractiveLoft::CmdPartDesignSubtractiveLoft() void CmdPartDesignSubtractiveLoft::activated(int iMsg) { + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true); + + // No PartDesign feature without Body past FreeCAD 0.13 + if (!pcActiveBody) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) {