diff --git a/src/Mod/BIM/ArchWindow.py b/src/Mod/BIM/ArchWindow.py index 87eacd9fea..e856bd6410 100644 --- a/src/Mod/BIM/ArchWindow.py +++ b/src/Mod/BIM/ArchWindow.py @@ -308,37 +308,6 @@ class _Window(ArchComponent.Component): obj.setEditorMode("HorizontalArea", 2) obj.setEditorMode("PerimeterLength", 2) - # SillHeight change related properties - self.setSillProperties(obj) - - def setSillProperties(self, orgObj, linkObj=None): - """Set properties which support SillHeight change. - Support both Arch Window and Link of Arch Window. - """ - - if linkObj: - obj = linkObj - else: - obj = orgObj - - prop = obj.PropertiesList - - # 'Sill' support - if not "SillHeight" in prop: - obj.addProperty( - "App::PropertyLength", - "SillHeight", - "Window", - QT_TRANSLATE_NOOP("App::Property", "The height of this window's sill"), - locked=True, - ) - - # Link has no Proxy, so needs to use PropertyPythonObject - sillProp = ["baseSill", "basePosZ", "atthOffZ"] - for i in sillProp: - if i not in prop: - obj.addProperty("App::PropertyPythonObject", i) - def onDocumentRestored(self, obj): ArchComponent.Component.onDocumentRestored(self, obj) @@ -347,19 +316,23 @@ class _Window(ArchComponent.Component): # Add features in the SketchArch External Add-on self.addSketchArchFeatures(obj, mode="ODR") - # TODO 2025.6.27 : Seems SillHeight already triggered onChanged() upon document restored - NO need codes below in onDocumentRestored() - # Need to restore 'initial' settings as corresponding codes in onChanged() does upon object creation - # self.baseSill = obj.SillHeight.Value - # self.basePos = obj.Base.Placement.Base - # self.atthOff = None - # if hasattr(obj, 'AttachmentOffsetXyzAndRotation'): - # self.atthOff = obj.AttachmentOffsetXyzAndRotation.Base - - # Sill -> SillHeight property rename migration - if hasattr(obj, "Sill"): - obj.SillHeight = obj.Sill - obj.setPropertyStatus("Sill", "-LockDynamic") - obj.removeProperty("Sill") + # During the v1.1 dev cycle an experiment with a new SillHeight handling was + # undertaken. This did not work out as intended and was therefore reverted. + # Related PRs: + # https://github.com/FreeCAD/FreeCAD/pull/21005 + # https://github.com/FreeCAD/FreeCAD/pull/23014 + # The properties that were added are removed here. Note that we do not check + # for "SillHeight" so that it is safe to use that property name in the future. + if ( + hasattr(obj, "Sill") + or hasattr(obj, "baseSill") + or hasattr(obj, "basePosZ") + or hasattr(obj, "atthOffZ") + ): + for prop in ("Sill", "SillHeight", "baseSill", "basePosZ", "atthOffZ"): + if hasattr(obj, prop): + obj.setPropertyStatus(prop, "-LockDynamic") + obj.removeProperty(prop) def loads(self, state): @@ -375,10 +348,7 @@ class _Window(ArchComponent.Component): def onChanged(self, obj, prop): self.hideSubobjects(obj, prop) - if prop == "SillHeight": - self.setSillProperties(obj) # Can't wait until onDocumentRestored - self.onSillHeightChanged(obj) - elif not "Restore" in obj.State: + if not "Restore" in obj.State: if prop in [ "Base", "WindowParts", @@ -734,72 +704,12 @@ class _Window(ArchComponent.Component): @realthunder added support to Links to run Linked Scripted Object's methods() """ - # SillHeight change support - self.setSillProperties(obj, linkObj) - # Add features in the SketchArch External Add-on self.addSketchArchFeatures(obj, linkObj) # Execute features in the SketchArch External Add-on self.executeSketchArchFeatures(obj, linkObj) - # SillHeight change feature - self.onSillHeightChanged(obj, linkObj) - - def onSillHeightChanged(self, orgObj, linkObj=None, index=None, linkElement=None): - - if linkObj: - obj = linkObj - else: - obj = orgObj - - val = getattr(obj, "SillHeight").Value - if ( - getattr(obj, "baseSill", None) is None - and getattr(obj, "basePosZ", None) is None - and getattr(obj, "atthOffZ", None) is None - ): # TODO Any cases only 1 or 2 are not None? - obj.baseSill = val - # Not to change Base's Placement, would change all Clones and - # Link's disposition unexpectedly to users, undesirable. - # - # self.basePos = obj.Base.Placement.Base - obj.basePosZ = obj.Placement.Base.z - obj.atthOffZ = None - if hasattr(obj, "AttachmentOffsetXyzAndRotation"): - obj.atthOffZ = obj.AttachmentOffsetXyzAndRotation.Base.z - return - - import ArchSketchObject # Need to import per method - - host = None - if obj.Hosts: - host = obj.Hosts[0] - if ( - hasattr(obj, "AttachToAxisOrSketch") - and obj.AttachToAxisOrSketch == "Host" - and host - and Draft.getType(host.Base) == "ArchSketch" - and hasattr(ArchSketchObject, "updateAttachmentOffset") - ): - SketchArch = True - else: - SketchArch = False - - # Keep track of change whether SketchArch is True or False (i.e. - # even Window object is not currently parametrically attached to - # a Wall or other Arch object at the moment). - # - # SketchArch or Not - if hasattr(obj, "AttachmentOffsetXyzAndRotation"): - objAttOff = obj.AttachmentOffsetXyzAndRotation - objAttOff.Base.z = obj.atthOffZ + (obj.SillHeight.Value - obj.baseSill) - obj.AttachmentOffsetXyzAndRotation = objAttOff - if not SketchArch: - # Not to change Base's Placement - # obj.Base.Placement.Base.z = self.basePos.z + (obj.Sill.Value - self.baseSill) - obj.Placement.Base.z = obj.basePosZ + (obj.SillHeight.Value - obj.baseSill) - def getSubFace(self): "returns a subface for creation of subvolume for cutting in a base object" # creation of subface from HoleWire (getSubWire) diff --git a/src/Mod/BIM/ArchWindowPresets.py b/src/Mod/BIM/ArchWindowPresets.py index aa4cd9f75b..e9bf0228af 100644 --- a/src/Mod/BIM/ArchWindowPresets.py +++ b/src/Mod/BIM/ArchWindowPresets.py @@ -42,9 +42,7 @@ WindowPresets = [ ] -def makeWindowPreset( - windowtype, width, height, h1, h2, h3, w1, w2, o1, o2, placement=None, window_sill=None -): +def makeWindowPreset(windowtype, width, height, h1, h2, h3, w1, w2, o1, o2, placement=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""" @@ -550,13 +548,6 @@ def makeWindowPreset( obj.Frame = w2 obj.Offset = o1 obj.Placement = FreeCAD.Placement() # unable to find where this bug comes from... - # If window_sill is provided, set obj.SillHeight (and trigger onChanged() - # codes to track and adjust disposition of the Window object). - # Do not set the property (to 0) and not trigger onChanged() - # if otherwise. - # obj.SillHeight = window_sill if window_sill is not None else 0 - if window_sill is not None: - obj.SillHeight = window_sill 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 451d866af2..dc153e10ab 100644 --- a/src/Mod/BIM/bimcommands/BimWindow.py +++ b/src/Mod/BIM/bimcommands/BimWindow.py @@ -288,11 +288,6 @@ class Arch_Window: # - see https://github.com/FreeCAD/FreeCAD/issues/24903#issuecomment-3475455946 # placement = FreeCAD.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(1,0,0),90)) # TODO 2025.11.1 : To improve the algorithm to be more robust to allow the Base Sketch in any orientation but without problem - # - # Window object triggers onChanged() upon setting/changing Window.SillHeight to move Window's z position - # For Window with SketchArch add-on, attachToHost() is to be run below to set the 'initial' Window's placement prior to triggering onChanged() below, - # so window_sill parameter is not used here at the moment, see 'if self.Include' below. - # FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ", window_sill=" + str(self.SillHeight.Value) + ")") FreeCADGui.doCommand( "pl90 = FreeCAD.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(1,0,0),90))" ) @@ -311,9 +306,7 @@ class Arch_Window: + WindowPresets[self.Preset] + "' " + wp - + ", placement=pl, window_sill=" - + str(self.SillHeight.Value) - + ")" + + ", placement=pl" ) FreeCADGui.doCommand("win.AttachToAxisOrSketch = 'None'") FreeCADGui.doCommand("FreeCADGui.Selection.addSelection(win)") @@ -327,9 +320,7 @@ class Arch_Window: + WindowPresets[self.Preset] + "' " + wp - + ", placement=pl, window_sill=" - + str(self.SillHeight.Value) - + ")" + + ", placement = pl)" ) SketchArch = False @@ -343,8 +334,6 @@ class Arch_Window: ) if SketchArch: ArchSketchObject.attachToHost(w, target=host, pl=wPl) - # Trigger onChanged() in the window object by setting Window.SillHeight, after setting the Window's 'initial' placement by attachToHost() above - FreeCADGui.doCommand("win.SillHeight = " + str(self.SillHeight.Value)) self.doc.commitTransaction() self.doc.recompute() diff --git a/src/Mod/BIM/bimtests/TestArchWindow.py b/src/Mod/BIM/bimtests/TestArchWindow.py index 6e2ac723a1..81f8b9f393 100644 --- a/src/Mod/BIM/bimtests/TestArchWindow.py +++ b/src/Mod/BIM/bimtests/TestArchWindow.py @@ -343,7 +343,7 @@ class TestArchWindow(TestArchBase.TestArchBase): Notes: - The clone's name is automatically generated, the `name` argument is ignored. - - The clone's WindowParts, SillHeight and other properties are always empty, despite the original having them. + - The clone's WindowParts and other properties are always empty, despite the original having them. """ sketch = self._create_sketch_with_wires("OriginalSketch", [(0, 0, 600, 800)]) @@ -352,7 +352,6 @@ class TestArchWindow(TestArchBase.TestArchBase): baseobj=sketch, parts=original_parts, name="OriginalWindow" ) original_window.Frame = 60.0 - original_window.SillHeight = 100.0 self.document.recompute() self.assertEqual(original_window.Label, "OriginalWindow")