[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
This commit is contained in:
Paul Lee
2025-05-01 09:08:47 +08:00
committed by Yorik van Havre
parent 2c9c80fefa
commit 7b078e2c96

View File

@@ -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()