[ArchWall] Fix Regression: sortSketchWidth only in addon (#27676)

* [ArchWall] Fix Regression: sortSketchWidth only in addon

Regression was introduced when get_width() method uses ArchSketchObject.sortSketchWidth() function in below lines.

https://github.com/FreeCAD/FreeCAD/blob/468269b9a6ea58cd8b0f9d8579b711c530db83b2/src/Mod/BIM/ArchWall.py#L1668-L1673
        if not lwidths:
            if obj.OverrideWidth:
                if obj.Base and obj.Base.isDerivedFrom("Sketcher::SketchObject"):
                    lwidths = ArchSketchObject.sortSketchWidth(
                        obj.Base, obj.OverrideWidth, obj.ArchSketchEdges
                    )

ArchSketchObject.sortSketchWidth() function is not in the FC core ArchSketchObject.py module and this results in error.  This function would only exist when the external add-on is present and loaded.

Previously, a try/exception test was used; now hasattr() is used in this fix to test the presence of the required function before it is used.

* [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>
This commit is contained in:
paul
2026-02-18 11:49:33 +01:00
committed by GitHub
co-authored by pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
parent 2d3b0a2ded
commit aa4a71b55b
+5 -1
View File
@@ -1667,7 +1667,11 @@ class _Wall(ArchComponent.Component):
)
if not lwidths:
if obj.OverrideWidth:
if obj.Base and obj.Base.isDerivedFrom("Sketcher::SketchObject"):
if (
obj.Base
and obj.Base.isDerivedFrom("Sketcher::SketchObject")
and hasattr(ArchSketchObject, "sortSketchWidth")
):
lwidths = ArchSketchObject.sortSketchWidth(
obj.Base, obj.OverrideWidth, obj.ArchSketchEdges
)