From 8aa25fa657ef7d7e082be1ecb1ccdeb65fa1cd41 Mon Sep 17 00:00:00 2001 From: paul <40677073+paullee0@users.noreply.github.com> Date: Tue, 25 Nov 2025 01:01:38 +0800 Subject: [PATCH] [ArchWall] Fix Bug: Center-Align with Centered Multi-Material (#25572) * [ArchWall] Fix Bug: Center-Align with Centered Multi-Material Fix #25485 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/BIM/ArchWall.py | 54 +++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/src/Mod/BIM/ArchWall.py b/src/Mod/BIM/ArchWall.py index f574e26346..b5b3f108a0 100644 --- a/src/Mod/BIM/ArchWall.py +++ b/src/Mod/BIM/ArchWall.py @@ -1397,15 +1397,55 @@ class _Wall(ArchComponent.Component): ) elif curAligns == "Center": if layers: + # TODO Current, the order of layers follow + # "Right" align. Option for the order of + # layers follow "Left" align should be + # provided for users. + dvec = dvec.negative() totalwidth = sum([abs(l) for l in layers]) - curWidth = abs(layers[i]) off = totalwidth / 2 - layeroffset - d1 = Vector(dvec).multiply(off) - wNe1 = DraftGeomUtils.offsetWire(wire, d1, wireNedge=True) - layeroffset += curWidth - off = totalwidth / 2 - layeroffset - d1 = Vector(dvec).multiply(off) - wNe2 = DraftGeomUtils.offsetWire(wire, d1, wireNedge=True) + # TODO To consider offset per edge? + # + # Offset follows direction of align "Right". + # Needs to be reversed in this case. + off = -off + # d1 = Vector(dvec).multiply(off) + curWidth = [] + alignListC = [] + offsetListC = [] + for n in range(edgeNum): + curWidth.append(abs(layers[i])) + alignListC.append("Right") # ("Left") + offsetListC.append(off) + # wNe1 = DraftGeomUtils.offsetWire(wire, d1, wireNedge=True) + # See https://github.com/FreeCAD/FreeCAD/issues/25485#issuecomment-3566734050 + # d1 may be Vector (0,0,0), offsetWire() + # in draftgeoutils\offsets.py:- + # v1 = App.Vector(dvec).normalize() return + # error. Provide widthList, alignList etc. + # so no need to run above code to deduce + # v1 in offsetWire() + wNe1 = DraftGeomUtils.offsetWire( + wire, + dvec, + widthList=curWidth, + offsetMode="BasewireMode", + alignList=alignListC, + normal=normal, + basewireOffset=offsetListC, + wireNedge=True, + ) + wNe2 = DraftGeomUtils.offsetWire( + wire, + dvec, + widthList=curWidth, + offsetMode=None, + alignList=alignListC, + normal=normal, + basewireOffset=offsetListC, + wireNedge=True, + ) + layeroffset += abs(curWidth[0]) else: dvec.multiply(width) wNe2 = DraftGeomUtils.offsetWire(