From 7b078e2c96c8dda448e26d2cbdd7eef15627b6ca Mon Sep 17 00:00:00 2001 From: Paul Lee Date: Thu, 1 May 2025 09:08:47 +0800 Subject: [PATCH] [BimWindow] Interactive Creation Tool: Check if SketchArch is Enabled (ArchSketchLock) Improvement to User Interactive Experience: - The Window Interactive Tool would check if SketchArch-addon is enabled by user, i.e. if ArchSketckLock is checked. - If not, the conventional creation behaviour is used, SketchArch properties would not be added to Window object. - It also check if Base of Wall is ArchSketch or not. Github Discussion: - https://github.com/paullee0/FreeCAD_SketchArch/issues/27#issuecomment-2837652351 --- src/Mod/BIM/bimcommands/BimWindow.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Mod/BIM/bimcommands/BimWindow.py b/src/Mod/BIM/bimcommands/BimWindow.py index f390f81e2c..95dff557e7 100644 --- a/src/Mod/BIM/bimcommands/BimWindow.py +++ b/src/Mod/BIM/bimcommands/BimWindow.py @@ -187,6 +187,13 @@ class Arch_Window: FreeCADGui.doCommand("pl.Base = FreeCAD.Vector(" + str(point.x) + ", " + str(point.y) + ", " + str(point.z) + ")") + if self.baseFace is not None: + host = self.baseFace[0] + elif obj: + host = obj + else: + host = None + if self.Preset >= len(WindowPresets): preset = False # library object @@ -221,7 +228,11 @@ class Arch_Window: for p in self.wparams: wp += ", " + p.lower() + "=" + str(getattr(self,p)) import ArchSketchObject - if hasattr(ArchSketchObject, 'attachToHost'): + + if (host and Draft.getType(host.Base) == "ArchSketch" and + hasattr(ArchSketchObject, 'attachToHost') and + hasattr(FreeCAD, 'ArchSketchLock') and + FreeCAD.ArchSketchLock): # Window sketch's stay at orgin is good if addon exists FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ")") FreeCADGui.doCommand("FreeCADGui.Selection.addSelection(win)") @@ -234,19 +245,13 @@ class Arch_Window: SketchArch = False if self.Include: - host = None - if self.baseFace is not None: - host = self.baseFace[0] - elif obj: - host = obj if Draft.getType(host) in ALLOWEDHOSTS: FreeCADGui.doCommand("win.Hosts = [FreeCAD.ActiveDocument." + host.Name + "]") siblings = host.Proxy.getSiblings(host) for sibling in siblings: FreeCADGui.doCommand("win.Hosts = win.Hosts + [FreeCAD.ActiveDocument." + sibling.Name + "]") - if preset == True and Draft.getType(host.Base) == "ArchSketch": - if SketchArch: - ArchSketchObject.attachToHost(w, target=host, pl=wPl) + if SketchArch: + ArchSketchObject.attachToHost(w, target=host, pl=wPl) self.doc.commitTransaction() self.doc.recompute()