Skip to content

Commit

Permalink
make handling more user-friendly if Sketch is outside of Body object
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 6, 2019
1 parent 0136445 commit 1a8d3a7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Mod/PartDesign/Gui/Command.cpp
Expand Up @@ -911,10 +911,16 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which,
auto* pcActiveBody = PartDesignGui::getBody(false);
if (pcActiveBody && !bNoSketchWasSelected && extReference) {

auto* pcActivePart = PartDesignGui::getPartFor(pcActiveBody, true);
// getPartFor() already has reported an error
if (!pcActivePart)
return;
// Hint: In an older version the function expected the body to be inside
// a Part container and if not an error was raised and the function aborted.
// First of all, for the user this wasn't obvious because the error message
// was quite confusing (and thus the user may have done the wrong thing since
// he may have assumed the that the sketch was meant) and second there is no need
// that the body must be inside a Part container.
// For more details see: https://forum.freecadweb.org/viewtopic.php?f=19&t=32164
// The function has been modified not to expect the body to be in the Part
// and it now directly invokes the 'makeCopy' dialog.
auto* pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);

QDialog dia(Gui::getMainWindow());
PartDesignGui::Ui_DlgReference dlg;
Expand All @@ -930,7 +936,7 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which,
auto oBody = PartDesignGui::getBodyFor(sketches[0], false);
if (oBody)
pcActiveBody->addObject(copy);
else
else if (pcActivePart)
pcActivePart->addObject(copy);

sketches[0] = copy;
Expand Down

0 comments on commit 1a8d3a7

Please sign in to comment.