diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp index e2d8fd31e..0f6d1beb6 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.cpp +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #endif #include @@ -196,16 +197,28 @@ App::DocumentObjectExecReturn *Pipe::execute(void) if(!mkSolid.IsDone()) return new App::DocumentObjectExecReturn("Result is not a solid"); - AddSubShape.setValue(mkSolid.Shape()); + TopoDS_Shape result = mkSolid.Shape(); + BRepClass3d_SolidClassifier SC(result); + SC.PerformInfinitePoint(Precision::Confusion()); + if ( SC.State() == TopAbs_IN) { + result.Reverse(); + } + + AddSubShape.setValue(result); if(base.IsNull()) { - Shape.setValue(mkSolid.Shape()); + Shape.setValue(result); return App::DocumentObject::StdReturn; } if(getAddSubType() == FeatureAddSub::Additive) { - BRepAlgoAPI_Fuse mkFuse(base, mkSolid.Shape()); + auto* b = getDocument()->addObject("Part::Feature", "base"); + static_cast(b)->Shape.setValue(base); + b = getDocument()->addObject("Part::Feature", "pipe"); + static_cast(b)->Shape.setValue(result); + + BRepAlgoAPI_Fuse mkFuse(base, result); if (!mkFuse.IsDone()) return new App::DocumentObjectExecReturn("Adding the pipe failed"); // we have to get the solids (fuse sometimes creates compounds) @@ -219,7 +232,7 @@ App::DocumentObjectExecReturn *Pipe::execute(void) } else if(getAddSubType() == FeatureAddSub::Subtractive) { - BRepAlgoAPI_Cut mkCut(base, mkSolid.Shape()); + BRepAlgoAPI_Cut mkCut(base, result); if (!mkCut.IsDone()) return new App::DocumentObjectExecReturn("Subtracting the pipe failed"); // we have to get the solids (fuse sometimes creates compounds) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 7420c2a58..0dec6e0ac 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -1150,7 +1150,7 @@ void CmdPartDesignPad::activated(int iMsg) Gui::Command::updateActive(); finishSketchBased(cmd, sketch, FeatName); - //adjustCameraPosition(); + cmd->adjustCameraPosition(); }; prepareSketchBased(this, "Pad", worker); @@ -1187,7 +1187,7 @@ void CmdPartDesignPocket::activated(int iMsg) Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 5.0",FeatName.c_str()); finishSketchBased(cmd, sketch, FeatName); - //adjustCameraPosition(); + cmd->adjustCameraPosition(); }; prepareSketchBased(this, "Pocket", worker); @@ -1230,7 +1230,7 @@ void CmdPartDesignRevolution::activated(int iMsg) Gui::Command::doCommand(Doc,"App.activeDocument().%s.Reversed = 1",FeatName.c_str()); finishSketchBased(cmd, sketch, FeatName); - //adjustCameraPosition(); + cmd->adjustCameraPosition(); }; prepareSketchBased(this, "Revolution", worker); @@ -1273,7 +1273,7 @@ void CmdPartDesignGroove::activated(int iMsg) Gui::Command::doCommand(Doc,"App.activeDocument().%s.Reversed = 1",FeatName.c_str()); finishSketchBased(cmd, sketch, FeatName); - //adjustCameraPosition(); + cmd->adjustCameraPosition(); }; prepareSketchBased(this, "Groove", worker); @@ -1320,7 +1320,7 @@ void CmdPartDesignAdditivePipe::activated(int iMsg) Gui::Command::updateActive(); finishSketchBased(cmd, sketch, FeatName); - //adjustCameraPosition(); + cmd->adjustCameraPosition(); }; prepareSketchBased(this, "AdditivePipe", worker); @@ -1368,7 +1368,7 @@ void CmdPartDesignSubtractivePipe::activated(int iMsg) Gui::Command::updateActive(); finishSketchBased(cmd, sketch, FeatName); - //adjustCameraPosition(); + cmd->adjustCameraPosition(); }; prepareSketchBased(this, "SubtractivePipe", worker);