From 256ad7a01aa2753ef7b8925ede93dd9448d80a82 Mon Sep 17 00:00:00 2001 From: Eric Price <32105268+AIRCAP@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:01:26 +0200 Subject: [PATCH] =?UTF-8?q?PartDesign:=20Loft=20Intelligence=20-=20Select?= =?UTF-8?q?=20the=20whole=20sketch=20if=20the=20selected=20shape=20is=20?= =?UTF-8?q?=E2=80=A6=20(#16791)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Loft Intelligence - Select the whole sketch if the selected shape is a component of a sketch that is not a vertex (Fix #16630) In fa8f29aed489247e931631dbd1e600cc7610c38f FeatureLoft.cpp was refactured, dropping some functionality, mainly the ability to create lofts to entire sketches or other 2d shapes if a single component that was not a single vertex was selected as either the base shape or a section the old code was: 1 auto getSectionShape = 2 [](App::DocumentObject* feature, const std::vector &subs) -> TopoDS_Shape { 3 if (!feature || 4 !feature->isDerivedFrom(Part::Feature::getClassTypeId())) 5 throw Base::TypeError("Loft: Invalid profile/section"); 6 7 auto subName = subs.empty() ? "" : subs.front(); 8 9 // only take the entire shape when we have a sketch selected, but 10 // not a point of the sketch 11 if (feature->isDerivedFrom(Part::Part2DObject::getClassTypeId()) && 12 subName.compare(0, 6, "Vertex") != 0) 13 return static_cast(feature)->Shape.getValue(); 14 else { 15 if(subName.empty()) 16 throw Base::ValueError("No valid subelement linked in Part::Feature"); 17 return static_cast(feature)->Shape.getShape().getSubShape(subName.c_str()); 18 } 19 }; this commit forward-ports the missing functionality provided by line 7-12 in above snippet * Code cleanup as suggested by (#16791) --- src/Mod/PartDesign/App/FeatureLoft.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/App/FeatureLoft.cpp b/src/Mod/PartDesign/App/FeatureLoft.cpp index baffc52b51..c2208a0999 100644 --- a/src/Mod/PartDesign/App/FeatureLoft.cpp +++ b/src/Mod/PartDesign/App/FeatureLoft.cpp @@ -72,7 +72,11 @@ Loft::getSectionShape(const char *name, size_t expected_size) { std::vector shapes; - if (subs.empty() || std::find(subs.begin(), subs.end(), std::string()) != subs.end()) { + // Be smart. If part of a sketch is selected, use the entire sketch unless it is a single vertex - + // backward compatibility (#16630) + auto subName = subs.empty() ? "" : subs.front(); + auto useEntireSketch = obj->isDerivedFrom(Part::Part2DObject::getClassTypeId()) && subName.find("Vertex") != 0; + if (subs.empty() || std::find(subs.begin(), subs.end(), std::string()) != subs.end() || useEntireSketch ) { shapes.push_back(Part::Feature::getTopoShape(obj)); if (shapes.back().isNull()) FC_THROWM(Part::NullShapeException, "Failed to get shape of "