diff --git a/src/Mod/Fem/App/FemConstraint.cpp b/src/Mod/Fem/App/FemConstraint.cpp index ad9c0afdb6..35e7c098a6 100644 --- a/src/Mod/Fem/App/FemConstraint.cpp +++ b/src/Mod/Fem/App/FemConstraint.cpp @@ -90,9 +90,14 @@ Constraint::~Constraint() App::DocumentObjectExecReturn *Constraint::execute(void) { - References.touch(); - Scale.touch(); - return StdReturn; + try { + References.touch(); + Scale.touch(); + return StdReturn; + } + catch (const Standard_Failure& e) { + return new App::DocumentObjectExecReturn(e.GetMessageString(), this); + } } //OvG: Provide the ability to determine how big to draw constraint arrows etc. @@ -123,14 +128,15 @@ void Constraint::onChanged(const App::Property* prop) // Extract geometry from References TopoDS_Shape sh; + bool execute = this->isRecomputing(); for (std::size_t i = 0; i < Objects.size(); i++) { App::DocumentObject* obj = Objects[i]; Part::Feature* feat = static_cast(obj); const Part::TopoShape& toposhape = feat->Shape.getShape(); if (!toposhape.getShape().IsNull()) { - sh = toposhape.getSubShape(SubElements[i].c_str()); + sh = toposhape.getSubShape(SubElements[i].c_str(), !execute); - if (sh.ShapeType() == TopAbs_FACE) { + if (!sh.IsNull() && sh.ShapeType() == TopAbs_FACE) { // Get face normal in center point TopoDS_Face face = TopoDS::Face(sh); BRepGProp_Face props(face); @@ -142,8 +148,7 @@ void Constraint::onChanged(const App::Property* prop) normal.Normalize(); NormalDirection.setValue(normal.X(), normal.Y(), normal.Z()); // One face is enough... - App::DocumentObject::onChanged(prop); - return; + break; } } } @@ -174,7 +179,9 @@ bool Constraint::getPoints(std::vector &points, std::vector