diff --git a/src/Mod/BIM/Arch.py b/src/Mod/BIM/Arch.py index a017c96181..614ca38cb5 100644 --- a/src/Mod/BIM/Arch.py +++ b/src/Mod/BIM/Arch.py @@ -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)