harmonize creation of linear pattern inside a multi transform to direction creation of linear pattern

This commit is contained in:
wmayer
2017-09-29 23:57:31 +02:00
parent 2244292552
commit 5a1a88568a
3 changed files with 21 additions and 4 deletions

View File

@@ -1673,7 +1673,9 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which,
}
str << "]";
Gui::Command::openCommand((std::string("Make ") + which + " feature").c_str());
std::string msg("Make ");
msg += which;
Gui::Command::openCommand(msg.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject(\"PartDesign::%s\",\"%s\")",
PartDesignGui::getBody(false)->getNameInDocument(), which.c_str(), FeatName.c_str());
// FIXME: There seems to be kind of a race condition here, leading to sporadic errors like

View File

@@ -199,7 +199,8 @@ void TaskLinearPatternParameters::updateUI()
if (dirLinks.setCurrentLink(pcLinearPattern->Direction) == -1){
//failed to set current, because the link isn't in the list yet
dirLinks.addLink(pcLinearPattern->Direction, getRefStr(pcLinearPattern->Direction.getValue(),pcLinearPattern->Direction.getSubValues()));
dirLinks.addLink(pcLinearPattern->Direction, getRefStr(pcLinearPattern->Direction.getValue(),
pcLinearPattern->Direction.getSubValues()));
dirLinks.setCurrentLink(pcLinearPattern->Direction);
}

View File

@@ -36,6 +36,7 @@
#include "Utils.h"
#include <App/Application.h>
#include <App/Document.h>
#include <App/Origin.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@@ -281,17 +282,30 @@ void TaskMultiTransformParameters::onTransformAddMirrored()
void TaskMultiTransformParameters::onTransformAddLinearPattern()
{
// See CmdPartDesignLinearPattern
//
closeSubTask();
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("LinearPattern");
Gui::Command::openCommand("LinearPattern");
Gui::Command::openCommand("Make LinearPattern");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject(\"PartDesign::LinearPattern\",\"%s\")",
PartDesignGui::getBody(false)->getNameInDocument(), newFeatName.c_str());
//Gui::Command::updateActive();
App::DocumentObject* sketch = getSketchObject();
if (sketch)
if (sketch) {
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"H_Axis\"])",
newFeatName.c_str(), sketch->getNameInDocument());
}
else {
// set Direction value before filling up the combo box to avoid creating an empty item
// inside updateUI()
PartDesign::Body* body = static_cast<PartDesign::Body*>(Part::BodyBase::findBodyOf(getObject()));
if (body) {
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"\"])",
newFeatName.c_str(), body->getOrigin()->getX()->getNameInDocument());
}
}
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Length = 100", newFeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str());