Skip to content

Commit

Permalink
PartDesign: allow making new ProfileBased feature using multiple faces
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed Mar 20, 2020
1 parent 4dd16c5 commit 509cbfa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Mod/PartDesign/Gui/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ unsigned validateSketches(std::vector<App::DocumentObject*>& sketches,
void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, const std::string& which,
boost::function<void (Part::Feature*, App::DocumentObject*)> func)
{
auto base_worker = [=](App::DocumentObject* feature, std::string sub) {
auto base_worker = [=](App::DocumentObject* feature, const std::vector<string> &subs) {

if (!feature || !feature->isDerivedFrom(Part::Feature::getClassTypeId()))
return;
Expand All @@ -1022,20 +1022,23 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
auto Feat = pcActiveBody->getDocument()->getObject(FeatName.c_str());

auto objCmd = Gui::Command::getObjectCmd(feature);
if (feature->isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
if (feature->isDerivedFrom(Part::Part2DObject::getClassTypeId()) || subs.empty()) {
FCMD_OBJ_CMD(Feat,"Profile = " << objCmd);
}
else {
FCMD_OBJ_CMD(Feat,"Profile = (" << objCmd << ", ['" << sub << "'])");
std::ostringstream ss;
for(auto &s : subs)
ss << "'" << s << "',";
FCMD_OBJ_CMD(Feat,"Profile = (" << objCmd << ", [" << ss.str() << "])");
}

func(static_cast<Part::Feature*>(feature), Feat);
};

//if a profile is selected we can make our life easy and fast
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
if (!selection.empty() && selection.front().hasSubNames()) {
base_worker(selection.front().getObject(), selection.front().getSubNames().front());
if (!selection.empty()) {
base_worker(selection.front().getObject(), selection.front().getSubNames());
return;
}

Expand Down Expand Up @@ -1069,7 +1072,7 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
};

auto sketch_worker = [&, base_worker](std::vector<App::DocumentObject*> features) {
base_worker(features.front(), "");
base_worker(features.front(), {});
};

//if there is a sketch selected which is from another body or part we need to bring up the
Expand Down

0 comments on commit 509cbfa

Please sign in to comment.