From 2c9c80fefa6b942d3d9e7d437c65f33c86839730 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Fri, 25 Apr 2025 19:56:57 +0200 Subject: [PATCH] BIM: Allow changing Sill parameter in Properties for Window User has no possibility to change Sill parameter upon adding Window, it is only possible while creating Window for the first time. So this patch adds this parameter, and changing it moves the *BASE* coordinate of the object in Z direction. --- src/Mod/BIM/ArchWindow.py | 16 +++++++++++++++- src/Mod/BIM/ArchWindowPresets.py | 4 ++-- src/Mod/BIM/bimcommands/BimWindow.py | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Mod/BIM/ArchWindow.py b/src/Mod/BIM/ArchWindow.py index a7de740d6a..0ecb13645d 100644 --- a/src/Mod/BIM/ArchWindow.py +++ b/src/Mod/BIM/ArchWindow.py @@ -105,6 +105,10 @@ class _Window(ArchComponent.Component): # Add features in the SketchArch External Add-on self.addSketchArchFeatures(obj) + # Initialize those two values later on during first onChanged call + self.baseSill = None + self.basePos = None + def addSketchArchFeatures(self,obj,linkObj=None,mode=None): ''' To add features in the SketchArch External Add-on (https://github.com/paullee0/FreeCAD_SketchArch) @@ -137,6 +141,8 @@ class _Window(ArchComponent.Component): obj.addProperty("App::PropertyLength","Width","Window",QT_TRANSLATE_NOOP("App::Property","The width of this window"), locked=True) if not "Height" in lp: obj.addProperty("App::PropertyLength","Height","Window",QT_TRANSLATE_NOOP("App::Property","The height of this window"), locked=True) + if not "Sill" in lp: + obj.addProperty("App::PropertyLength","Sill","Window",QT_TRANSLATE_NOOP("App::Property","The height of this window's sill"), locked=True) if not "Normal" in lp: obj.addProperty("App::PropertyVector","Normal","Window",QT_TRANSLATE_NOOP("App::Property","The normal direction of this window"), locked=True) if not "Preset" in lp: @@ -183,7 +189,15 @@ class _Window(ArchComponent.Component): def onChanged(self,obj,prop): self.hideSubobjects(obj,prop) - if not "Restore" in obj.State: + if prop == "Sill": + val = getattr(obj,prop).Value + if getattr(self, 'baseSill', None) is None and getattr(self, 'basePos', None) is None: + self.baseSill = val + self.basePos = obj.Base.Placement.Base + return + + obj.Base.Placement.Base.z = self.basePos.z + (obj.Sill.Value - self.baseSill) + elif not "Restore" in obj.State: if prop in ["Base","WindowParts","Placement","HoleDepth","Height","Width","Hosts","Shape"]: # anti-recursive loops, bc the base sketch will touch the Placement all the time touchhosts = False diff --git a/src/Mod/BIM/ArchWindowPresets.py b/src/Mod/BIM/ArchWindowPresets.py index a20b9bcd5e..cbf03e090b 100644 --- a/src/Mod/BIM/ArchWindowPresets.py +++ b/src/Mod/BIM/ArchWindowPresets.py @@ -31,8 +31,7 @@ from draftutils.translate import translate WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane", "Sliding 2-pane", "Simple door", "Glass door", "Sliding 4-pane", "Awning", "Opening only"] -def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None): - +def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None,window_sill=None): """makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,[placement]): makes a window object based on the given data. windowtype must be one of the names defined in Arch.WindowPresets""" @@ -516,6 +515,7 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None obj.Frame = w2 obj.Offset = o1 obj.Placement = FreeCAD.Placement() # unable to find where this bug comes from... + obj.Sill = window_sill if window_sill is not None else 0 if "door" in windowtype.lower(): obj.IfcType = "Door" obj.Label = translate("Arch","Door") diff --git a/src/Mod/BIM/bimcommands/BimWindow.py b/src/Mod/BIM/bimcommands/BimWindow.py index 3652c002d4..f390f81e2c 100644 --- a/src/Mod/BIM/bimcommands/BimWindow.py +++ b/src/Mod/BIM/bimcommands/BimWindow.py @@ -230,7 +230,7 @@ class Arch_Window: wPl = FreeCAD.SketchArchPl SketchArch = True else: - FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ", placement=pl)") + FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ", placement=pl, window_sill=" + str(self.Sill.Value) + ")") SketchArch = False if self.Include: