From dff2127bc3c4db668f7c65a602dd39d2ccf66648 Mon Sep 17 00:00:00 2001 From: Bas Ruigrok Date: Thu, 19 Jun 2025 16:38:09 +0200 Subject: [PATCH] Part: Align to planar curves normal direction --- src/Mod/Part/App/PartFeature.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Mod/Part/App/PartFeature.cpp b/src/Mod/Part/App/PartFeature.cpp index fbaa479fe7..5ec7a459fa 100644 --- a/src/Mod/Part/App/PartFeature.cpp +++ b/src/Mod/Part/App/PartFeature.cpp @@ -1776,11 +1776,19 @@ bool Feature::getCameraAlignmentDirection(Base::Vector3d& directionZ, Base::Vect // Edge direction const size_t edgeCount = topoShape.countSubShapes(TopAbs_EDGE); - if (edgeCount == 1 && topoShape.isLinearEdge()) { - if (const std::unique_ptr geometry = Geometry::fromShape(topoShape.getSubShape(TopAbs_EDGE, 1), true)) { - const std::unique_ptr geomLine(static_cast(geometry.get())->toLine()); - if (geomLine) { - directionZ = geomLine->getDir().Normalize(); + if (edgeCount == 1) { + if (topoShape.isLinearEdge()) { + if (const std::unique_ptr geometry = Geometry::fromShape(topoShape.getSubShape(TopAbs_EDGE, 1), true)) { + const std::unique_ptr geomLine(static_cast(geometry.get())->toLine()); + if (geomLine) { + directionZ = geomLine->getDir().Normalize(); + return true; + } + } + } else { + // Planar curves + if (gp_Pln plane; topoShape.findPlane(plane)) { + directionZ = Base::Vector3d(plane.Axis().Direction().X(), plane.Axis().Direction().Y(), plane.Axis().Direction().Z()).Normalize(); return true; } }