Centralize the check for valid external geometry to ensure consistency (part 2)

This commit is contained in:
jrheinlaender 2013-09-11 19:57:50 +02:00 committed by Stefan Tröger
parent be9365679f
commit 02ce7395aa

View File

@ -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;
}