+ in Fem constraint force dialog handle empty Direction
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
using namespace Fem;
|
||||
|
||||
@@ -312,7 +313,15 @@ const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direct
|
||||
const Part::TopoShape& shape = feat->Shape.getShape();
|
||||
if (shape.isNull())
|
||||
return Base::Vector3d(0,0,0);
|
||||
TopoDS_Shape sh = shape.getSubShape(subName.c_str());
|
||||
TopoDS_Shape sh;
|
||||
try {
|
||||
sh = shape.getSubShape(subName.c_str());
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
std::stringstream str;
|
||||
str << "No such sub-element '" << subName << "'";
|
||||
throw Base::AttributeError(str.str());
|
||||
}
|
||||
gp_Dir dir;
|
||||
|
||||
if (sh.ShapeType() == TopAbs_FACE) {
|
||||
|
||||
@@ -96,8 +96,11 @@ void ConstraintForce::onChanged(const App::Property* prop)
|
||||
} else if (prop == &NormalDirection) {
|
||||
// Set a default direction if no direction reference has been given
|
||||
if (Direction.getValue() == NULL) {
|
||||
DirectionVector.setValue(NormalDirection.getValue());
|
||||
naturalDirectionVector = NormalDirection.getValue();
|
||||
Base::Vector3d direction = NormalDirection.getValue();
|
||||
if (Reversed.getValue())
|
||||
direction = -direction;
|
||||
DirectionVector.setValue(direction);
|
||||
naturalDirectionVector = direction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user