From 2f07f13e9dfd7800d40b5be459f3435bebefc7bb Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 7 Oct 2019 15:33:28 -0300 Subject: [PATCH] Arch: Adjust height of objects inside groups --- src/Mod/Arch/ArchBuildingPart.py | 17 ++++++++++++----- src/Mod/Arch/ArchComponent.py | 16 ++++++++++++++++ src/Mod/Arch/ArchStructure.py | 5 +---- src/Mod/Arch/ArchWall.py | 5 +---- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/Mod/Arch/ArchBuildingPart.py b/src/Mod/Arch/ArchBuildingPart.py index 5bfade5c82..837f87a36f 100644 --- a/src/Mod/Arch/ArchBuildingPart.py +++ b/src/Mod/Arch/ArchBuildingPart.py @@ -377,11 +377,7 @@ class BuildingPart(ArchIFC.IfcProduct): self.shapecache = None if (prop == "Height") and obj.Height.Value: - for child in obj.Group: - if Draft.getType(child) in ["Wall","Structure"]: - if not child.Height.Value: - print("Executing ",child.Label) - child.Proxy.execute(child) + self.touchChildren(obj) elif prop == "Placement": if hasattr(self,"oldPlacement"): @@ -461,6 +457,17 @@ class BuildingPart(ArchIFC.IfcProduct): g.append(o) return g + def touchChildren(self,obj): + + "Touches all descendents where applicable" + + for child in obj.Group: + if Draft.getType(child) in ["Wall","Structure"]: + if not child.Height.Value: + print("Executing ",child.Label) + child.Proxy.execute(child) + elif Draft.getType(child) in ["Group"]: + self.touchChildren(child) class ViewProviderBuildingPart: diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index ded738bdd3..c4530a5107 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -269,6 +269,22 @@ class Component(ArchIFC.IfcProduct): ilist2.append(o) return ilist2 + def getParentHeight(self,obj): + + "gets a height value from a host BuildingPart" + + for parent in obj.InList: + if Draft.getType(parent) in ["Floor","BuildingPart"]: + if obj in parent.Group: + if parent.Height.Value: + return parent.Height.Value + # not found? get one level higher + for parent in obj.InList: + if hasattr(parent,"Group"): + if obj in parent.Group: + return self.getParentHeight(parent) + return 0 + def clone(self,obj): "if this object is a clone, sets the shape. Returns True if this is the case" diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index b18c787005..d7100dddad 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -730,10 +730,7 @@ class _Structure(ArchComponent.Component): height = obj.Height.Value normal = None if not height: - for p in obj.InList: - if Draft.getType(p) in ["Floor","BuildingPart"]: - if p.Height.Value: - height = p.Height.Value + height = self.getParentHeight(obj) base = None placement = None if obj.Base: diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index 324ce68b19..7a1f99db3f 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -816,10 +816,7 @@ class _Wall(ArchComponent.Component): height = obj.Height.Value if not height: - for p in obj.InList: - if Draft.getType(p) in ["Floor","BuildingPart"]: - if p.Height.Value: - height = p.Height.Value + height = self.getParentHeight(obj) if not height: return None if obj.Normal == Vector(0,0,0):