From 25c1c6c3f15eda7984be7f97a4ad34cb53d35fc5 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 22 Apr 2024 11:22:43 +0200 Subject: [PATCH 1/2] Arch: Fixed move with host - fixes #13568 --- src/Mod/Arch/ArchBuildingPart.py | 47 ++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/Mod/Arch/ArchBuildingPart.py b/src/Mod/Arch/ArchBuildingPart.py index c6bffe8140..109c089c70 100644 --- a/src/Mod/Arch/ArchBuildingPart.py +++ b/src/Mod/Arch/ArchBuildingPart.py @@ -395,24 +395,23 @@ class BuildingPart(ArchIFC.IfcProduct): #print "Rotation",deltar.Axis,deltar.Angle if deltar.Angle < 0.0001: deltar = None - for child in obj.Group: - if ((not hasattr(child,"MoveWithHost")) or child.MoveWithHost) and hasattr(child,"Placement"): - #print "moving ",child.Label - if deltar: - #child.Placement.Rotation = child.Placement.Rotation.multiply(deltar) - not enough, child must also move - # use shape methods to obtain a correct placement - import Part - import math - shape = Part.Shape() - shape.Placement = child.Placement - #print("angle before rotation:",shape.Placement.Rotation.Angle) - #print("rotation angle:",math.degrees(deltar.Angle)) - shape.rotate(DraftVecUtils.tup(obj.Placement.Base), DraftVecUtils.tup(deltar.Axis), math.degrees(deltar.Angle)) - print("angle after rotation:",shape.Placement.Rotation.Angle) - child.Placement = shape.Placement - if deltap: - print("moving child",child.Label) - child.Placement.move(deltap) + for child in self.getMovableChildren(obj): + #print "moving ",child.Label + if deltar: + #child.Placement.Rotation = child.Placement.Rotation.multiply(deltar) - not enough, child must also move + # use shape methods to obtain a correct placement + import Part + import math + shape = Part.Shape() + shape.Placement = child.Placement + #print("angle before rotation:",shape.Placement.Rotation.Angle) + #print("rotation angle:",math.degrees(deltar.Angle)) + shape.rotate(DraftVecUtils.tup(obj.Placement.Base), DraftVecUtils.tup(deltar.Axis), math.degrees(deltar.Angle)) + print("angle after rotation:",shape.Placement.Rotation.Angle) + child.Placement = shape.Placement + if deltap: + print("moving child",child.Label) + child.Placement.move(deltap) def execute(self,obj): @@ -438,6 +437,18 @@ class BuildingPart(ArchIFC.IfcProduct): # update the autogroup box if needed obj.ViewObject.Proxy.onChanged(obj.ViewObject,"AutoGroupBox") + def getMovableChildren(self, obj): + "recursively get movable children" + + result = [] + for child in obj.Group: + if isinstance(child, "App::DocumentObjectGroup"): + result.extend(getMovableChildren(child) + if not hasattr(child,"MoveWithHost") or child.MoveWithHost: + if hasattr(child,"Placement"): + result.append(child) + return result + def getArea(self,obj): "computes the area of this floor by adding its inner spaces" From 951e5b63cc42c7e46c78425bf18bab137875af41 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 22 Apr 2024 15:38:16 +0200 Subject: [PATCH 2/2] arch - fixed stupid mistake in movewithhost --- src/Mod/Arch/ArchBuildingPart.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mod/Arch/ArchBuildingPart.py b/src/Mod/Arch/ArchBuildingPart.py index 109c089c70..0e85ab17e7 100644 --- a/src/Mod/Arch/ArchBuildingPart.py +++ b/src/Mod/Arch/ArchBuildingPart.py @@ -438,12 +438,12 @@ class BuildingPart(ArchIFC.IfcProduct): obj.ViewObject.Proxy.onChanged(obj.ViewObject,"AutoGroupBox") def getMovableChildren(self, obj): - "recursively get movable children" + "recursively get movable children" - result = [] - for child in obj.Group: + result = [] + for child in obj.Group: if isinstance(child, "App::DocumentObjectGroup"): - result.extend(getMovableChildren(child) + result.extend(getMovableChildren(child)) if not hasattr(child,"MoveWithHost") or child.MoveWithHost: if hasattr(child,"Placement"): result.append(child)