From b908e46b26ab8d251f58e6beb0f65a7b4298db65 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 31 Mar 2024 08:37:39 +0200 Subject: [PATCH] PD: Mirror feature should be more permissive If you have a mirror feature and set the mirror plane with the normal feature editing the recompute works. But if the mirror plane is set with the property editor then the recompute fails with the message that no mirror plane reference is set. This is related to a an empty sub-name list of the link property instead of a single and empty sub-name element. This PR allows to specify a sketch, plane or datum plane without a sub-name. For more details see: https://forum.freecad.org/viewtopic.php?t=86568 This fixes #13238 --- src/Mod/PartDesign/App/FeatureMirrored.cpp | 18 ++++++++++-------- src/Mod/PartDesign/App/FeatureTransformed.cpp | 6 +++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureMirrored.cpp b/src/Mod/PartDesign/App/FeatureMirrored.cpp index d582677fb0..9956823c68 100644 --- a/src/Mod/PartDesign/App/FeatureMirrored.cpp +++ b/src/Mod/PartDesign/App/FeatureMirrored.cpp @@ -69,15 +69,15 @@ const std::list Mirrored::getTransformations(const std::vector(refObject)) { Base::Axis axis; - if (subStrings[0] == "H_Axis") { + if (subStrings.empty() || subStrings[0].empty()) { + axis = refSketch->getAxis(Part::Part2DObject::N_Axis); + } + else if (subStrings[0] == "H_Axis") { axis = refSketch->getAxis(Part::Part2DObject::V_Axis); } else if (subStrings[0] == "V_Axis") { axis = refSketch->getAxis(Part::Part2DObject::H_Axis); } - else if (subStrings[0].empty()) { - axis = refSketch->getAxis(Part::Part2DObject::N_Axis); - } else if (subStrings[0].compare(0, 4, "Axis") == 0) { int AxId = std::atoi(subStrings[0].substr(4,4000).c_str()); if (AxId >= 0 && AxId < refSketch->getAxisCount()) { @@ -85,6 +85,9 @@ const std::list Mirrored::getTransformations(const std::vectorPlacement.getValue(); axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); @@ -131,6 +134,9 @@ const std::list Mirrored::getTransformations(const std::vector subStrings = MirrorPlane.getSubValues(); if (auto feature = dynamic_cast(refObject)) { + if (subStrings.empty()) { + throw Base::ValueError("No mirror plane reference specified"); + } if (subStrings[0].empty()) { throw Base::ValueError("No direction reference specified"); } @@ -162,10 +168,6 @@ const std::list Mirrored::getTransformations(const std::vector subStrings = MirrorPlane.getSubValues(); - if (subStrings.empty()) { - throw Base::ValueError("No mirror plane reference specified"); - } gp_Pnt axbase; gp_Dir axdir; diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index 3e0788dae7..d5b2306de6 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -183,9 +183,13 @@ App::DocumentObjectExecReturn *Transformed::execute() try { std::list t_list = getTransformations(originals); transformations.insert(transformations.end(), t_list.begin(), t_list.end()); - } catch (Base::Exception& e) { + } + catch (Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } + catch (const Standard_Failure& e) { + return new App::DocumentObjectExecReturn(e.GetMessageString()); + } if (transformations.empty()) return App::DocumentObject::StdReturn; // No transformations defined, exit silently