BIM: improve Arch_MergeWalls (#22262)

* BIM: improve Arch_MergeWalls

* Improve delete behavior

Keep hosted objects*, additions and subtractions if delete is False. 

* For hosted objects with a Host property this is not possible.

* Make deletion of base objects optional
This commit is contained in:
Roy-043
2025-07-07 14:51:27 +02:00
committed by GitHub
parent e6e1d6c54e
commit 236bec9aa9

View File

@@ -1691,7 +1691,7 @@ def makeWall(
return wall
def joinWalls(walls, delete=False):
def joinWalls(walls, delete=False, deletebase=False):
"""Join the given list of walls into one sketch-based wall.
Take the first wall in the list, and adds on the other walls in the list.
@@ -1707,6 +1707,9 @@ def joinWalls(walls, delete=False):
be based off a base object.
delete : bool, optional
If True, deletes the other walls in the list. Defaults to False.
deletebase : bool, optional
If True, and delete is True, the base of the other walls is also deleted
Defaults to False.
Returns
-------
@@ -1745,14 +1748,39 @@ def joinWalls(walls, delete=False):
else:
sk = base.Base
for w in walls:
if w.Base:
if not w.Base.Shape.Faces:
for e in w.Base.Shape.Edges:
l = e.Curve
if isinstance(l, Part.Line):
l = Part.LineSegment(e.Vertexes[0].Point, e.Vertexes[-1].Point)
sk.addGeometry(l)
deleteList.append(w.Name)
if w.Base and not w.Base.Shape.Faces:
for hostedObj in w.Proxy.getHosts(w):
if hasattr(hostedObj, "Host"):
hostedObj.Host = base
else:
tmp = hostedObj.Hosts
if delete:
tmp.remove(w)
if not base in tmp:
tmp.append(base)
hostedObj.Hosts = tmp
tmp = []
for add in w.Additions:
if not add in base.Additions:
tmp.append(add)
if delete:
w.Additions = None
base.Additions += tmp
tmp = []
for sub in w.Subtractions:
if not sub in base.Subtractions:
tmp.append(sub)
if delete:
w.Subtractions = None
base.Subtractions += tmp
for e in w.Base.Shape.Edges:
l = e.Curve
if isinstance(l, Part.Line):
l = Part.LineSegment(e.Vertexes[0].Point, e.Vertexes[-1].Point)
sk.addGeometry(l)
deleteList.append(w.Name)
if deletebase:
deleteList.append(w.Base.Name)
if delete:
for n in deleteList:
FreeCAD.ActiveDocument.removeObject(n)