diff --git a/src/Mod/Part/App/FeatureExtrusion.cpp b/src/Mod/Part/App/FeatureExtrusion.cpp index 04613bbf86..67e1978217 100644 --- a/src/Mod/Part/App/FeatureExtrusion.cpp +++ b/src/Mod/Part/App/FeatureExtrusion.cpp @@ -100,7 +100,7 @@ bool Extrusion::fetchAxisLink(const App::PropertyLinkSub& axisLink, Base::Vector TopoDS_Shape axEdge; if (axisLink.getSubValues().size() > 0 && axisLink.getSubValues()[0].length() > 0) { - axEdge = Feature::getTopoShape(linked).getSubShape(axisLink.getSubValues()[0].c_str()); + axEdge = Feature::getTopoShape(linked, axisLink.getSubValues()[0].c_str(), true /*need element*/).getShape(); } else { axEdge = Feature::getShape(linked); diff --git a/src/Mod/Part/App/FeatureRevolution.cpp b/src/Mod/Part/App/FeatureRevolution.cpp index fd7848ad81..367df48443 100644 --- a/src/Mod/Part/App/FeatureRevolution.cpp +++ b/src/Mod/Part/App/FeatureRevolution.cpp @@ -94,7 +94,7 @@ bool Revolution::fetchAxisLink(const App::PropertyLinkSub &axisLink, TopoDS_Shape axEdge; if (axisLink.getSubValues().size() > 0 && axisLink.getSubValues()[0].length() > 0){ - axEdge = Feature::getTopoShape(linked).getSubShape(axisLink.getSubValues()[0].c_str()); + axEdge = Feature::getTopoShape(linked, axisLink.getSubValues()[0].c_str(), true /*need element*/).getShape(); } else { axEdge = Feature::getShape(linked); } diff --git a/src/Mod/Part/App/PartFeatures.cpp b/src/Mod/Part/App/PartFeatures.cpp index 92e0f29d1a..9b0cb8f7f1 100644 --- a/src/Mod/Part/App/PartFeatures.cpp +++ b/src/Mod/Part/App/PartFeatures.cpp @@ -61,6 +61,8 @@ RuledSurface::RuledSurface() ADD_PROPERTY_TYPE(Curve2,(nullptr),"Ruled Surface",App::Prop_None,"Curve of ruled surface"); ADD_PROPERTY_TYPE(Orientation,((long)0),"Ruled Surface",App::Prop_None,"Orientation of ruled surface"); Orientation.setEnums(OrientationEnums); + ADD_PROPERTY_TYPE(ResetPlacement,(false),"Ruled Surface",App::Prop_None, + "Whether to reset placement"); } short RuledSurface::mustExecute() const @@ -71,6 +73,8 @@ short RuledSurface::mustExecute() const return 1; if (Orientation.isTouched()) return 1; + if (ResetPlacement.isTouched()) + return 1; return 0; } @@ -100,6 +104,7 @@ App::DocumentObjectExecReturn* RuledSurface::getShape(const App::PropertyLinkSub if (!part.getShape().IsNull()) { if (!element[0].empty()) { + //shape = Part::Feature::getTopoShape(obj, element[0].c_str(), true /*need element*/).getShape(); shape = part.getSubShape(element[0].c_str()); } else { @@ -239,15 +244,20 @@ App::DocumentObjectExecReturn *RuledSurface::execute(void) // re-apply the placement in case we reset it if (!Loc.IsIdentity()) ruledShape.Move(Loc); + Loc = ruledShape.Location(); - if (!Loc.IsIdentity()) { + if (!Loc.IsIdentity() && ResetPlacement.getValue()) { // reset the placement of the shape because the Placement // property will be changed ruledShape.Location(TopLoc_Location()); Base::Matrix4D transform; TopoShape::convertToMatrix(Loc.Transformation(), transform); this->Placement.setValue(Base::Placement(transform)); + } else { + if (!Loc.IsIdentity()){ //Reset Placement property = False + this->Placement.setValue(Base::Placement()); + } } this->Shape.setValue(ruledShape); @@ -431,7 +441,7 @@ App::DocumentObjectExecReturn *Sweep::execute(void) if (!subedge.empty()) { BRepBuilderAPI_MakeWire mkWire; for (std::vector::const_iterator it = subedge.begin(); it != subedge.end(); ++it) { - TopoDS_Shape subshape = shape.getSubShape(it->c_str()); + TopoDS_Shape subshape = Feature::getTopoShape(spine, it->c_str(), true /*need element*/).getShape(); mkWire.Add(TopoDS::Edge(subshape)); } path = mkWire.Wire(); diff --git a/src/Mod/Part/App/PartFeatures.h b/src/Mod/Part/App/PartFeatures.h index 898dce1945..f7164aac90 100644 --- a/src/Mod/Part/App/PartFeatures.h +++ b/src/Mod/Part/App/PartFeatures.h @@ -41,6 +41,7 @@ public: App::PropertyEnumeration Orientation; App::PropertyLinkSub Curve1; App::PropertyLinkSub Curve2; + App::PropertyBool ResetPlacement; /** @name methods override feature */ //@{ diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index 05a308d668..f8a705af9d 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -2108,11 +2108,11 @@ void CmdPartRuledSurface::activated(int iMsg) } if (ok && subnames1.size() <= 2) { if (subnames1.size() >= 1) { - curve1 = shape1.getSubShape(subnames1[0].c_str()); + curve1 = Part::Feature::getTopoShape(docobj1, subnames1[0].c_str(), true /*need element*/).getShape(); link1 = subnames1[0]; } if (subnames1.size() == 2) { - curve2 = shape1.getSubShape(subnames1[1].c_str()); + curve2 = Part::Feature::getTopoShape(docobj1, subnames1[1].c_str(), true /*need element*/).getShape(); link2 = subnames1[1]; } if (subnames1.size() == 0) { @@ -2132,7 +2132,7 @@ void CmdPartRuledSurface::activated(int iMsg) ok = false; } if (ok && subnames2.size() == 1) { - curve2 = shape2.getSubShape(subnames2[0].c_str()); + curve2 = Part::Feature::getTopoShape(docobj2, subnames2[0].c_str(), true /*need element*/).getShape(); link2 = subnames2[0]; } else { if (subnames2.size() == 0) { diff --git a/src/Mod/Part/Gui/DlgExtrusion.cpp b/src/Mod/Part/Gui/DlgExtrusion.cpp index 6e52e86d61..13f6931f03 100644 --- a/src/Mod/Part/Gui/DlgExtrusion.cpp +++ b/src/Mod/Part/Gui/DlgExtrusion.cpp @@ -81,7 +81,7 @@ public: return false; } try { - TopoDS_Shape sub = part.getSubShape(sSubName); + TopoDS_Shape sub = Part::Feature::getTopoShape(pObj, sSubName, true /*need element*/).getShape(); if (!sub.IsNull() && sub.ShapeType() == TopAbs_EDGE) { const TopoDS_Edge& edge = TopoDS::Edge(sub); BRepAdaptor_Curve adapt(edge); diff --git a/src/Mod/Part/Gui/TaskSweep.cpp b/src/Mod/Part/Gui/TaskSweep.cpp index 7ac38137be..643e0b6bc9 100644 --- a/src/Mod/Part/Gui/TaskSweep.cpp +++ b/src/Mod/Part/Gui/TaskSweep.cpp @@ -300,7 +300,7 @@ bool SweepWidget::accept() topoShape = Part::Feature::getTopoShape(docobj); if (!topoShape.isNull()) { for (std::vector::const_iterator it = subnames.begin(); it != subnames.end(); ++it) { - subShapes.push_back(topoShape.getSubShape(subnames[0].c_str())); + subShapes.push_back(Part::Feature::getTopoShape(docobj, subnames[0].c_str(), true /*need element*/)); } for (std::vector::iterator it = subShapes.begin(); it != subShapes.end(); ++it) { TopoDS_Shape dsShape = (*it).getShape();