PartDesign/Feature: add an optional parameter to getBaseObject() to prevent it from throwing exceptions
In most cases getBaseObject() is used with an exception handler which only detects if it failed but not the reason. This modification allows to use it without excess exception handlers. Also add the same parameter to SketchBased::getVerifiedSketch().
This commit is contained in:
committed by
Stefan Tröger
parent
013381ccb6
commit
55f3f52f54
@@ -91,15 +91,26 @@ const gp_Pnt Feature::getPointFromFace(const TopoDS_Face& f)
|
||||
throw Base::Exception("getPointFromFace(): Not implemented yet for this case");
|
||||
}
|
||||
|
||||
Part::Feature* Feature::getBaseObject() const {
|
||||
Part::Feature* Feature::getBaseObject(bool silent) const {
|
||||
App::DocumentObject* BaseLink = BaseFeature.getValue();
|
||||
if (BaseLink == NULL) throw Base::Exception("Base property not set");
|
||||
Part::Feature* BaseObject = NULL;
|
||||
if (BaseLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
BaseObject = static_cast<Part::Feature*>(BaseLink);
|
||||
Part::Feature* BaseObject = nullptr;
|
||||
const char *err = nullptr;
|
||||
|
||||
if (BaseObject == NULL)
|
||||
throw Base::Exception("No base feature linked");
|
||||
if (BaseLink) {
|
||||
if (BaseLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
BaseObject = static_cast<Part::Feature*>(BaseLink);
|
||||
}
|
||||
if (!BaseObject) {
|
||||
err = "No base feature linked";
|
||||
}
|
||||
} else {
|
||||
err = "Base property not set";
|
||||
}
|
||||
|
||||
// If the funtion not in silent mode throw the exception discribing the error
|
||||
if (!silent && err) {
|
||||
throw Base::Exception(err);
|
||||
}
|
||||
|
||||
return BaseObject;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user