fix body booleans

This commit is contained in:
Stefan Tröger 2015-08-08 15:08:35 +02:00
parent 585e4cebb5
commit e7a96ac26f

View File

@ -1839,37 +1839,28 @@ CmdPartDesignBoolean::CmdPartDesignBoolean()
void CmdPartDesignBoolean::activated(int iMsg) void CmdPartDesignBoolean::activated(int iMsg)
{ {
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
if (!pcActiveBody) return;
Gui::SelectionFilter BodyFilter("SELECT PartDesign::Body COUNT 1.."); Gui::SelectionFilter BodyFilter("SELECT PartDesign::Body COUNT 1..");
PartDesign::Body* body; PartDesign::Body* body = nullptr;
std::string bodyString(""); std::string bodyString("");
if (BodyFilter.match()) { if (BodyFilter.match()) {
body = static_cast<PartDesign::Body*>(BodyFilter.Result[0][0].getObject()); body = static_cast<PartDesign::Body*>(BodyFilter.Result[0][0].getObject());
std::vector<App::DocumentObject*> bodies; std::vector<App::DocumentObject*> bodies;
std::vector<std::vector<Gui::SelectionObject> >::iterator i = BodyFilter.Result.begin(); std::vector<std::vector<Gui::SelectionObject> >::iterator i = BodyFilter.Result.begin();
i++;
for (; i != BodyFilter.Result.end(); i++) { for (; i != BodyFilter.Result.end(); i++) {
for (std::vector<Gui::SelectionObject>::iterator j = i->begin(); j != i->end(); j++) { for (std::vector<Gui::SelectionObject>::iterator j = i->begin(); j != i->end(); j++) {
bodies.push_back(j->getObject()); if(j->getObject() != pcActiveBody)
bodies.push_back(j->getObject());
} }
} }
bodyString = PartDesignGui::buildLinkListPythonStr(bodies); bodyString = PartDesignGui::buildLinkListPythonStr(bodies);
} else {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No body selected"),
QObject::tr("Please select a body for the boolean operation"));
return;
} }
openCommand("Create Boolean"); openCommand("Create Boolean");
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
// Make sure we are working on the selected body
if (body != activeBody) {
Gui::Selection().clearSelection();
Gui::Selection().addSelection(body->getDocument()->getName(), body->Tip.getValue()->getNameInDocument());
Gui::Command::doCommand(Gui::Command::Gui,"FreeCADGui.runCommand('PartDesign_MoveTip')");
}
std::string FeatName = getUniqueObjectName("Boolean"); std::string FeatName = getUniqueObjectName("Boolean");
doCommand(Doc,"App.activeDocument().addObject('PartDesign::Boolean','%s')",FeatName.c_str()); doCommand(Doc,"App.activeDocument().addObject('PartDesign::Boolean','%s')",FeatName.c_str());