[BimWindow] Integrate Interactive Creation Tool with SketchArch Parametric Attachment Feature (#20872)

Improvement to User Interactive Experience:
- Now with the stock BIM Window Interactive Tool and SketchArch-addon, the required SketchArch parametric placement information of an Arch Object (Window currently) are automatically completed, no more manual input is required.

FreeCAD Forum Discussion:
- https://forum.freecad.org/viewtopic.php?p=822493#p822493

YouTube Demo:
- https://youtu.be/BNZFk03_eGE
This commit is contained in:
paul
2025-04-25 21:05:51 +08:00
committed by GitHub
parent fc90443b98
commit 39afedb077

View File

@@ -173,7 +173,7 @@ class Arch_Window:
point = point.add(FreeCAD.Vector(0,0,self.Sill))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Window"))
FreeCADGui.doCommand("import math, FreeCAD, Arch, DraftGeomUtils, WorkingPlane")
FreeCADGui.doCommand("import FreeCAD, Arch, DraftGeomUtils, WorkingPlane")
FreeCADGui.doCommand("wp = WorkingPlane.get_working_plane()")
if self.baseFace is not None:
@@ -186,6 +186,7 @@ class Arch_Window:
FreeCADGui.doCommand("pl.Base = FreeCAD.Vector(" + str(point.x) + ", " + str(point.y) + ", " + str(point.z) + ")")
if self.Preset >= len(WindowPresets):
preset = False
# library object
col = FreeCAD.ActiveDocument.Objects
path = self.librarypresets[self.Preset - len(WindowPresets)][1]
@@ -213,10 +214,22 @@ class Arch_Window:
else:
# preset
preset = True
wp = ""
for p in self.wparams:
wp += p.lower() + "=" + str(getattr(self,p)) + ", "
FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "', " + wp + "placement=pl)")
wp += ", " + p.lower() + "=" + str(getattr(self,p))
import ArchSketchObject
if hasattr(ArchSketchObject, 'attachToHost'):
# 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)")
w = FreeCADGui.Selection.getSelection()[0]
FreeCADGui.doCommand("FreeCAD.SketchArchPl = pl")
wPl = FreeCAD.SketchArchPl
SketchArch = True
else:
FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ", placement=pl)")
SketchArch = False
if self.Include:
host = None
@@ -229,6 +242,9 @@ class Arch_Window:
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)
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()