From 78674fb121af363bfc05bf43332d20d6d31db8a7 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 16 Mar 2026 14:43:50 -0500 Subject: [PATCH] PD: Add migration to handle reversed TwoLengths prism Commit a346c266 (PR #21794) was a major refactoring of the extrusion code, and one consequence of it was that the 'TwoLengths' extrusion was deprecated and replaced. The code that replaced it generated the same final geometry, but in the opposite direction, changing the face order and breaking the element names. This commit adds a backwards-compatibility branch to the file loading code that flips the direction of the inputs, so the final output matches the original. (cherry picked from commit 49d7d77274dd516e8f24c82277fe60e3ff10450e) --- src/Mod/PartDesign/App/FeatureExtrude.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Mod/PartDesign/App/FeatureExtrude.cpp b/src/Mod/PartDesign/App/FeatureExtrude.cpp index 1403b44ccf..45fb84eb09 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.cpp +++ b/src/Mod/PartDesign/App/FeatureExtrude.cpp @@ -965,6 +965,20 @@ void FeatureExtrude::onDocumentRestored() Type.setValue("Length"); Type2.setValue("Length"); SideType.setValue("Two sides"); + + // The old TwoLengths code path (generatePrism) always extruded in +dir: + // offset = -L2 * dir (Reversed=false) or -L * dir (Reversed=true) + // extrude = (L+L2) * dir + // The new "Two sides" code extrudes Side 1 in dir, Side 2 in -dir, + // with Reversed toggling the sign of dir. To preserve the same OCC + // topology (face/edge ordering), we toggle Reversed so the effective + // extrusion direction matches the old +dir, and swap Length/Length2 + // to keep the correct offset for each side. + Reversed.setValue(!Reversed.getValue()); + double origL = Length.getValue(); + double origL2 = Length2.getValue(); + Length.setValue(origL2); + Length2.setValue(origL); } else if (Midplane.getValue()) { Midplane.setValue(false);