Arch: Allow to build windows on any shape that contains wires

This commit is contained in:
Yorik van Havre
2017-08-08 20:16:06 -03:00
parent 8d71bfba72
commit e1848f2eca

View File

@@ -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"):