Skip to content

Commit

Permalink
set referenceaxis properly and fix getaxis
Browse files Browse the repository at this point in the history
  • Loading branch information
usakhelo authored and wwmayer committed Mar 18, 2017
1 parent 934f473 commit bd3fef0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
13 changes: 11 additions & 2 deletions src/Mod/PartDesign/App/FeatureSketchBased.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Part::Part2DObject*>(getVerifiedObject());
}

Base::Placement SketchPlm = sketch->Placement.getValue();
Base::Vector3d SketchPos = SketchPlm.getPosition();
Base::Rotation SketchOrientation = SketchPlm.getRotation();
Expand Down Expand Up @@ -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") {
Expand Down
20 changes: 11 additions & 9 deletions src/Mod/PartDesign/Gui/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Gui::SelectionObject> 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<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
if (!selection.empty() && selection.front().hasSubNames()) {
base_worker(selection.front().getObject(), selection.front().getSubNames().front());
return;
Expand Down Expand Up @@ -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<PartDesign::Revolution*>(cmd->getDocument()->getObject(FeatName.c_str()));
if (pcRevolution && pcRevolution->suggestReversed())
Expand Down

0 comments on commit bd3fef0

Please sign in to comment.