BIM: Smart removal of wall bases (#24550)
* BIM: Implement smart base removal for Walls Previously, removing the Base object from an Arch Wall would cause the wall to reset its position to the document origin and could lead to unintended geometric changes for complex walls. This commit introduces a "smart debasing" mechanism integrated into the Component Task Panel's "Remove" button: - For walls based on a single straight line, the operation now preserves the wall's global position and parametric `Length`, making it an independent object. - For walls with complex bases (multi-segment, curved), a warning dialog is now presented to the user, explaining the consequences (shape alteration and position reset) before allowing the operation to proceed. This is supported by new API functions `Arch.is_debasable()` and `Arch.debaseWall()`, which contain the core logic for the feature. Fixes: https://github.com/FreeCAD/FreeCAD/issues/24453 * BIM: Move wall debasing logic into ArchWall proxy The logic for handling the removal of a wall's base object was previously implemented directly within the generic `ComponentTaskPanel` in `ArchComponent.py`. This created a tight coupling, forcing the generic component UI to have specific knowledge about the `ArchWall` type. This commit refactors the implementation to follow a more object-oriented and polymorphic design: 1. A new overridable method, `handleComponentRemoval(subobject)`, has been added to the base `ArchComponent` proxy class. Its default implementation maintains the standard removal behavior. 2. The `_Wall` proxy class in `ArchWall.py` now overrides this method. All wall-specific debasing logic, including the eligibility check and the user-facing warning dialog, now resides entirely within this override. 3. The `ComponentTaskPanel.removeElement` method has been simplified. It is now a generic dispatcher that calls `handleComponentRemoval` on the proxy of the object being edited, with no specific knowledge of object types. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * BIM: Correct user warning The operation can indeed be undone. Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
This commit is contained in:
@@ -245,6 +245,15 @@ def removeComponents(objectsList, host=None):
|
||||
for o in objectsList:
|
||||
if o.InList:
|
||||
h = o.InList[0]
|
||||
|
||||
is_base_removal = hasattr(h, "Base") and h.Base == o
|
||||
has_handler = hasattr(h, "Proxy") and hasattr(h.Proxy, "handleComponentRemoval")
|
||||
|
||||
if is_base_removal and has_handler:
|
||||
# Dispatch to the object's own smart removal logic and skip the old code path.
|
||||
h.Proxy.handleComponentRemoval(h, o)
|
||||
continue
|
||||
|
||||
tp = Draft.getType(h)
|
||||
if tp in ["Floor", "Building", "Site", "BuildingPart"]:
|
||||
c = h.Group
|
||||
|
||||
Reference in New Issue
Block a user