diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp
index a6e3f987b..1ba15e590 100644
--- a/src/Mod/PartDesign/Gui/Command.cpp
+++ b/src/Mod/PartDesign/Gui/Command.cpp
@@ -884,11 +884,12 @@ void CmdPartDesignPad::activated(int iMsg)
{
Q_UNUSED(iMsg);
App::Document *doc = getDocument();
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(
- /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc));
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
- // No PartDesign feature without Body past FreeCAD 0.16
- if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc))
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
+
+ if (!pcActiveBody)
return;
Gui::Command* cmd = this;
@@ -942,11 +943,12 @@ void CmdPartDesignPocket::activated(int iMsg)
{
Q_UNUSED(iMsg);
App::Document *doc = getDocument();
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(
- /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc));
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
- // No PartDesign feature without Body past FreeCAD 0.16
- if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc))
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
+
+ if (!pcActiveBody)
return;
Gui::Command* cmd = this;
@@ -988,11 +990,12 @@ void CmdPartDesignRevolution::activated(int iMsg)
{
Q_UNUSED(iMsg);
App::Document *doc = getDocument();
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(
- /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc));
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
- // No PartDesign feature without Body past FreeCAD 0.16
- if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc))
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
+
+ if (!pcActiveBody)
return;
Gui::Command* cmd = this;
@@ -1040,10 +1043,12 @@ void CmdPartDesignGroove::activated(int iMsg)
{
Q_UNUSED(iMsg);
App::Document *doc = getDocument();
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(
- /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc));
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
- if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc))
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
+
+ if (!pcActiveBody)
return;
Gui::Command* cmd = this;
@@ -1090,9 +1095,12 @@ CmdPartDesignAdditivePipe::CmdPartDesignAdditivePipe()
void CmdPartDesignAdditivePipe::activated(int iMsg)
{
Q_UNUSED(iMsg);
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true);
+ App::Document *doc = getDocument();
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
+
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
- // No PartDesign feature without Body past FreeCAD 0.13
if (!pcActiveBody)
return;
@@ -1137,9 +1145,12 @@ CmdPartDesignSubtractivePipe::CmdPartDesignSubtractivePipe()
void CmdPartDesignSubtractivePipe::activated(int iMsg)
{
Q_UNUSED(iMsg);
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true);
+ App::Document *doc = getDocument();
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
+
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
- // No PartDesign feature without Body past FreeCAD 0.13
if (!pcActiveBody)
return;
@@ -1184,9 +1195,12 @@ CmdPartDesignAdditiveLoft::CmdPartDesignAdditiveLoft()
void CmdPartDesignAdditiveLoft::activated(int iMsg)
{
Q_UNUSED(iMsg);
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true);
+ App::Document *doc = getDocument();
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
+
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
- // No PartDesign feature without Body past FreeCAD 0.13
if (!pcActiveBody)
return;
@@ -1231,9 +1245,12 @@ CmdPartDesignSubtractiveLoft::CmdPartDesignSubtractiveLoft()
void CmdPartDesignSubtractiveLoft::activated(int iMsg)
{
Q_UNUSED(iMsg);
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true);
+ App::Document *doc = getDocument();
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
+
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
- // No PartDesign feature without Body past FreeCAD 0.13
if (!pcActiveBody)
return;
@@ -1596,7 +1613,18 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which,
return;
}
}
+ else if (features.size() > 1) {
+ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Multiple Features Selected"),
+ QObject::tr("Please select only one subtractive or additive feature first."));
+ return;
+ }
else {
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
+ if (pcActiveBody != PartDesignGui::getBodyFor(features[0], false)) {
+ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection is not in Active Body"),
+ QObject::tr("Please select only one subtractive or additive feature in an active body."));
+ return;
+ }
worker(features);
}
}
diff --git a/src/Mod/PartDesign/Gui/CommandPrimitive.cpp b/src/Mod/PartDesign/Gui/CommandPrimitive.cpp
index feccacc70..e470191d1 100644
--- a/src/Mod/PartDesign/Gui/CommandPrimitive.cpp
+++ b/src/Mod/PartDesign/Gui/CommandPrimitive.cpp
@@ -40,6 +40,7 @@
#include
#include "Utils.h"
+#include "WorkflowManager.h"
using namespace std;
@@ -59,9 +60,14 @@ CmdPrimtiveCompAdditive::CmdPrimtiveCompAdditive()
void CmdPrimtiveCompAdditive::activated(int iMsg)
{
+ App::Document *doc = getDocument();
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
- if (!pcActiveBody) return;
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
+
+ if (!pcActiveBody)
+ return;
Gui::ActionGroup* pcAction = qobject_cast(_pcAction);
pcAction->setIcon(pcAction->actions().at(iMsg)->icon());
@@ -241,8 +247,14 @@ CmdPrimtiveCompSubtractive::CmdPrimtiveCompSubtractive()
void CmdPrimtiveCompSubtractive::activated(int iMsg)
{
- PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
- if (!pcActiveBody) return;
+ App::Document *doc = getDocument();
+ if (!PartDesignGui::assureModernWorkflow(doc))
+ return;
+
+ PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
+
+ if (!pcActiveBody)
+ return;
Gui::ActionGroup* pcAction = qobject_cast(_pcAction);
pcAction->setIcon(pcAction->actions().at(iMsg)->icon());