From 93b53af0d146affd42b042ec1af8f4d047f167ae Mon Sep 17 00:00:00 2001 From: paul <40677073+paullee0@users.noreply.github.com> Date: Tue, 3 Jun 2025 17:15:18 +0800 Subject: [PATCH] [BimWindow] ArchWindow/MakeWindow Normal Default Auto & SketchArch Support Sill Property (#21568) https://github.com/FreeCAD/FreeCAD/pull/21261 Historically, the normal of a Window object was deduced by the orientation of the Base Sketch and hardcoded in the Normal property. Now with the new AutoNormalReversed property/flag (above PR), set True as default, the auto Normal previously in opposite direction to is now consistent with that previously hardcoded. With the normal set to 'auto', window object would not suffer weird shape if the Base Sketch is rotated by some reason. The Normal property is set to 'auto' (0,0,0) default following the above PR. https://github.com/FreeCAD/FreeCAD/pull/21005 BIM: Allow changing Sill parameter in Properties for Window #21005 Ground work is added to support Window augmented by SketchArch Parametric Placement feature (PR to ArchWindow.py to be submitted separately) --- src/Mod/BIM/Arch.py | 7 ++++++- src/Mod/BIM/bimcommands/BimWindow.py | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Mod/BIM/Arch.py b/src/Mod/BIM/Arch.py index 169a0c292b..afbb401841 100644 --- a/src/Mod/BIM/Arch.py +++ b/src/Mod/BIM/Arch.py @@ -1785,7 +1785,12 @@ def makeWindow(baseobj=None, width=None, height=None, parts=None, name=None): if height: window.Height = height if baseobj: - window.Normal = baseobj.Placement.Rotation.multVec(FreeCAD.Vector(0, 0, -1)) + # 2025.5.25 + # Historically, this normal was deduced by the orientation of the Base Sketch and hardcoded in the Normal property. + # Now with the new AutoNormalReversed property/flag, set True as default, the auto Normal previously in opposite direction to is now consistent with that previously hardcoded. + # With the normal set to 'auto', window object would not suffer weird shape if the Base Sketch is rotated by some reason. + # Keep the property be 'auto' (0,0,0) here. + #obj.Normal = baseobj.Placement.Rotation.multVec(FreeCAD.Vector(0, 0, -1)) window.Base = baseobj if parts is not None: window.WindowParts = parts diff --git a/src/Mod/BIM/bimcommands/BimWindow.py b/src/Mod/BIM/bimcommands/BimWindow.py index 95dff557e7..451d97b566 100644 --- a/src/Mod/BIM/bimcommands/BimWindow.py +++ b/src/Mod/BIM/bimcommands/BimWindow.py @@ -210,7 +210,12 @@ class Arch_Window: break FreeCADGui.doCommand("win = FreeCAD.ActiveDocument.getObject('" + o.Name + "')") FreeCADGui.doCommand("win.Base.Placement = pl") - FreeCADGui.doCommand("win.Normal = pl.Rotation.multVec(FreeCAD.Vector(0, 0, -1))") + # 2025.5.25 + # Historically, this normal was deduced by the orientation of the Base Sketch and hardcoded in the Normal property. + # Now with the new AutoNormalReversed property/flag, set True as default, the auto Normal previously in opposite direction to is now consistent with that previously hardcoded. + # With the normal set to 'auto', window object would not suffer weird shape if the Base Sketch is rotated by some reason. + # Keep the property be 'auto' (0,0,0) here. + #FreeCADGui.doCommand("win.Normal = pl.Rotation.multVec(FreeCAD.Vector(0, 0, -1))") FreeCADGui.doCommand("win.Width = " + str(self.Width)) FreeCADGui.doCommand("win.Height = " + str(self.Height)) FreeCADGui.doCommand("win.Base.recompute()") @@ -233,8 +238,13 @@ class Arch_Window: 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 + ")") + if self.Include: + # Window base sketch's placement stay at orgin is good if addon exists and self.Include + FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ", window_sill=" + str(self.Sill.Value) + ")") + else: + # Window base sketch's placement follow getPoint placement if addon exists but NOT self.Include + FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ", placement=pl, window_sill=" + str(self.Sill.Value) + ")") + FreeCADGui.doCommand("win.AttachToAxisOrSketch = 'None'") FreeCADGui.doCommand("FreeCADGui.Selection.addSelection(win)") w = FreeCADGui.Selection.getSelection()[0] FreeCADGui.doCommand("FreeCAD.SketchArchPl = pl")