diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 59e804fbc2c3..e33bb1d13151 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -296,14 +296,24 @@ std::vector ProfileBased::getProfileWires() const { // Note: We cannot return a reference, because it will become Null. // Not clear where, because we check for IsNull() here, but as soon as it is passed out of // this method, it becomes null! -const TopoDS_Face ProfileBased::getSupportFace() const { - const Part::Part2DObject* sketch = getVerifiedSketch(); - if (sketch->MapMode.getValue() == Attacher::mmFlatFace && sketch->Support.getValue()) { +const TopoDS_Face ProfileBased::getSupportFace() const +{ + const Part::Part2DObject* sketch = getVerifiedSketch(true); + if (sketch) { + return getSupportFace(sketch); + } + + return getSupportFace(Profile); +} + +TopoDS_Face ProfileBased::getSupportFace(const Part::Part2DObject* sketch) const +{ + if (sketch && sketch->MapMode.getValue() == Attacher::mmFlatFace && sketch->Support.getValue()) { const auto& Support = sketch->Support; App::DocumentObject* ref = Support.getValue(); - Part::Feature* part = static_cast(ref); - if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + Part::Feature* part = dynamic_cast(ref); + if (part) { const std::vector& sub = Support.getSubValues(); assert(sub.size() == 1); @@ -335,6 +345,18 @@ const TopoDS_Face ProfileBased::getSupportFace() const { return TopoDS::Face(Feature::makeShapeFromPlane(sketch)); } +TopoDS_Face ProfileBased::getSupportFace(const App::PropertyLinkSub& link) const +{ + App::DocumentObject* result = link.getValue(); + if (!result) { + throw Base::RuntimeError("No support linked"); + } + + TopoDS_Face face; + getFaceFromLinkSub(face, link); + return face; +} + int ProfileBased::getSketchAxisCount(void) const { Part::Part2DObject* sketch = static_cast(Profile.getValue()); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index c93900e6d051..62629e288b8a 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -124,6 +124,9 @@ class PartDesignExport ProfileBased : public PartDesign::FeatureAddSub protected: void remapSupportShape(const TopoDS_Shape&); + TopoDS_Face getSupportFace(const Part::Part2DObject*) const; + TopoDS_Face getSupportFace(const App::PropertyLinkSub& link) const; + /// Extract a face from a given LinkSub static void getFaceFromLinkSub(TopoDS_Face& upToFace, const App::PropertyLinkSub& refFace);