diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index b32b8d4f8..f0ee0b0b3 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -41,6 +41,7 @@ #include "FeatureSubtractive.h" #include "FeatureMirrored.h" #include "FeatureLinearPattern.h" +#include "FeaturePolarPattern.h" #include #include @@ -87,6 +88,16 @@ App::DocumentObject* Transformed::getSketchObject() const const LinearPattern* pattern = static_cast(this); return pattern->Direction.getValue(); } + else if (this->getTypeId().isDerivedFrom(PolarPattern::getClassTypeId())) { + // if Originals is empty then try the polar pattern's Axis property + const PolarPattern* pattern = static_cast(this); + return pattern->Axis.getValue(); + } + else if (this->getTypeId().isDerivedFrom(Mirrored::getClassTypeId())) { + // if Originals is empty then try the mirror pattern's MirrorPlane property + const Mirrored* pattern = static_cast(this); + return pattern->MirrorPlane.getValue(); + } else { return 0; } diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp index 30911452a..5d60d724d 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp @@ -429,10 +429,10 @@ bool TaskDlgLinearPatternParameters::accept() else sketch = linearpatternParameter->getSupportObject(); - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); if (sketch) { + QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])"); buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument())); - buf = buf.arg(QString::fromUtf8(direction.c_str())); + buf = buf.arg(QString::fromLatin1(direction.c_str())); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str()); } } else diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp b/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp index a2b2ff1c2..75907c15b 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp @@ -333,14 +333,19 @@ bool TaskDlgMirroredParameters::accept() TaskMirroredParameters* mirrorParameter = static_cast(parameter); std::string mirrorPlane = mirrorParameter->getMirrorPlane(); if (!mirrorPlane.empty()) { - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); + App::DocumentObject* sketch = 0; if (mirrorPlane == "H_Axis" || mirrorPlane == "V_Axis" || (mirrorPlane.size() > 4 && mirrorPlane.substr(0,4) == "Axis")) - buf = buf.arg(QString::fromUtf8(mirrorParameter->getSketchObject()->getNameInDocument())); + sketch = mirrorParameter->getSketchObject(); else - buf = buf.arg(QString::fromUtf8(mirrorParameter->getSupportObject()->getNameInDocument())); - buf = buf.arg(QString::fromUtf8(mirrorPlane.c_str())); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), buf.toStdString().c_str()); + sketch = mirrorParameter->getSupportObject(); + + if (sketch) { + QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])"); + buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument())); + buf = buf.arg(QString::fromLatin1(mirrorPlane.c_str())); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), buf.toStdString().c_str()); + } } else Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp index fffc97b7c..dc83c5542 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.cpp @@ -370,13 +370,18 @@ bool TaskDlgPolarPatternParameters::accept() TaskPolarPatternParameters* polarpatternParameter = static_cast(parameter); std::string axis = polarpatternParameter->getAxis(); if (!axis.empty()) { - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); + App::DocumentObject* sketch = 0; if (axis == "N_Axis") - buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSketchObject()->getNameInDocument())); + sketch = polarpatternParameter->getSketchObject(); else - buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSupportObject()->getNameInDocument())); - buf = buf.arg(QString::fromUtf8(axis.c_str())); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), buf.toStdString().c_str()); + sketch = polarpatternParameter->getSupportObject(); + + if (sketch) { + QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])"); + buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument())); + buf = buf.arg(QString::fromLatin1(axis.c_str())); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), buf.toStdString().c_str()); + } } else Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = None", name.c_str()); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),polarpatternParameter->getReverse());