diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 298d8dd25..a5960aea5 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -930,13 +930,27 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName, const b const unsigned validateSketches(std::vector& sketches, std::vector& status, std::vector::iterator& firstValidSketch) -{ +{ + PartDesign::Body* pcActiveBody = PartDesignGui::getBody(false); + App::Part* pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false); + // TODO: If the user previously opted to allow multiple use of sketches or use of sketches from other bodies, // then count these as valid sketches! unsigned validSketches = 0; firstValidSketch = sketches.end(); for (std::vector::iterator s = sketches.begin(); s != sketches.end(); s++) { + + // Check whether this plane belongs to the active body + if (!pcActiveBody->hasFeature(*s)) { + if(pcActivePart->hasObject(*s, true)) + status.push_back(PartDesignGui::TaskFeaturePick::otherBody); + else + status.push_back(PartDesignGui::TaskFeaturePick::otherPart); + + continue; + } + //Base::Console().Error("Checking sketch %s\n", (*s)->getNameInDocument()); // Check whether this sketch is already being used by another feature // Body features don't count... @@ -955,11 +969,9 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName, const b status.push_back(PartDesignGui::TaskFeaturePick::isUsed); continue; } - - // Check whether this sketch belongs to the active body - PartDesign::Body* body = PartDesignGui::getBody(/*messageIfNot = */false); - if (!body->hasFeature(*s)) { - status.push_back(PartDesignGui::TaskFeaturePick::otherBody); + + if (pcActiveBody->isAfterTip(*s)){ + status.push_back(PartDesignGui::TaskFeaturePick::afterTip); continue; } diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index e93a26118..8691c8394 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -229,7 +229,7 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, bool in //we do know that the created instance is a document object, as obj is one. But we do not know which //exact type - auto name = App::GetApplication().getActiveDocument()->getUniqueObjectName(obj->getNameInDocument()); + auto name = std::string("Copy") + std::string(obj->getNameInDocument()); auto copy = App::GetApplication().getActiveDocument()->addObject(obj->getTypeId().getName(), name.c_str()); if(copy) { @@ -237,7 +237,7 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, bool in std::vector props; std::vector cprops; obj->getPropertyList(props); - obj->getPropertyList(cprops); + copy->getPropertyList(cprops); try{ auto it = cprops.begin(); for( App::Property* prop : props ) { @@ -253,21 +253,15 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, bool in ++it; continue; } - - Base::StringWriter writer; - //the properties xml tag is often not correctly cosed and only has "". This leads - //to a end of document exception. To prevent this we add a dummy tag arround. - writer.Stream() << writer.ind() << "" << std::endl; - writer.ind(); - prop->Save(writer); - writer.decInd(); - writer.Stream() << writer.ind() << "" << std::endl; - std::stringstream stream(writer.getString()); - Base::XMLReader reader("test", stream); - reader.readElement("Prop"); App::Property* cprop = *it++; - cprop->Restore(reader); + + if( strcmp(prop->getName(), "Label") == 0 ) { + static_cast(cprop)->setValue("wuhahahahah"); + continue; + } + + cprop->Paste(*prop); } } catch(const Base::Exception& e) {