From 880461593fdc90cbf41a490c279a5984ff798fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20B=C3=A4hr?= Date: Fri, 1 Sep 2023 23:05:24 +0200 Subject: [PATCH] Sketcher: Fix check in carbonCopy's python interface Presumably due to an copy/paste error, carbonCopy used to verify the referenced object via `isExternalAllowed` (just like addExternal). Now using `isCarbonCopyAllowed`, the resulting error message is the expected one for wrong objects, not a generic one after the operation failed. --- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 1841e9f738..e28625a552 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -517,16 +517,15 @@ PyObject* SketchObjectPy::carbonCopy(PyObject* args) PyErr_SetString(PyExc_ValueError, str.str().c_str()); return nullptr; } - // check if this type of external geometry is allowed - if (!skObj->isExternalAllowed(Obj->getDocument(), Obj) - && (Obj->getTypeId() != Sketcher::SketchObject::getClassTypeId())) { + + bool xinv = false, yinv = false; + if (!skObj->isCarbonCopyAllowed(Obj->getDocument(), Obj, xinv, yinv)) { std::stringstream str; str << ObjectName << " is not allowed for a carbon copy operation in this sketch"; PyErr_SetString(PyExc_ValueError, str.str().c_str()); return nullptr; } - // add the external if (skObj->carbonCopy(Obj, Base::asBoolean(construction)) < 0) { std::stringstream str; str << "Not able to add the requested geometry"; @@ -565,7 +564,7 @@ PyObject* SketchObjectPy::addExternal(PyObject* args) // add the external if (skObj->addExternal(Obj, SubName) < 0) { std::stringstream str; - str << "Not able to add external shape element"; + str << "Not able to add external shape element " << SubName; PyErr_SetString(PyExc_ValueError, str.str().c_str()); return nullptr; }