diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 50568a3962..c9cba28324 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -156,17 +156,30 @@ const TopoDS_Shape& Feature::getBaseShape() const { return result; } -const Part::TopoShape Feature::getBaseTopoShape() const { - const Part::Feature* BaseObject = getBaseObject(); +Part::TopoShape Feature::getBaseTopoShape(bool silent) const { + Part::TopoShape result; - if (BaseObject->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId())) { - throw Base::ValueError("Base shape of shape binder cannot be used"); + const Part::Feature* BaseObject = getBaseObject(silent); + if (!BaseObject) + return result; + + if(BaseObject != BaseFeature.getValue()) { + if (BaseObject->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) || + BaseObject->isDerivedFrom(PartDesign::SubShapeBinder::getClassTypeId())) + { + if(silent) + return result; + throw Base::ValueError("Base shape of shape binder cannot be used"); + } } - const Part::TopoShape& result = BaseObject->Shape.getShape(); - if (result.getShape().IsNull()) - throw Base::ValueError("Base feature's TopoShape is invalid"); - + result = BaseObject->Shape.getShape(); + if(!silent) { + if (result.isNull()) + throw Base::ValueError("Base feature's TopoShape is invalid"); + if (!result.hasSubShape(TopAbs_SOLID)) + throw Base::ValueError("Base feature's shape is not a solid"); + } return result; } diff --git a/src/Mod/PartDesign/App/Feature.h b/src/Mod/PartDesign/App/Feature.h index cccb5de692..99c763d325 100644 --- a/src/Mod/PartDesign/App/Feature.h +++ b/src/Mod/PartDesign/App/Feature.h @@ -72,7 +72,7 @@ public: /// Returns the BaseFeature property's shape (if any) virtual const TopoDS_Shape& getBaseShape() const; /// Returns the BaseFeature property's TopoShape (if any) - const Part::TopoShape getBaseTopoShape() const; + Part::TopoShape getBaseTopoShape(bool silent=false) const; virtual PyObject* getPyObject(void); diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index 5bafab6420..59f748d4cc 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -191,14 +191,14 @@ void DressUp::onChanged(const App::Property* prop) s = base->AddSubShape.getShape(); } else { addSubType = base->getAddSubType(); - auto baseBase = base->getBaseObject(true); - if(!baseBase) { + Part::TopoShape baseShape = base->getBaseTopoShape(true); + if (baseShape.isNull() || !baseShape.hasSubShape(TopAbs_SOLID)) { s = Shape.getShape(); addSubType = Additive; } else if (addSubType == Additive) - s = Shape.getShape().cut(base->getBaseTopoShape().getShape()); + s = Shape.getShape().cut(baseShape.getShape()); else - s = base->getBaseTopoShape().cut(Shape.getValue()); + s = baseShape.cut(Shape.getValue()); } AddSubShape.setValue(s); }