don't allow to set empty list of bodies for boolean operations

don't update the body feature if boolean body list is empty
This commit is contained in:
wmayer
2018-03-15 12:05:13 +01:00
parent 03ce0f276e
commit bbbbf6c691
2 changed files with 16 additions and 3 deletions

View File

@@ -678,7 +678,9 @@ bool CmdPartDesignNewSketch::isActive(void)
//===========================================================================
void finishFeature(const Gui::Command* cmd, const std::string& FeatName,
App::DocumentObject* prevSolidFeature = nullptr, const bool hidePrevSolid = true)
App::DocumentObject* prevSolidFeature = nullptr,
const bool hidePrevSolid = true,
const bool updateDocument = true)
{
PartDesign::Body *pcActiveBody;
@@ -691,7 +693,9 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName,
if (hidePrevSolid && prevSolidFeature && (prevSolidFeature != NULL))
cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", prevSolidFeature->getNameInDocument());
cmd->updateActive();
if (updateDocument)
cmd->updateActive();
// #0001721: use '0' as edit value to avoid switching off selection in
// ViewProviderGeometryObject::setEditViewer
cmd->doCommand(cmd->Gui,"Gui.activeDocument().setEdit('%s', 0)", FeatName.c_str());
@@ -2186,6 +2190,9 @@ void CmdPartDesignBoolean::activated(int iMsg)
std::string FeatName = getUniqueObjectName("Boolean");
doCommand(Doc,"App.activeDocument().%s.newObject('PartDesign::Boolean','%s')", pcActiveBody->getNameInDocument(), FeatName.c_str());
// If we don't add an object to the boolean group then don't update the body
// as otherwise this will fail and it will be marked as invalid
bool updateDocument = false;
if (BodyFilter.match() && !BodyFilter.Result.empty()) {
std::vector<App::DocumentObject*> bodies;
std::vector<std::vector<Gui::SelectionObject> >::iterator i = BodyFilter.Result.begin();
@@ -2197,12 +2204,13 @@ void CmdPartDesignBoolean::activated(int iMsg)
}
if (!bodies.empty()) {
updateDocument = true;
std::string bodyString = PartDesignGui::buildLinkListPythonStr(bodies);
doCommand(Doc,"App.activeDocument().%s.addObjects(%s)",FeatName.c_str(),bodyString.c_str());
}
}
finishFeature(this, FeatName, nullptr, false);
finishFeature(this, FeatName, nullptr, false, updateDocument);
}
bool CmdPartDesignBoolean::isActive(void)

View File

@@ -322,6 +322,11 @@ bool TaskDlgBooleanParameters::accept()
try {
std::vector<std::string> bodies = parameter->getBodies();
if (bodies.empty()) {
QMessageBox::warning(parameter, tr("Empty body list"),
tr("The body list cannot be empty"));
return false;
}
std::stringstream str;
str << "App.ActiveDocument." << name.c_str() << ".setObjects( [";
for (std::vector<std::string>::const_iterator it = bodies.begin(); it != bodies.end(); ++it)