From e1848f2eca4fdac3285dce72ba8f443fab96299f Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 8 Aug 2017 20:16:06 -0300 Subject: [PATCH] Arch: Allow to build windows on any shape that contains wires --- src/Mod/Arch/ArchWindow.py | 67 +++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index 3e8fa34860..37040b5032 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -419,42 +419,43 @@ class _CommandWindow: if FreeCADGui.Selection.getSelectionEx(): FreeCADGui.draftToolBar.offUi() obj = self.sel[0] - if obj.isDerivedFrom("Part::Part2DObject"): - FreeCADGui.Control.closeDialog() - host = None - if hasattr(obj,"Support"): - if obj.Support: - if isinstance(obj.Support,tuple): - host = obj.Support[0] - elif isinstance(obj.Support,list): - host = obj.Support[0][0] - else: - host = obj.Support - obj.Support = None # remove - elif Draft.isClone(obj,"Window"): - if obj.Objects[0].Inlist: - host = obj.Objects[0].Inlist[0] - - FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Window")) - FreeCADGui.addModule("Arch") - FreeCADGui.doCommand("win = Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")") - if host and self.Include: - if self.RemoveExternal: - FreeCADGui.doCommand("Arch.removeComponents(win,host=FreeCAD.ActiveDocument."+host.Name+")") - else: - # make a new object to avoid circular references - FreeCADGui.doCommand("host=Arch.make"+Draft.getType(host)+"(FreeCAD.ActiveDocument."+host.Name+")") - FreeCADGui.doCommand("Arch.removeComponents(win,host)") - siblings = host.Proxy.getSiblings(host) - for sibling in siblings: + if obj.isDerivedFrom("Part::Feature"): + if obj.Shape.Wires and not obj.Shape.Faces: + FreeCADGui.Control.closeDialog() + host = None + if hasattr(obj,"Support"): + if obj.Support: + if isinstance(obj.Support,tuple): + host = obj.Support[0] + elif isinstance(obj.Support,list): + host = obj.Support[0][0] + else: + host = obj.Support + obj.Support = None # remove + elif Draft.isClone(obj,"Window"): + if obj.Objects[0].Inlist: + host = obj.Objects[0].Inlist[0] + + FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Window")) + FreeCADGui.addModule("Arch") + FreeCADGui.doCommand("win = Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")") + if host and self.Include: if self.RemoveExternal: - FreeCADGui.doCommand("Arch.removeComponents(win,host=FreeCAD.ActiveDocument."+sibling.Name+")") + FreeCADGui.doCommand("Arch.removeComponents(win,host=FreeCAD.ActiveDocument."+host.Name+")") else: - FreeCADGui.doCommand("host=Arch.make"+Draft.getType(sibling)+"(FreeCAD.ActiveDocument."+sibling.Name+")") + # make a new object to avoid circular references + FreeCADGui.doCommand("host=Arch.make"+Draft.getType(host)+"(FreeCAD.ActiveDocument."+host.Name+")") FreeCADGui.doCommand("Arch.removeComponents(win,host)") - FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() - return + siblings = host.Proxy.getSiblings(host) + for sibling in siblings: + if self.RemoveExternal: + FreeCADGui.doCommand("Arch.removeComponents(win,host=FreeCAD.ActiveDocument."+sibling.Name+")") + else: + FreeCADGui.doCommand("host=Arch.make"+Draft.getType(sibling)+"(FreeCAD.ActiveDocument."+sibling.Name+")") + FreeCADGui.doCommand("Arch.removeComponents(win,host)") + FreeCAD.ActiveDocument.commitTransaction() + FreeCAD.ActiveDocument.recompute() + return # interactive mode if hasattr(FreeCAD,"DraftWorkingPlane"):