diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index e3689dc92..c4ecd6bb9 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -120,11 +120,16 @@ void SketchBased::positionBySketch(void) { Part::Part2DObject *sketch = static_cast(Sketch.getValue()); if (sketch && sketch->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { - Part::Feature *part = static_cast(sketch->Support.getValue()); - if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + App::DocumentObject* support = sketch->Support.getValue(); + if (support->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + Part::Feature *part = static_cast(support); this->Placement.setValue(part->Placement.getValue()); - else + } else if (support->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + App::Plane *plane = static_cast(support); + this->Placement.setValue(plane->Placement.getValue()); + } else { this->Placement.setValue(sketch->Placement.getValue()); + } } } @@ -212,20 +217,15 @@ const TopoDS_Face SketchBased::getSupportFace() const { return face; } -Part::Feature* SketchBased::getSupport() const { - // get the support of the Sketch if any +const TopoDS_Shape& SketchBased::getSupportShape() const { if (!Sketch.getValue()) - return 0; + throw Base::Exception("No Sketch!"); + App::DocumentObject* SupportLink = static_cast(Sketch.getValue())->Support.getValue(); Part::Feature* SupportObject = NULL; if (SupportLink && SupportLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) SupportObject = static_cast(SupportLink); - return SupportObject; -} - -const TopoDS_Shape& SketchBased::getSupportShape() const { - Part::Feature* SupportObject = getSupport(); if (SupportObject == NULL) throw Base::Exception("No support in Sketch!"); @@ -954,9 +954,12 @@ bool SketchBased::isParallelPlane(const TopoDS_Shape& s1, const TopoDS_Shape& s2 bool SketchBased::isSupportDatum() const { - Part::Feature* SupportObject = getSupport(); + if (!Sketch.getValue()) + return 0; + App::DocumentObject* SupportObject = static_cast(Sketch.getValue())->Support.getValue(); if (SupportObject == NULL) throw Base::Exception("No support in Sketch!"); + return isDatum(SupportObject); } diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index 2a86eaa8d..b28f18cc2 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -122,12 +122,8 @@ protected: /// Check whether the line crosses the face (line and face must be on the same plane) static const bool checkLineCrossesFace(const gp_Lin& line, const TopoDS_Face& face); - -private: class Wire_Compare; - /// Returns the sketch support feature or NULL - Part::Feature* getSupport() const; }; } //namespace PartDesign diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index d15448cb1..bc8d339ea 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -183,6 +183,8 @@ void CmdPartDesignMoveTip::activated(int iMsg) if (pcActiveBody != NULL) Gui::Command::doCommand(Gui::Command::Gui,"PartDesignGui.setActivePart(App.activeDocument().%s)", pcActiveBody->getNameInDocument()); + else + return; } App::DocumentObject* oldTip = pcActiveBody->Tip.getValue();