From 19cd040415bfc4224040259977568602fb8ea5c9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 27 Sep 2018 11:04:30 +0200 Subject: [PATCH] in linear pattern handle selected edge of a 2d part object --- src/Mod/PartDesign/App/FeatureLinearPattern.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp index 4df99d133a..69117d2409 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp @@ -102,6 +102,21 @@ const std::list LinearPattern::getTransformations(const std::vector= 0 && AxId < refSketch->getAxisCount()) axis = refSketch->getAxis(AxId); } + else if (subStrings[0].substr(0,4) == "Edge") { + Part::TopoShape refShape = refSketch->Shape.getShape(); + TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str()); + TopoDS_Edge refEdge = TopoDS::Edge(ref); + if (refEdge.IsNull()) + throw Base::Exception("Failed to extract direction edge"); + BRepAdaptor_Curve adapt(refEdge); + if (adapt.GetType() != GeomAbs_Line) + throw Base::Exception("Direction edge must be a straight line"); + + gp_Pnt p = adapt.Line().Location(); + gp_Dir d = adapt.Line().Direction(); + axis.setBase(Base::Vector3d(p.X(), p.Y(), p.Z())); + axis.setDirection(Base::Vector3d(d.X(), d.Y(), d.Z())); + } axis *= refSketch->Placement.getValue(); dir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); } else if (refObject->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {