From bd3fef03a7606e027d84b51899796dc7cb5470ba Mon Sep 17 00:00:00 2001 From: Sergo Date: Fri, 10 Mar 2017 01:19:38 -0500 Subject: [PATCH] set referenceaxis properly and fix getaxis --- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 13 ++++++++++-- src/Mod/PartDesign/Gui/Command.cpp | 20 ++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index b94ef1c51c..058f8e4448 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -912,7 +912,15 @@ void ProfileBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std if (pcReferenceAxis == NULL) return; - Part::Part2DObject* sketch = getVerifiedSketch(); + App::DocumentObject* profile = Profile.getValue(); + Part::Part2DObject* sketch; + if (profile->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + sketch = getVerifiedSketch(); + } + else if (profile->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + sketch = static_cast(getVerifiedObject()); + } + Base::Placement SketchPlm = sketch->Placement.getValue(); Base::Vector3d SketchPos = SketchPlm.getPosition(); Base::Rotation SketchOrientation = SketchPlm.getRotation(); @@ -943,7 +951,8 @@ void ProfileBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std return; } - if (pcReferenceAxis == sketch){ + if (pcReferenceAxis == profile) { + //Part::Part2DObject* sketch = getVerifiedSketch(); bool hasValidAxis=false; Base::Axis axis; if (subReferenceAxis[0] == "V_Axis") { diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 0a7b66fd2f..b4002651b3 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -739,12 +739,7 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which, }; //if a profile is selected we can make our life easy and fast - std::vector selection; - std::string cmdName = cmd->getName(); - if (cmdName == "PartDesign_Revolution" || cmdName == "PartDesign_Groove") - selection = cmd->getSelection().getSelectionEx(0, Part::Part2DObject::getClassTypeId()); - else - selection = cmd->getSelection().getSelectionEx(); + std::vector selection = cmd->getSelection().getSelectionEx(); if (!selection.empty() && selection.front().hasSubNames()) { base_worker(selection.front().getObject(), selection.front().getSubNames().front()); return; @@ -1004,12 +999,19 @@ void CmdPartDesignRevolution::activated(int iMsg) return; Gui::Command* cmd = this; - auto worker = [this, cmd](Part::Feature* sketch, std::string FeatName) { + auto worker = [this, cmd, pcActiveBody](Part::Feature* sketch, std::string FeatName) { if (FeatName.empty()) return; - Gui::Command::doCommand(Doc,"App.activeDocument().%s.ReferenceAxis = (App.activeDocument().%s,['V_Axis'])", - FeatName.c_str(), sketch->getNameInDocument()); + if (sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + Gui::Command::doCommand(Doc, "App.activeDocument().%s.ReferenceAxis = (App.activeDocument().%s,['V_Axis'])", + FeatName.c_str(), sketch->getNameInDocument()); + } + else { + Gui::Command::doCommand(Doc, "App.activeDocument().%s.ReferenceAxis = (App.activeDocument().%s,[\"\"])", + FeatName.c_str(), pcActiveBody->getOrigin()->getY()->getNameInDocument()); + } + Gui::Command::doCommand(Doc,"App.activeDocument().%s.Angle = 360.0",FeatName.c_str()); PartDesign::Revolution* pcRevolution = static_cast(cmd->getDocument()->getObject(FeatName.c_str())); if (pcRevolution && pcRevolution->suggestReversed())