diff --git a/src/Mod/Arch/Arch.py b/src/Mod/Arch/Arch.py index 99216f7598..05890af2d4 100644 --- a/src/Mod/Arch/Arch.py +++ b/src/Mod/Arch/Arch.py @@ -49,6 +49,7 @@ from ArchProfile import * from ArchCommands import * from ArchSectionPlane import * from ArchWindow import * +from ArchWindowPresets import * from ArchAxis import * from ArchRoof import * from ArchSpace import * diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index bea21f3c07..e6b9079365 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -172,7 +172,7 @@ class Component(ArchIFC.IfcProduct): ---------- obj: The object to turn into an Arch Component - """ + """ def __init__(self, obj): obj.Proxy = self @@ -275,7 +275,7 @@ class Component(ArchIFC.IfcProduct): return None def onBeforeChange(self,obj,prop): - """Method called before the object has a property changed. + """Method called before the object has a property changed. Specifically, this method is called before the value changes. @@ -392,7 +392,7 @@ class Component(ArchIFC.IfcProduct): The Height value of the found Floor or BuildingPart. """ - + for parent in obj.InList: if Draft.getType(parent) in ["Floor","BuildingPart"]: if obj in parent.Group: @@ -476,7 +476,7 @@ class Component(ArchIFC.IfcProduct): Recursively scrape the Bases of the object, until a Base that is derived from a is found. From there, copy the - extrusion to the (0,0,0) origin. + extrusion to the (0,0,0) origin. With this copy, get the the shape was originally extruded from, the of the extrusion, and the @@ -645,7 +645,7 @@ class Component(ArchIFC.IfcProduct): """Hides Additions and Subtractions of this Component when that list changes. Intended to be used in conjunction with the .onChanged() method, to - access the property that has changed. + access the property that has changed. When an object loses or gains an Addition, this method hides all Additions. When it gains or loses a Subtraction, this method hides all @@ -697,7 +697,7 @@ class Component(ArchIFC.IfcProduct): The base shape to add Additions and Subtractions to. placement: , optional Prior to adding or subtracting subshapes, the of - the subshapes are multiplied by the inverse of this parameter. + the subshapes are multiplied by the inverse of this parameter. Returns ------- @@ -753,41 +753,44 @@ class Component(ArchIFC.IfcProduct): # treat subtractions subs = obj.Subtractions - for link in obj.InList: + for link in obj.InListRecursive: if hasattr(link,"Hosts"): for host in link.Hosts: if host == obj: subs.append(link) + elif hasattr(link,"Host"): + if link.Host == obj: + subs.append(link) for o in subs: - if base: if base.isNull(): base = None if base: + subvolume = None if (Draft.getType(o) == "Window") or (Draft.isClone(o,"Window",True)): # windows can be additions or subtractions, treated the same way - f = o.Proxy.getSubVolume(o) - if f: - if base.Solids and f.Solids: - if placement: - f.Placement = f.Placement.multiply(placement) - if len(base.Solids) > 1: - base = Part.makeCompound([sol.cut(f) for sol in base.Solids]) - else: - base = base.cut(f) - + subvolume = o.Proxy.getSubVolume(o) elif (Draft.getType(o) == "Roof") or (Draft.isClone(o,"Roof")): # roofs define their own special subtraction volume - f = o.Proxy.getSubVolume(o) - if f: - if base.Solids and f.Solids: - if len(base.Solids) > 1: - base = Part.makeCompound([sol.cut(f) for sol in base.Solids]) - else: - base = base.cut(f) + subvolume = o.Proxy.getSubVolume(o) + elif hasattr(o,"Subvolume") and hasattr(o.Subvolume,"Shape"): + # Any other object with a Subvolume property + subvolume = o.Subvolume.Shape.copy() + if hasattr(o,"Placement"): + subvolume.Placement = subvolume.Placement.multiply(o.Placement) + + if subvolume: + if base.Solids and subvolume.Solids: + if placement: + subvolume.Placement = subvolume.Placement.multiply(placement) + if len(base.Solids) > 1: + base = Part.makeCompound([sol.cut(subvolume) for sol in base.Solids]) + else: + base = base.cut(subvolume) elif hasattr(o,'Shape'): + # no subvolume, we subtract the whole shape if o.Shape: if not o.Shape.isNull(): if o.Shape.Solids and base.Solids: @@ -941,7 +944,7 @@ class Component(ArchIFC.IfcProduct): """Compute the area properties of the object's shape. Compute the vertical area, horizontal area, and perimeter length of - the object's shape. + the object's shape. The vertical area is the surface area of the faces perpendicular to the ground. @@ -1101,6 +1104,30 @@ class Component(ArchIFC.IfcProduct): # - must have an IfcWindowType and IfcRelFillsElement (to be implemented in IFC exporter) return False + def getHosts(self,obj): + """Return the objects that have this one as host, + that is, objects with a "Host" property pointing + at this object, or a "Hosts" property containing + this one. + + Returns + ------- + list of + The Arch Structures hosting this component. + """ + + hosts = [] + for link in obj.InListRecursive: + if hasattr(link,"Host"): + if link.Host: + if link.Host == obj: + hosts.append(link) + elif hasattr(link,"Hosts"): + for host in link.Hosts: + if host == obj: + hosts.append(link) + return hosts + class ViewProviderComponent: """A default View Provider for Component objects. @@ -1112,13 +1139,13 @@ class ViewProviderComponent: ---------- vobj: The view provider to turn into a component view provider. - """ + """ def __init__(self,vobj): vobj.Proxy = self self.Object = vobj.Object self.setProperties(vobj) - + def setProperties(self,vobj): """Give the component view provider its component view provider specific properties. @@ -1242,7 +1269,7 @@ class ViewProviderComponent: d = vobj.DiffuseColor vobj.DiffuseColor = d elif prop == "Visibility": - for host in self.getHosts(): + for host in vobj.Object.Proxy.getHosts(vobj.Object): if hasattr(host, 'ViewObject'): host.ViewObject.Visibility = vobj.Visibility @@ -1252,7 +1279,7 @@ class ViewProviderComponent: """Add display modes' data to the coin scenegraph. Add each display mode as a coin node, whose parent is this view - provider. + provider. Each display mode's node includes the data needed to display the object in that mode. This might include colors of faces, or the draw style of @@ -1304,7 +1331,7 @@ class ViewProviderComponent: When HiRes is set as display mode, display the component as a copy of the mesh associated as the HiRes property of the host object. See - ArchComponent.Component's properties. + ArchComponent.Component's properties. If no shape is set in the HiRes property, just display the object as the Flat Lines display mode. @@ -1414,8 +1441,9 @@ class ViewProviderComponent: objlink = getattr(self.Object,link) if objlink: c.append(objlink) - for link in self.getHosts(): - c.append(link) + if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("ClaimHosted",True): + for link in self.Object.Proxy.getHosts(self.Object): + c.append(link) return c return [] @@ -1527,39 +1555,11 @@ class ViewProviderComponent: """ if obj.CloneOf: - if (self.areDifferentColors(obj.ViewObject.DiffuseColor, - obj.CloneOf.ViewObject.DiffuseColor) + if (self.areDifferentColors(obj.ViewObject.DiffuseColor, + obj.CloneOf.ViewObject.DiffuseColor) or force): obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor - - def getHosts(self): - """Return the hosts of the view provider's host object. - - Note that in this case, the hosts are the objects referenced by Arch - Rebar's "Host" and/or "Hosts" properties specifically. Only Arch Rebar - has these properties. - - Returns - ------- - list of - The Arch Structures hosting this component. - """ - - hosts = [] - - if hasattr(self,"Object"): - for link in self.Object.InList: - if hasattr(link,"Host"): - if link.Host: - if link.Host == self.Object: - hosts.append(link) - elif hasattr(link,"Hosts"): - for host in link.Hosts: - if host == self.Object: - hosts.append(link) - - return hosts class ArchSelectionObserver: @@ -1660,7 +1660,7 @@ class SelectionTaskPanel: def reject(self): """The method run when the user selects the cancel button.""" - + if hasattr(FreeCAD,"ArchObserver"): FreeCADGui.Selection.removeObserver(FreeCAD.ArchObserver) del FreeCAD.ArchObserver @@ -2062,7 +2062,7 @@ class ComponentTaskPanel: def acceptIfcProperties(self): """This method runs as a callback when the user selects the ok button in the IFC editor. - + Scrape through the rows of the IFC editor's items, and compare them to the object being edited's .IfcData. If the two are different, change the object's .IfcData to match the editor's items. @@ -2159,7 +2159,7 @@ class ComponentTaskPanel: def addIfcPset(self,idx=0): """Add an IFC property set to the object, within the IFC editor. - + This method runs as a callback when the user selects a property set within the Add property set dropdown. @@ -2265,7 +2265,7 @@ if FreeCAD.GuiUp: ---------- parent: The table cell that is being edited. - option: + option: Unused? index: The index object of the table of the IFC editor. diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index a3051e6661..4f64a65f8c 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -22,6 +22,7 @@ import os import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands +import ArchWindowPresets from FreeCAD import Units from FreeCAD import Vector if FreeCAD.GuiUp: @@ -54,11 +55,9 @@ __url__ = "http://www.freecadweb.org" # presets WindowPartTypes = ["Frame","Solid panel","Glass panel","Louvre"] AllowedHosts = ["Wall","Structure","Roof"] -WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane", - "Sliding 2-pane", "Simple door", "Glass door", "Sliding 4-pane"] WindowOpeningModes = ["None","Arc 90","Arc 90 inv","Arc 45","Arc 45 inv","Arc 180", "Arc 180 inv","Triangle","Triangle inv","Sliding","Sliding inv"] - +WindowPresets = ArchWindowPresets.WindowPresets def makeWindow(baseobj=None,width=None,height=None,parts=None,name="Window"): @@ -101,6 +100,13 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name="Window"): ws += "Wire" + str(i) i += 1 obj.WindowParts = ["Default","Frame",ws,"1","0"] + else: + # bind properties from base obj if existing + for prop in ["Height","Width","Subvolume","Tag","Description","Material"]: + for p in baseobj.PropertiesList: + if (p == prop) or p.endswith("_"+prop): + obj.setExpression(prop, baseobj.Name+"."+p) + if obj.Base and FreeCAD.GuiUp: obj.Base.ViewObject.DisplayMode = "Wireframe" obj.Base.ViewObject.hide() @@ -108,475 +114,26 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name="Window"): todo.delay(recolorize,[obj.Document.Name,obj.Name]) return obj -def recolorize(names): # names is [docname,objname] +def recolorize(attr): # names is [docname,objname] - if names[0] in FreeCAD.listDocuments(): - doc = FreeCAD.getDocument(names[0]) - obj = doc.getObject(names[1]) - if obj: - if obj.ViewObject: - if obj.ViewObject.Proxy: - obj.ViewObject.Proxy.colorize(obj,force=True) + """Recolorizes an object or a [documentname,objectname] list + This basically calls the Proxy.colorize(obj) methods of objects that + have one.""" -def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None): + if isinstance(attr,list): + if attr[0] in FreeCAD.listDocuments(): + doc = FreeCAD.getDocument(attr[0]) + obj = doc.getObject(attr[1]) + if obj: + if obj.ViewObject: + if obj.ViewObject.Proxy: + obj.ViewObject.Proxy.colorize(obj,force=True) + elif hasattr(attr,"ViewObject") and attr.ViewObject: + obj = attr + if hasattr(obj.ViewObject,"Proxy") and hasattr(obj.ViewObject.Proxy,"colorize"): + obj.ViewObject.Proxy.colorize(obj,force=True) - """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""" - if not FreeCAD.ActiveDocument: - FreeCAD.Console.PrintError("No active document. Aborting\n") - return - - def makeSketch(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2): - - import Part,Sketcher - width = float(width) - height = float(height) - h1 = float(h1) - h2 = float(h2) - h3 = float(h3) - w1 = float(w1) - w2 = float(w2) - o1 = float(o1) - o2 = float(o2) - # small spacing to avoid wrong auto-wires in sketch - tol = h1/10 - # glass size divider - gla = 10 - s = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Sketch') - - def addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8): - - "adds two rectangles to the given sketch" - - idx = s.GeometryCount - s.addGeometry(Part.LineSegment(p1,p2)) - s.addGeometry(Part.LineSegment(p2,p3)) - s.addGeometry(Part.LineSegment(p3,p4)) - s.addGeometry(Part.LineSegment(p4,p1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx,2,idx+1,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+1,2,idx+2,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+2,2,idx+3,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+3,2,idx,1)) - s.addConstraint(Sketcher.Constraint('Horizontal',idx)) - s.addConstraint(Sketcher.Constraint('Horizontal',idx+2)) - s.addConstraint(Sketcher.Constraint('Vertical',idx+1)) - s.addConstraint(Sketcher.Constraint('Vertical',idx+3)) - s.addGeometry(Part.LineSegment(p5,p6)) - s.addGeometry(Part.LineSegment(p6,p7)) - s.addGeometry(Part.LineSegment(p7,p8)) - s.addGeometry(Part.LineSegment(p8,p5)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+4,2,idx+5,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+5,2,idx+6,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+6,2,idx+7,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+7,2,idx+4,1)) - s.addConstraint(Sketcher.Constraint('Horizontal',idx+4)) - s.addConstraint(Sketcher.Constraint('Horizontal',idx+6)) - s.addConstraint(Sketcher.Constraint('Vertical',idx+5)) - s.addConstraint(Sketcher.Constraint('Vertical',idx+7)) - - def outerFrame(s,width,height,h1,w1,o1): - - p1 = Vector(0,0,0) - p2 = Vector(width,0,0) - p3 = Vector(width,height,0) - p4 = Vector(0,height,0) - p5 = Vector(h1,h1,0) - p6 = Vector(width-h1,h1,0) - p7 = Vector(width-h1,height-h1,0) - p8 = Vector(h1,height-h1,0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceY',1,height)) #16 - s.addConstraint(Sketcher.Constraint('DistanceX',0,width)) #17 - s.renameConstraint(16, 'Height') - s.renameConstraint(17, 'Width') - s.addConstraint(Sketcher.Constraint('DistanceY',6,2,2,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceX',2,2,6,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,2,0,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceY',0,2,4,2,h1)) - s.renameConstraint(18, 'Frame1') - s.renameConstraint(19, 'Frame2') - s.renameConstraint(20, 'Frame3') - s.renameConstraint(21, 'Frame4') - s.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) - return ["OuterFrame","Frame","Wire0,Wire1",str(w1-w2)+"+V","0.00+V"] - - def doorFrame(s,width,height,h1,w1,o1): - - p1 = Vector(0,0,0) - p2 = Vector(width,0,0) - p3 = Vector(width,height,0) - p4 = Vector(0,height,0) - p5 = Vector(h1,0,0) - p6 = Vector(width-h1,0,0) - p7 = Vector(width-h1,height-h1,0) - p8 = Vector(h1,height-h1,0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceY',1,height)) #16 - s.addConstraint(Sketcher.Constraint('DistanceX',0,width)) #17 - s.renameConstraint(16, 'Height') - s.renameConstraint(17, 'Width') - s.addConstraint(Sketcher.Constraint('DistanceY',6,2,2,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceX',2,2,6,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,2,0,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceY',0,2,4,2,0.0)) - s.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) - s.renameConstraint(18, 'Frame1') - s.renameConstraint(19, 'Frame2') - s.renameConstraint(20, 'Frame3') - return ["OuterFrame","Frame","Wire0,Wire1",str(w1-w2)+"+V","0.00+V"] - - if windowtype == "Fixed": - - wp = outerFrame(s,width,height,h1,w1,o1) - wp.extend(["Glass","Glass panel","Wire1",str(w1/gla),str(w1/2)+"+V"]) - - elif windowtype == "Open 1-pane": - - wp = outerFrame(s,width,height,h1,w1,o1) - p1 = Vector(h1+tol,h1+tol,0) - p2 = Vector(width-(h1+tol),h1+tol,0) - p3 = Vector(width-(h1+tol),height-(h1+tol),0) - p4 = Vector(h1+tol,height-(h1+tol),0) - p5 = Vector(h1+h2,h1+h2,0) - p6 = Vector(width-(h1+h2),h1+h2,0) - p7 = Vector(width-(h1+h2),height-(h1+h2),0) - p8 = Vector(h1+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',10,1,6,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,1,6,1,tol)) - if h2 == h1: - s.renameConstraint(39,'Frame5') - s.renameConstraint(40,'Frame6') - s.renameConstraint(42,'Frame7') - s.renameConstraint(41,'Frame8') - fw = str(w2) - if w2 == w1: - fw = "0.00+V" - wp.extend(["InnerFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) - wp.extend(["InnerGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) - - elif windowtype == "Open 2-pane": - - wp = outerFrame(s,width,height,h1,w1,o1) - p1 = Vector(h1+tol,h1+tol,0) - p2 = Vector((width/2)-tol,h1+tol,0) - p3 = Vector((width/2)-tol,height-(h1+tol),0) - p4 = Vector(h1+tol,height-(h1+tol),0) - p5 = Vector(h1+h2,h1+h2,0) - p6 = Vector((width/2)-h2,h1+h2,0) - p7 = Vector((width/2)-h2,height-(h1+h2),0) - p8 = Vector(h1+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - p1 = Vector((width/2)+tol,h1+tol,0) - p2 = Vector(width-(h1+tol),h1+tol,0) - p3 = Vector(width-(h1+tol),height-(h1+tol),0) - p4 = Vector((width/2)+tol,height-(h1+tol),0) - p5 = Vector((width/2)+h2,h1+h2,0) - p6 = Vector(width-(h1+h2),h1+h2,0) - p7 = Vector(width-(h1+h2),height-(h1+h2),0) - p8 = Vector((width/2)+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('Equal',22,14)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,1,18,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',9,1,19,2,tol)) - s.addConstraint(Sketcher.Constraint('PointOnObject',13,2,22)) - s.addConstraint(Sketcher.Constraint('PointOnObject',20,1,12)) - if h1 == h2: - s.renameConstraint(55,'Frame5') - s.renameConstraint(56,'Frame6') - s.renameConstraint(57,'Frame7') - s.renameConstraint(58,'Frame8') - s.renameConstraint(59,'Frame9') - s.renameConstraint(60,'Frame10') - fw = str(w2) - if w2 == w1: - fw = "0.00+V" - wp.extend(["LeftFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) - wp.extend(["LeftGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) - wp.extend(["RightFrame","Frame","Wire4,Wire5",fw,str(o2)+"+V"]) - wp.extend(["RightGlass","Glass panel","Wire5",str(w2/gla),str(o2+w2/2)+"+V"]) - - elif windowtype == "Sash 2-pane": - - wp = outerFrame(s,width,height,h1,w1,o1) - p1 = Vector(h1+tol,h1+tol,0) - p2 = Vector(width-(h1+tol),h1+tol,0) - p3 = Vector(width-(h1+tol),(height/2)-tol,0) - p4 = Vector(h1+tol,(height/2)-tol,0) - p5 = Vector(h1+h2,h1+h2,0) - p6 = Vector(width-(h1+h2),h1+h2,0) - p7 = Vector(width-(h1+h2),(height/2)-h2,0) - p8 = Vector(h1+h2,(height/2)-h2,0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - p1 = Vector(h1+tol,(height/2)+tol,0) - p2 = Vector(width-(h1+tol),(height/2)+tol,0) - p3 = Vector(width-(h1+tol),height-(h1+tol),0) - p4 = Vector(h1+tol,height-(h1+tol),0) - p5 = Vector(h1+h2,(height/2)+h2,0) - p6 = Vector(width-(h1+h2),(height/2)+h2,0) - p7 = Vector(width-(h1+h2),height-(h1+h2),0) - p8 = Vector(h1+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',16,2,20,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,2,14,2,-h2)) - s.addConstraint(Sketcher.Constraint('Equal',23,15)) - s.addConstraint(Sketcher.Constraint('DistanceX',12,1,20,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',13,2,20,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,1,16,1,tol)) - s.addConstraint(Sketcher.Constraint('PointOnObject',9,2,17)) - s.addConstraint(Sketcher.Constraint('PointOnObject',16,1,11)) - if h1 == h2: - s.renameConstraint(55,'Frame5') - s.renameConstraint(56,'Frame6') - s.renameConstraint(57,'Frame7') - s.renameConstraint(58,'Frame8') - s.renameConstraint(59,'Frame9') - s.renameConstraint(60,'F10') - s.setExpression('.Constraints.F10','-.Constraints.Frame5') - fw = str(w2) - if w2 == w1: - fw = "0.00+V" - wp.extend(["LowerFrame","Frame","Wire2,Wire3",fw,str(o2+w2)+"+V"]) - wp.extend(["LowerGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2+w2/2)+"+V"]) - wp.extend(["UpperFrame","Frame","Wire4,Wire5",fw,str(o2)+"+V"]) - wp.extend(["UpperGlass","Glass panel","Wire5",str(w2/gla),str(o2+w2/2)+"+V"]) - - elif windowtype == "Sliding 2-pane": - - wp = outerFrame(s,width,height,h1,w1,o1) - p1 = Vector(h1+tol,h1+tol,0) - p2 = Vector((width/2)-tol,h1+tol,0) - p3 = Vector((width/2)-tol,height-(h1+tol),0) - p4 = Vector(h1+tol,height-(h1+tol),0) - p5 = Vector(h1+h2,h1+h2,0) - p6 = Vector((width/2)-h2,h1+h2,0) - p7 = Vector((width/2)-h2,height-(h1+h2),0) - p8 = Vector(h1+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - p1 = Vector((width/2)+tol,h1+tol,0) - p2 = Vector(width-(h1+tol),h1+tol,0) - p3 = Vector(width-(h1+tol),height-(h1+tol),0) - p4 = Vector((width/2)+tol,height-(h1+tol),0) - p5 = Vector((width/2)+h2,h1+h2,0) - p6 = Vector(width-(h1+h2),h1+h2,0) - p7 = Vector(width-(h1+h2),height-(h1+h2),0) - p8 = Vector((width/2)+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('Equal',22,14)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,1,18,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',9,1,19,2,tol)) - s.addConstraint(Sketcher.Constraint('PointOnObject',13,2,22)) - s.addConstraint(Sketcher.Constraint('PointOnObject',12,2,20)) - if h1 == h2: - s.renameConstraint(55,'Frame5') - s.renameConstraint(56,'Frame6') - s.renameConstraint(57,'Frame7') - s.renameConstraint(58,'Frame8') - s.renameConstraint(59,'Frame9') - s.renameConstraint(60,'Frame10') - fw = str(w2) - if w2 == w1: - fw = "0.00+V" - wp.extend(["LeftFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) - wp.extend(["LeftGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) - wp.extend(["RightFrame","Frame","Wire4,Wire5",fw,str(o2+w2)+"+V"]) - wp.extend(["RightGlass","Glass panel","Wire5",str(w2/gla),str(o2+w2+w2/2)+"+V"]) - - elif windowtype == "Sliding 4-pane": - - wp = outerFrame(s,width,height,h1,w1,o1) - p1 = Vector(h1+tol,h1+tol,0) - p2 = Vector(width/4-tol,h1+tol,0) - p3 = Vector(width/4-tol,height-(h1+tol),0) - p4 = Vector(h1+tol,height-(h1+tol),0) - p5 = Vector(h1+h2,h1+h2,0) - p6 = Vector(width/4-h2,h1+h2,0) - p7 = Vector(width/4-h2,height-(h1+h2),0) - p8 = Vector(h1+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - p1 = Vector(width/4+tol,h1+tol,0) - p2 = Vector(width/2-tol,h1+tol,0) - p3 = Vector(width/2-tol,height-(h1+tol),0) - p4 = Vector(width/4+tol,height-(h1+tol),0) - p5 = Vector(width/4+h2,h1+h2,0) - p6 = Vector(width/2-h2,h1+h2,0) - p7 = Vector(width/2-h2,height-(h1+h2),0) - p8 = Vector(width/4+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - p1 = Vector(width/2+tol,h1+tol,0) - p2 = Vector(width*3/4-tol,h1+tol,0) - p3 = Vector(width*3/4-tol,height-(h1+tol),0) - p4 = Vector(width/2+tol,height-(h1+tol),0) - p5 = Vector(width/2+h2,h1+h2,0) - p6 = Vector(width*3/4-h2,h1+h2,0) - p7 = Vector(width*3/4-h2,height-(h1+h2),0) - p8 = Vector(width/2+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - p1 = Vector(width*3/4+tol,h1+tol,0) - p2 = Vector(width-(h1+tol),h1+tol,0) - p3 = Vector(width-(h1+tol),height-(h1+tol),0) - p4 = Vector(width*3/4+tol,height-(h1+tol),0) - p5 = Vector(width*3/4+h2,h1+h2,0) - p6 = Vector(width-(h1+h2),h1+h2,0) - p7 = Vector(width-(h1+h2),height-(h1+h2),0) - p8 = Vector(width*3/4+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',8,2,16,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',17,1,27,2,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',24,2,32,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',32,2,4,2,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,2,6,2,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',17,2,26,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',25,2,34,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',9,2,18,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',16,2,24,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',24,2,32,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',13,2,9,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',13,2,9,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',16,1,20,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',24,1,28,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',24,1,28,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',29,2,25,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',29,2,25,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',32,1,36,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',32,1,36,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',37,2,33,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',37,2,33,2,h2)) - s.addConstraint(Sketcher.Constraint('Equal',14,22)) - s.addConstraint(Sketcher.Constraint('Equal',22,30)) - s.addConstraint(Sketcher.Constraint('Equal',30,38)) - if h1 == h2: - s.renameConstraint(100,'Frame5') - s.renameConstraint(101,'Frame6') - s.renameConstraint(102,'Frame7') - s.renameConstraint(103,'Frame8') - s.renameConstraint(104,'Frame9') - s.renameConstraint(105,'Frame10') - s.renameConstraint(106,'Frame11') - s.renameConstraint(107,'Frame12') - s.renameConstraint(108,'Frame13') - s.renameConstraint(109,'Frame14') - s.renameConstraint(110,'Frame15') - s.renameConstraint(111,'Frame16') - s.renameConstraint(112,'Frame17') - s.renameConstraint(113,'Frame18') - s.renameConstraint(114,'Frame19') - s.renameConstraint(115,'Frame20') - fw = str(w2) - if w2 == w1: - fw = "0.00+V" - wp.extend(["LeftMostFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) - wp.extend(["LeftMostGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) - wp.extend(["LeftFrame","Frame","Wire4,Wire5",fw,str(o2+w2)+"+V"]) - wp.extend(["LeftGlass","Glass panel","Wire5",str(w2/gla),str(o2+w2+w2/2)+"+V"]) - wp.extend(["RightFrame","Frame","Wire6,Wire7",fw,str(o2+w2)+"+V"]) - wp.extend(["RightGlass","Glass panel","Wire7",str(w2/gla),str(o2+w2+w2/2)+"+V"]) - wp.extend(["RightMostFrame","Frame","Wire8,Wire9",fw,str(o2)+"+V"]) - wp.extend(["RightMostGlass","Glass panel","Wire9",str(w2/gla),str(o2+w2/2)+"+V"]) - - elif windowtype == "Simple door": - - wp = doorFrame(s,width,height,h1,w1,o1) - wp.extend(["Door","Solid panel","Wire1",str(w2),str(o2)+"+V"]) - - elif windowtype == "Glass door": - - wp = doorFrame(s,width,height,h1,w1,o1) - p1 = Vector(h1+tol,h1+tol,0) - p2 = Vector(width-(h1+tol),h1+tol,0) - p3 = Vector(width-(h1+tol),height-(h1+tol),0) - p4 = Vector(h1+tol,height-(h1+tol),0) - p5 = Vector(h1+h2,h1+h3,0) - p6 = Vector(width-(h1+h2),h1+h3,0) - p7 = Vector(width-(h1+h2),height-(h1+h2),0) - p8 = Vector(h1+h2,height-(h1+h2),0) - addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h3)) - s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',10,1,6,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,1,6,1,tol)) - if h2 == h1: - s.renameConstraint(39,'Frame5') - s.renameConstraint(40,'Frame6') - s.renameConstraint(42,'Frame7') - s.renameConstraint(41,'Frame8') - fw = str(w2) - if w2 == w1: - fw = "0.00+V" - wp.extend(["InnerFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) - wp.extend(["InnerGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) - - return (s,wp) - - if windowtype in WindowPresets: - default = makeSketch(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2) - FreeCAD.ActiveDocument.recompute() - if default: - if placement: - default[0].Placement = placement - FreeCAD.ActiveDocument.recompute() - obj = makeWindow(default[0],width,height,default[1]) - obj.Preset = WindowPresets.index(windowtype)+1 - obj.Frame = h1 - obj.Offset = o1 - obj.Placement = FreeCAD.Placement() # unable to find where this bug comes from... - if "door" in windowtype: - obj.IfcType = "Door" - obj.Label = translate("Arch","Door") - FreeCAD.ActiveDocument.recompute() - return obj - - print("Arch: Unknown window type") @@ -585,7 +142,7 @@ class _CommandWindow: "the Arch Window command definition" def __init__(self): - + self.doormode = False def GetResources(self): @@ -653,6 +210,17 @@ class _CommandWindow: FreeCAD.ActiveDocument.recompute() return + # Try to detect an object to use as a window type - TODO we must make this safer + + elif obj.Shape.Solids and (Draft.getType(obj) not in ["Wall","Structure","Roof"]): + # we consider the selected object as a type + FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Window")) + FreeCADGui.addModule("Arch") + FreeCADGui.doCommand("Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")") + FreeCAD.ActiveDocument.commitTransaction() + FreeCAD.ActiveDocument.recompute() + return + # interactive mode if hasattr(FreeCAD,"DraftWorkingPlane"): FreeCAD.DraftWorkingPlane.setup() @@ -1029,22 +597,11 @@ class _Window(ArchComponent.Component): # mark host to recompute so it can detect this object host.touch() if prop in ["Width","Height","Frame"]: - if obj.Base and hasattr(obj.Base,"Constraints"): - if prop == "Height": - if obj.Height.Value > 0: - for c in obj.Base.Constraints: - if c.Name == "Height": - obj.Base.setDatum(c.Name,obj.Height.Value) - elif prop == "Width": - if obj.Width.Value > 0: - for c in obj.Base.Constraints: - if c.Name == "Width": - obj.Base.setDatum(c.Name,obj.Width.Value) - elif prop == "Frame": - if obj.Frame.Value > 0: - for c in obj.Base.Constraints: - if "Frame" in c.Name: - obj.Base.setDatum(c.Name,obj.Frame.Value) + if obj.Base: + if hasattr(obj.Base,"Constraints") and (prop in [c.Name for c in obj.Base.Constraints]): + val = getattr(obj,prop).Value + if val > 0: + obj.Base.setDatum(prop,val) else: ArchComponent.Component.onChanged(self,obj,prop) @@ -1272,8 +829,9 @@ class _Window(ArchComponent.Component): elif not obj.WindowParts: if not obj.Base.Shape.isNull(): base = obj.Base.Shape.copy() - if not DraftGeomUtils.isNull(pl): - base.Placement = base.Placement.multiply(pl) + # obj placement is already added by applyShape() below + #if not DraftGeomUtils.isNull(pl): + # base.Placement = base.Placement.multiply(pl) else: print("Arch: Bad formatting of window parts definitions") @@ -1311,8 +869,11 @@ class _Window(ArchComponent.Component): if hasattr(obj.Subvolume,'Shape'): if not obj.Subvolume.Shape.isNull(): sh = obj.Subvolume.Shape.copy() + pl = FreeCAD.Placement(sh.Placement) + pl = pl.multiply(obj.Placement) if plac: - sh.Placement = plac + pl = pl.multiply(plac) + sh.Placement = pl return sh # getting extrusion depth @@ -1366,7 +927,7 @@ class _Window(ArchComponent.Component): f = base.Shape.Wires[obj.HoleWire-1] if not f: - if Draft.isClone(obj,"Window"): + if Draft.isClone(obj,"Window"): # check original HoleWire then if orig.HoleWire > 0: if orig.HoleWire <= len(base.Shape.Wires): @@ -1487,8 +1048,6 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent): if self.areDifferentColors(obj.ViewObject.DiffuseColor,obj.CloneOf.ViewObject.DiffuseColor) or force: obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor return - if not obj.WindowParts: - return if not obj.Shape: return if not obj.Shape.Solids: @@ -1499,25 +1058,23 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent): base = obj.ViewObject.ShapeColor for i in range(len(solids)): ccol = None - if len(obj.WindowParts) > i*5: + if obj.WindowParts and len(obj.WindowParts) > i*5: + # WindowParts-based window name = obj.WindowParts[(i*5)] mtype = obj.WindowParts[(i*5)+1] - if hasattr(obj,"Material"): - if obj.Material: - if hasattr(obj.Material,"Materials"): - if obj.Material.Names: - mat = None - if name in obj.Material.Names: - mat = obj.Material.Materials[obj.Material.Names.index(name)] - elif mtype in obj.Material.Names: - mat = obj.Material.Materials[obj.Material.Names.index(mtype)] - if mat: - if 'DiffuseColor' in mat.Material: - if "(" in mat.Material['DiffuseColor']: - ccol = tuple([float(f) for f in mat.Material['DiffuseColor'].strip("()").split(",")]) - if ccol and ('Transparency' in mat.Material): - t = float(mat.Material['Transparency'])/100.0 - ccol = (ccol[0],ccol[1],ccol[2],t) + ccol = self.getSolidMaterial(obj,name,mtype) + elif obj.Base and hasattr(obj.Base,"Shape"): + # Type-based window: obj.Base furnishes the window solids + sol1 = self.getSolidSignature(solids[i]) + # here we look for all the ways to retrieve a name for each + # solid. Currently we look for similar solids in the + if hasattr(obj.Base,"Group"): + for child in obj.Base.Group: + if hasattr(child,"Shape") and child.Shape and child.Shape.Solids: + sol2 = self.getSolidSignature(child.Shape) + if sol1 == sol2: + ccol = self.getSolidMaterial(obj,child.Label) + break if not ccol: typeidx = (i*5)+1 if typeidx < len(obj.WindowParts): @@ -1531,6 +1088,32 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent): if self.areDifferentColors(colors,obj.ViewObject.DiffuseColor) or force: obj.ViewObject.DiffuseColor = colors + def getSolidSignature(self,solid): + + """Returns a tuple defining as uniquely as possible a solid""" + + return (solid.ShapeType,solid.Volume,solid.Area,solid.Length) + + def getSolidMaterial(self,obj,name,mtype=None): + + ccol = None + if hasattr(obj,"Material"): + if obj.Material: + if hasattr(obj.Material,"Materials"): + if obj.Material.Names: + mat = None + if name in obj.Material.Names: + mat = obj.Material.Materials[obj.Material.Names.index(name)] + elif mtype and (mtype in obj.Material.Names): + mat = obj.Material.Materials[obj.Material.Names.index(mtype)] + if mat: + if 'DiffuseColor' in mat.Material: + if "(" in mat.Material['DiffuseColor']: + ccol = tuple([float(f) for f in mat.Material['DiffuseColor'].strip("()").split(",")]) + if ccol and ('Transparency' in mat.Material): + t = float(mat.Material['Transparency'])/100.0 + ccol = (ccol[0],ccol[1],ccol[2],t) + return ccol class _ArchWindowTaskPanel: diff --git a/src/Mod/Arch/ArchWindowPresets.py b/src/Mod/Arch/ArchWindowPresets.py new file mode 100644 index 0000000000..19c756c2ae --- /dev/null +++ b/src/Mod/Arch/ArchWindowPresets.py @@ -0,0 +1,487 @@ +#*************************************************************************** +#* Copyright (c) 2020 Yorik van Havre * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#*************************************************************************** + +import FreeCAD +from FreeCAD import Vector + +WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane", + "Sliding 2-pane", "Simple door", "Glass door", "Sliding 4-pane"] + +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""" + + if not FreeCAD.ActiveDocument: + FreeCAD.Console.PrintError("No active document. Aborting\n") + return + + def makeSketch(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2): + + import Part,Sketcher + width = float(width) + height = float(height) + h1 = float(h1) + h2 = float(h2) + h3 = float(h3) + w1 = float(w1) + w2 = float(w2) + o1 = float(o1) + o2 = float(o2) + # small spacing to avoid wrong auto-wires in sketch + tol = h1/10 + # glass size divider + gla = 10 + s = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Sketch') + + def addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8): + + "adds two rectangles to the given sketch" + + idx = s.GeometryCount + s.addGeometry(Part.LineSegment(p1,p2)) + s.addGeometry(Part.LineSegment(p2,p3)) + s.addGeometry(Part.LineSegment(p3,p4)) + s.addGeometry(Part.LineSegment(p4,p1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx,2,idx+1,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+1,2,idx+2,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+2,2,idx+3,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+3,2,idx,1)) + s.addConstraint(Sketcher.Constraint('Horizontal',idx)) + s.addConstraint(Sketcher.Constraint('Horizontal',idx+2)) + s.addConstraint(Sketcher.Constraint('Vertical',idx+1)) + s.addConstraint(Sketcher.Constraint('Vertical',idx+3)) + s.addGeometry(Part.LineSegment(p5,p6)) + s.addGeometry(Part.LineSegment(p6,p7)) + s.addGeometry(Part.LineSegment(p7,p8)) + s.addGeometry(Part.LineSegment(p8,p5)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+4,2,idx+5,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+5,2,idx+6,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+6,2,idx+7,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+7,2,idx+4,1)) + s.addConstraint(Sketcher.Constraint('Horizontal',idx+4)) + s.addConstraint(Sketcher.Constraint('Horizontal',idx+6)) + s.addConstraint(Sketcher.Constraint('Vertical',idx+5)) + s.addConstraint(Sketcher.Constraint('Vertical',idx+7)) + + def outerFrame(s,width,height,h1,w1,o1): + + p1 = Vector(0,0,0) + p2 = Vector(width,0,0) + p3 = Vector(width,height,0) + p4 = Vector(0,height,0) + p5 = Vector(h1,h1,0) + p6 = Vector(width-h1,h1,0) + p7 = Vector(width-h1,height-h1,0) + p8 = Vector(h1,height-h1,0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + s.addConstraint(Sketcher.Constraint('DistanceY',1,height)) #16 + s.addConstraint(Sketcher.Constraint('DistanceX',0,width)) #17 + s.renameConstraint(16, 'Height') + s.renameConstraint(17, 'Width') + s.addConstraint(Sketcher.Constraint('DistanceY',6,2,2,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceX',2,2,6,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,2,0,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceY',0,2,4,2,h1)) + s.renameConstraint(18, 'Frame1') + s.renameConstraint(19, 'Frame2') + s.renameConstraint(20, 'Frame3') + s.renameConstraint(21, 'Frame4') + s.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) + return ["OuterFrame","Frame","Wire0,Wire1",str(w1-w2)+"+V","0.00+V"] + + def doorFrame(s,width,height,h1,w1,o1): + + p1 = Vector(0,0,0) + p2 = Vector(width,0,0) + p3 = Vector(width,height,0) + p4 = Vector(0,height,0) + p5 = Vector(h1,0,0) + p6 = Vector(width-h1,0,0) + p7 = Vector(width-h1,height-h1,0) + p8 = Vector(h1,height-h1,0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + s.addConstraint(Sketcher.Constraint('DistanceY',1,height)) #16 + s.addConstraint(Sketcher.Constraint('DistanceX',0,width)) #17 + s.renameConstraint(16, 'Height') + s.renameConstraint(17, 'Width') + s.addConstraint(Sketcher.Constraint('DistanceY',6,2,2,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceX',2,2,6,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,2,0,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceY',0,2,4,2,0.0)) + s.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) + s.renameConstraint(18, 'Frame1') + s.renameConstraint(19, 'Frame2') + s.renameConstraint(20, 'Frame3') + return ["OuterFrame","Frame","Wire0,Wire1",str(w1-w2)+"+V","0.00+V"] + + if windowtype == "Fixed": + + wp = outerFrame(s,width,height,h1,w1,o1) + wp.extend(["Glass","Glass panel","Wire1",str(w1/gla),str(w1/2)+"+V"]) + + elif windowtype == "Open 1-pane": + + wp = outerFrame(s,width,height,h1,w1,o1) + p1 = Vector(h1+tol,h1+tol,0) + p2 = Vector(width-(h1+tol),h1+tol,0) + p3 = Vector(width-(h1+tol),height-(h1+tol),0) + p4 = Vector(h1+tol,height-(h1+tol),0) + p5 = Vector(h1+h2,h1+h2,0) + p6 = Vector(width-(h1+h2),h1+h2,0) + p7 = Vector(width-(h1+h2),height-(h1+h2),0) + p8 = Vector(h1+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',10,1,6,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,1,6,1,tol)) + if h2 == h1: + s.renameConstraint(39,'Frame5') + s.renameConstraint(40,'Frame6') + s.renameConstraint(42,'Frame7') + s.renameConstraint(41,'Frame8') + fw = str(w2) + if w2 == w1: + fw = "0.00+V" + wp.extend(["InnerFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) + wp.extend(["InnerGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) + + elif windowtype == "Open 2-pane": + + wp = outerFrame(s,width,height,h1,w1,o1) + p1 = Vector(h1+tol,h1+tol,0) + p2 = Vector((width/2)-tol,h1+tol,0) + p3 = Vector((width/2)-tol,height-(h1+tol),0) + p4 = Vector(h1+tol,height-(h1+tol),0) + p5 = Vector(h1+h2,h1+h2,0) + p6 = Vector((width/2)-h2,h1+h2,0) + p7 = Vector((width/2)-h2,height-(h1+h2),0) + p8 = Vector(h1+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + p1 = Vector((width/2)+tol,h1+tol,0) + p2 = Vector(width-(h1+tol),h1+tol,0) + p3 = Vector(width-(h1+tol),height-(h1+tol),0) + p4 = Vector((width/2)+tol,height-(h1+tol),0) + p5 = Vector((width/2)+h2,h1+h2,0) + p6 = Vector(width-(h1+h2),h1+h2,0) + p7 = Vector(width-(h1+h2),height-(h1+h2),0) + p8 = Vector((width/2)+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('Equal',22,14)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,1,18,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',9,1,19,2,tol)) + s.addConstraint(Sketcher.Constraint('PointOnObject',13,2,22)) + s.addConstraint(Sketcher.Constraint('PointOnObject',20,1,12)) + if h1 == h2: + s.renameConstraint(55,'Frame5') + s.renameConstraint(56,'Frame6') + s.renameConstraint(57,'Frame7') + s.renameConstraint(58,'Frame8') + s.renameConstraint(59,'Frame9') + s.renameConstraint(60,'Frame10') + fw = str(w2) + if w2 == w1: + fw = "0.00+V" + wp.extend(["LeftFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) + wp.extend(["LeftGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) + wp.extend(["RightFrame","Frame","Wire4,Wire5",fw,str(o2)+"+V"]) + wp.extend(["RightGlass","Glass panel","Wire5",str(w2/gla),str(o2+w2/2)+"+V"]) + + elif windowtype == "Sash 2-pane": + + wp = outerFrame(s,width,height,h1,w1,o1) + p1 = Vector(h1+tol,h1+tol,0) + p2 = Vector(width-(h1+tol),h1+tol,0) + p3 = Vector(width-(h1+tol),(height/2)-tol,0) + p4 = Vector(h1+tol,(height/2)-tol,0) + p5 = Vector(h1+h2,h1+h2,0) + p6 = Vector(width-(h1+h2),h1+h2,0) + p7 = Vector(width-(h1+h2),(height/2)-h2,0) + p8 = Vector(h1+h2,(height/2)-h2,0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + p1 = Vector(h1+tol,(height/2)+tol,0) + p2 = Vector(width-(h1+tol),(height/2)+tol,0) + p3 = Vector(width-(h1+tol),height-(h1+tol),0) + p4 = Vector(h1+tol,height-(h1+tol),0) + p5 = Vector(h1+h2,(height/2)+h2,0) + p6 = Vector(width-(h1+h2),(height/2)+h2,0) + p7 = Vector(width-(h1+h2),height-(h1+h2),0) + p8 = Vector(h1+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',16,2,20,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,2,14,2,-h2)) + s.addConstraint(Sketcher.Constraint('Equal',23,15)) + s.addConstraint(Sketcher.Constraint('DistanceX',12,1,20,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',13,2,20,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,1,16,1,tol)) + s.addConstraint(Sketcher.Constraint('PointOnObject',9,2,17)) + s.addConstraint(Sketcher.Constraint('PointOnObject',16,1,11)) + if h1 == h2: + s.renameConstraint(55,'Frame5') + s.renameConstraint(56,'Frame6') + s.renameConstraint(57,'Frame7') + s.renameConstraint(58,'Frame8') + s.renameConstraint(59,'Frame9') + s.renameConstraint(60,'F10') + s.setExpression('.Constraints.F10','-.Constraints.Frame5') + fw = str(w2) + if w2 == w1: + fw = "0.00+V" + wp.extend(["LowerFrame","Frame","Wire2,Wire3",fw,str(o2+w2)+"+V"]) + wp.extend(["LowerGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2+w2/2)+"+V"]) + wp.extend(["UpperFrame","Frame","Wire4,Wire5",fw,str(o2)+"+V"]) + wp.extend(["UpperGlass","Glass panel","Wire5",str(w2/gla),str(o2+w2/2)+"+V"]) + + elif windowtype == "Sliding 2-pane": + + wp = outerFrame(s,width,height,h1,w1,o1) + p1 = Vector(h1+tol,h1+tol,0) + p2 = Vector((width/2)-tol,h1+tol,0) + p3 = Vector((width/2)-tol,height-(h1+tol),0) + p4 = Vector(h1+tol,height-(h1+tol),0) + p5 = Vector(h1+h2,h1+h2,0) + p6 = Vector((width/2)-h2,h1+h2,0) + p7 = Vector((width/2)-h2,height-(h1+h2),0) + p8 = Vector(h1+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + p1 = Vector((width/2)+tol,h1+tol,0) + p2 = Vector(width-(h1+tol),h1+tol,0) + p3 = Vector(width-(h1+tol),height-(h1+tol),0) + p4 = Vector((width/2)+tol,height-(h1+tol),0) + p5 = Vector((width/2)+h2,h1+h2,0) + p6 = Vector(width-(h1+h2),h1+h2,0) + p7 = Vector(width-(h1+h2),height-(h1+h2),0) + p8 = Vector((width/2)+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('Equal',22,14)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,1,18,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',9,1,19,2,tol)) + s.addConstraint(Sketcher.Constraint('PointOnObject',13,2,22)) + s.addConstraint(Sketcher.Constraint('PointOnObject',12,2,20)) + if h1 == h2: + s.renameConstraint(55,'Frame5') + s.renameConstraint(56,'Frame6') + s.renameConstraint(57,'Frame7') + s.renameConstraint(58,'Frame8') + s.renameConstraint(59,'Frame9') + s.renameConstraint(60,'Frame10') + fw = str(w2) + if w2 == w1: + fw = "0.00+V" + wp.extend(["LeftFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) + wp.extend(["LeftGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) + wp.extend(["RightFrame","Frame","Wire4,Wire5",fw,str(o2+w2)+"+V"]) + wp.extend(["RightGlass","Glass panel","Wire5",str(w2/gla),str(o2+w2+w2/2)+"+V"]) + + elif windowtype == "Sliding 4-pane": + + wp = outerFrame(s,width,height,h1,w1,o1) + p1 = Vector(h1+tol,h1+tol,0) + p2 = Vector(width/4-tol,h1+tol,0) + p3 = Vector(width/4-tol,height-(h1+tol),0) + p4 = Vector(h1+tol,height-(h1+tol),0) + p5 = Vector(h1+h2,h1+h2,0) + p6 = Vector(width/4-h2,h1+h2,0) + p7 = Vector(width/4-h2,height-(h1+h2),0) + p8 = Vector(h1+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + p1 = Vector(width/4+tol,h1+tol,0) + p2 = Vector(width/2-tol,h1+tol,0) + p3 = Vector(width/2-tol,height-(h1+tol),0) + p4 = Vector(width/4+tol,height-(h1+tol),0) + p5 = Vector(width/4+h2,h1+h2,0) + p6 = Vector(width/2-h2,h1+h2,0) + p7 = Vector(width/2-h2,height-(h1+h2),0) + p8 = Vector(width/4+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + p1 = Vector(width/2+tol,h1+tol,0) + p2 = Vector(width*3/4-tol,h1+tol,0) + p3 = Vector(width*3/4-tol,height-(h1+tol),0) + p4 = Vector(width/2+tol,height-(h1+tol),0) + p5 = Vector(width/2+h2,h1+h2,0) + p6 = Vector(width*3/4-h2,h1+h2,0) + p7 = Vector(width*3/4-h2,height-(h1+h2),0) + p8 = Vector(width/2+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + p1 = Vector(width*3/4+tol,h1+tol,0) + p2 = Vector(width-(h1+tol),h1+tol,0) + p3 = Vector(width-(h1+tol),height-(h1+tol),0) + p4 = Vector(width*3/4+tol,height-(h1+tol),0) + p5 = Vector(width*3/4+h2,h1+h2,0) + p6 = Vector(width-(h1+h2),h1+h2,0) + p7 = Vector(width-(h1+h2),height-(h1+h2),0) + p8 = Vector(width*3/4+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,2,16,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',17,1,27,2,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',24,2,32,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',32,2,4,2,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,2,6,2,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',17,2,26,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',25,2,34,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',9,2,18,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',16,2,24,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',24,2,32,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',13,2,9,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',13,2,9,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',16,1,20,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',24,1,28,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',24,1,28,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',29,2,25,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',29,2,25,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',32,1,36,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',32,1,36,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',37,2,33,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',37,2,33,2,h2)) + s.addConstraint(Sketcher.Constraint('Equal',14,22)) + s.addConstraint(Sketcher.Constraint('Equal',22,30)) + s.addConstraint(Sketcher.Constraint('Equal',30,38)) + if h1 == h2: + s.renameConstraint(100,'Frame5') + s.renameConstraint(101,'Frame6') + s.renameConstraint(102,'Frame7') + s.renameConstraint(103,'Frame8') + s.renameConstraint(104,'Frame9') + s.renameConstraint(105,'Frame10') + s.renameConstraint(106,'Frame11') + s.renameConstraint(107,'Frame12') + s.renameConstraint(108,'Frame13') + s.renameConstraint(109,'Frame14') + s.renameConstraint(110,'Frame15') + s.renameConstraint(111,'Frame16') + s.renameConstraint(112,'Frame17') + s.renameConstraint(113,'Frame18') + s.renameConstraint(114,'Frame19') + s.renameConstraint(115,'Frame20') + fw = str(w2) + if w2 == w1: + fw = "0.00+V" + wp.extend(["LeftMostFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) + wp.extend(["LeftMostGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) + wp.extend(["LeftFrame","Frame","Wire4,Wire5",fw,str(o2+w2)+"+V"]) + wp.extend(["LeftGlass","Glass panel","Wire5",str(w2/gla),str(o2+w2+w2/2)+"+V"]) + wp.extend(["RightFrame","Frame","Wire6,Wire7",fw,str(o2+w2)+"+V"]) + wp.extend(["RightGlass","Glass panel","Wire7",str(w2/gla),str(o2+w2+w2/2)+"+V"]) + wp.extend(["RightMostFrame","Frame","Wire8,Wire9",fw,str(o2)+"+V"]) + wp.extend(["RightMostGlass","Glass panel","Wire9",str(w2/gla),str(o2+w2/2)+"+V"]) + + elif windowtype == "Simple door": + + wp = doorFrame(s,width,height,h1,w1,o1) + wp.extend(["Door","Solid panel","Wire1",str(w2),str(o2)+"+V"]) + + elif windowtype == "Glass door": + + wp = doorFrame(s,width,height,h1,w1,o1) + p1 = Vector(h1+tol,h1+tol,0) + p2 = Vector(width-(h1+tol),h1+tol,0) + p3 = Vector(width-(h1+tol),height-(h1+tol),0) + p4 = Vector(h1+tol,height-(h1+tol),0) + p5 = Vector(h1+h2,h1+h3,0) + p6 = Vector(width-(h1+h2),h1+h3,0) + p7 = Vector(width-(h1+h2),height-(h1+h2),0) + p8 = Vector(h1+h2,height-(h1+h2),0) + addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h3)) + s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',10,1,6,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,1,6,1,tol)) + if h2 == h1: + s.renameConstraint(39,'Frame5') + s.renameConstraint(40,'Frame6') + s.renameConstraint(42,'Frame7') + s.renameConstraint(41,'Frame8') + fw = str(w2) + if w2 == w1: + fw = "0.00+V" + wp.extend(["InnerFrame","Frame","Wire2,Wire3",fw,str(o2)+"+V"]) + wp.extend(["InnerGlass","Glass panel","Wire3",str(w2/gla),str(o2+w2/2)+"+V"]) + + return (s,wp) + + if windowtype in WindowPresets: + import ArchWindow + default = makeSketch(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2) + FreeCAD.ActiveDocument.recompute() + if default: + if placement: + default[0].Placement = placement + FreeCAD.ActiveDocument.recompute() + obj = ArchWindow.makeWindow(default[0],width,height,default[1]) + obj.Preset = WindowPresets.index(windowtype)+1 + obj.Frame = h1 + obj.Offset = o1 + obj.Placement = FreeCAD.Placement() # unable to find where this bug comes from... + if "door" in windowtype: + obj.IfcType = "Door" + obj.Label = translate("Arch","Door") + FreeCAD.ActiveDocument.recompute() + return obj + + print("Arch: Unknown window type") diff --git a/src/Mod/Arch/CMakeLists.txt b/src/Mod/Arch/CMakeLists.txt index 1ed820e16e..1e9a2041cd 100644 --- a/src/Mod/Arch/CMakeLists.txt +++ b/src/Mod/Arch/CMakeLists.txt @@ -25,6 +25,7 @@ SET(Arch_SRCS importDAE.py importOBJ.py ArchWindow.py + ArchWindowPresets.py ArchAxis.py ArchVRM.py ArchRoof.py