From 02ce7395aa856f7dd024808980f9b09efff5678d Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Wed, 11 Sep 2013 19:57:50 +0200 Subject: [PATCH] Centralize the check for valid external geometry to ensure consistency (part 2) --- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index d9cc5bf91..55009ac0f 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -384,20 +384,10 @@ PyObject* SketchObjectPy::addExternal(PyObject *args) PyErr_SetString(PyExc_ValueError, str.str().c_str()); return 0; } - // check if it is a datum feature - // TODO: Allow selection only from Body which this sketch belongs to? - if (Obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { - // OK - } else if (Obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { - if (!skObj->allowOtherBody && (skObj->Support.getValue() != Obj)) { - std::stringstream str; - str << ObjectName << " is not supported by this sketch"; - PyErr_SetString(PyExc_ValueError, str.str().c_str()); - return 0; - } - } else if (!Obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + // check if this type of external geometry is allowed + if (!skObj->isExternalAllowed(Obj->getDocument(), Obj)) { std::stringstream str; - str << ObjectName << " must be a Part feature or a datum feature"; + str << ObjectName << " is not allowed as external geometry of this sketch"; PyErr_SetString(PyExc_ValueError, str.str().c_str()); return 0; }