BIM: Allow changing Sill parameter in Properties for Window
User has no possibility to change Sill parameter upon adding Window, it is only possible while creating Window for the first time. So this patch adds this parameter, and changing it moves the *BASE* coordinate of the object in Z direction.
This commit is contained in:
committed by
Yorik van Havre
parent
1de7024a43
commit
2c9c80fefa
@@ -105,6 +105,10 @@ class _Window(ArchComponent.Component):
|
||||
# Add features in the SketchArch External Add-on
|
||||
self.addSketchArchFeatures(obj)
|
||||
|
||||
# Initialize those two values later on during first onChanged call
|
||||
self.baseSill = None
|
||||
self.basePos = None
|
||||
|
||||
def addSketchArchFeatures(self,obj,linkObj=None,mode=None):
|
||||
'''
|
||||
To add features in the SketchArch External Add-on (https://github.com/paullee0/FreeCAD_SketchArch)
|
||||
@@ -137,6 +141,8 @@ class _Window(ArchComponent.Component):
|
||||
obj.addProperty("App::PropertyLength","Width","Window",QT_TRANSLATE_NOOP("App::Property","The width of this window"), locked=True)
|
||||
if not "Height" in lp:
|
||||
obj.addProperty("App::PropertyLength","Height","Window",QT_TRANSLATE_NOOP("App::Property","The height of this window"), locked=True)
|
||||
if not "Sill" in lp:
|
||||
obj.addProperty("App::PropertyLength","Sill","Window",QT_TRANSLATE_NOOP("App::Property","The height of this window's sill"), locked=True)
|
||||
if not "Normal" in lp:
|
||||
obj.addProperty("App::PropertyVector","Normal","Window",QT_TRANSLATE_NOOP("App::Property","The normal direction of this window"), locked=True)
|
||||
if not "Preset" in lp:
|
||||
@@ -183,7 +189,15 @@ class _Window(ArchComponent.Component):
|
||||
def onChanged(self,obj,prop):
|
||||
|
||||
self.hideSubobjects(obj,prop)
|
||||
if not "Restore" in obj.State:
|
||||
if prop == "Sill":
|
||||
val = getattr(obj,prop).Value
|
||||
if getattr(self, 'baseSill', None) is None and getattr(self, 'basePos', None) is None:
|
||||
self.baseSill = val
|
||||
self.basePos = obj.Base.Placement.Base
|
||||
return
|
||||
|
||||
obj.Base.Placement.Base.z = self.basePos.z + (obj.Sill.Value - self.baseSill)
|
||||
elif not "Restore" in obj.State:
|
||||
if prop in ["Base","WindowParts","Placement","HoleDepth","Height","Width","Hosts","Shape"]:
|
||||
# anti-recursive loops, bc the base sketch will touch the Placement all the time
|
||||
touchhosts = False
|
||||
|
||||
@@ -31,8 +31,7 @@ from draftutils.translate import translate
|
||||
WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane", "Sliding 2-pane",
|
||||
"Simple door", "Glass door", "Sliding 4-pane", "Awning", "Opening only"]
|
||||
|
||||
def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None):
|
||||
|
||||
def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None,window_sill=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"""
|
||||
@@ -516,6 +515,7 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None
|
||||
obj.Frame = w2
|
||||
obj.Offset = o1
|
||||
obj.Placement = FreeCAD.Placement() # unable to find where this bug comes from...
|
||||
obj.Sill = window_sill if window_sill is not None else 0
|
||||
if "door" in windowtype.lower():
|
||||
obj.IfcType = "Door"
|
||||
obj.Label = translate("Arch","Door")
|
||||
|
||||
@@ -230,7 +230,7 @@ class Arch_Window:
|
||||
wPl = FreeCAD.SketchArchPl
|
||||
SketchArch = True
|
||||
else:
|
||||
FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ", placement=pl)")
|
||||
FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "' " + wp + ", placement=pl, window_sill=" + str(self.Sill.Value) + ")")
|
||||
SketchArch = False
|
||||
|
||||
if self.Include:
|
||||
|
||||
Reference in New Issue
Block a user