diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index aadf35436..68c887592 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -737,6 +737,9 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which, auto worker = [which, cmd, func](std::vector features) { + if(features.empty()) + return; + auto firstValidSketch = features.begin(); Part::Part2DObject* sketch = static_cast(*firstValidSketch); @@ -819,7 +822,11 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which, } else { std::vector theSketch; - theSketch.push_back(*firstFreeSketch); + if(!bNoSketchWasSelected) + theSketch.push_back(sketches[0]); + else + theSketch.push_back(*firstFreeSketch); + worker(theSketch); } diff --git a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp index ef0d11bac..8c9f04121 100644 --- a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp @@ -28,6 +28,7 @@ # include # include # include +#include #endif #include @@ -47,6 +48,8 @@ #include "Utils.h" #include "ReferenceSelection.h" +#include "TaskFeaturePick.h" +#include using namespace PartDesignGui; using namespace Gui; @@ -174,11 +177,47 @@ void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::Selec { if (strcmp(thisObj->getDocument()->getName(), msg.pDocName) != 0) return; - + selObj = thisObj->getDocument()->getObject(msg.pObjectName); if (selObj == thisObj) return; + std::string subname = msg.pSubName; + + //check if the selection is an external reference and ask the user what to do + //of course only if thisObj is in a body, as otherwise the old workflow would not + //be supportet + PartDesign::Body* body = PartDesignGui::getBodyFor(thisObj, false); + if(body) { + PartDesign::Body* selBody = PartDesignGui::getBodyFor(selObj, false); + if(!selBody || body != selBody) { + + auto* pcActivePart = PartDesignGui::getPartFor(body, false); + + QDialog* dia = new QDialog; + Ui_Dialog dlg; + dlg.setupUi(dia); + dia->setModal(true); + int result = dia->exec(); + if(result == QDialog::DialogCode::Rejected) { + selObj = NULL; + return; + } + else if(!dlg.radioXRef->isChecked()) { + + auto copy = PartDesignGui::TaskFeaturePick::makeCopy(selObj, subname, dlg.radioIndependent->isChecked()); + if(selBody) + body->addFeature(copy); + else + pcActivePart->addObject(copy); + + selObj = copy; + subname.erase(std::remove_if(subname.begin(), subname.end(), &isdigit), subname.end()); + subname.append("1"); + } + + } + } // Remove subname for planes and datum features if (PartDesign::Feature::isDatum(selObj)) {